forked from opendacs/PyHCL
19 lines
390 B
Python
19 lines
390 B
Python
from pyhcl import *
|
|
|
|
|
|
class FullAdder(Module):
|
|
io = IO(
|
|
a=Input(U.w(1)),
|
|
b=Input(U.w(1)),
|
|
cin=Input(U.w(1)),
|
|
s=Output(U.w(1)),
|
|
cout=Output(U.w(1))
|
|
)
|
|
|
|
io.s @= io.a ^ io.b ^ io.cin
|
|
io.cout @= (io.a & io.b) | (io.a & io.cin) | (io.b & io.cin)
|
|
|
|
|
|
if __name__ == '__main__':
|
|
Emitter.dump(Emitter.emit(FullAdder(), True), "FullAdder.v")
|