-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.py
executable file
·50 lines (36 loc) · 862 Bytes
/
test.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import sys
from hwlib import *
from hwlib.basics import *
from hwlib.basic_circuits import *
d = Design()
pwl = Voltage(d, 1)
i1 = Inverter(d)
c1 = Capacitor(d, 2e-15)
d.pair({i1.input: pwl.plus,
pwl.minus: d.vss,
c1.pos: i1.output,
c1.neg: d.vss
})
d.print_netlist(sys.stdout)
inp = True
def toggle(cpp):
global inp
if inp:
inp = False
pwl.alter("0v")
outlevel.highgoing()
else:
inp = True
pwl.alter("1v")
outlevel.lowgoing()
s = Simulation(d, "10n", "test simulation", "test.raw")
s.add_start_callback(toggle)
pmon = s.power(d.vpwr)
outlevel = s.levelhalt(i1.output, 0.05, False)
outlevel.callback = toggle
s.run_full()
print "Simulation end with ", s.sim.status
print "VPwr:"
print " Avg: %e" % pmon.avg()