-
Notifications
You must be signed in to change notification settings - Fork 0
/
FullAdderGL.py
42 lines (32 loc) · 917 Bytes
/
FullAdderGL.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
#=========================================================================
# FullAdderGL
#=========================================================================
from pymtl3 import *
class FullAdderGL( Component ):
def construct( s ):
s.a = InPort()
s.b = InPort()
s.cin = InPort()
s.sum = OutPort()
s.cout = OutPort()
@update
def upblk():
s.sum @= s.cin ^ s.a ^ s.b
s.cout @= ( ( s.a ^ s.b ) & s.cin ) | ( s.a & s.b )
#-------------------------------------------------------------------------
# main
#-------------------------------------------------------------------------
if __name__ == "__main__":
dut = FullAdderGL()
dut.apply( DefaultPassGroup(textwave=True) )
dut.sim_reset()
dut.a @= 0
dut.b @= 1
dut.cin @= 0
dut.sim_tick()
dut.a @= 1
dut.b @= 1
dut.cin @= 1
dut.sim_tick()
dut.sim_tick()
dut.print_textwave()