Py4Hw User Guide> 1.3 HWSystem¶

Next: 1.4 Logic¶

In py4hw the top element of a circuit hierearchy is always the object HWSystem. This object should be the only one with no parent in the circuit hierarchy.

It also maintains an objet (a singleton object) of the circuit simulator. The simulator can be retrieved by doing .getSimulator() on the HWSystem object.

In [1]:
import py4hw

sys = py4hw.HWSystem()

a = sys.wire('a', 8)
b = sys.wire('b', 8)
reset = sys.wire('reset')
inc = sys.wire('inc')
gt = sys.wire('gt')
eq = sys.wire('eq')
lt = sys.wire('lt')
co = sys.wire('co')

py4hw.Constant(sys, 'reset', 0, reset)
py4hw.Constant(sys, 'inc', 1, inc)

py4hw.Sequence(sys, 'seq', [1,2,3,4,5], a)
py4hw.ModuloCounter(sys, 'count', 7, reset, inc, b, co)
py4hw.Comparator(sys, 'cmp', a, b, gt, eq, lt)


wvf = py4hw.Waveform(sys, 'wvf', [a,b,gt,eq,lt])

sim = sys.getSimulator()
sim.clk(15)

wvf.draw_wavedrom()
Out[1]:

Summary¶

  • HWSystem is the top entity in a py4hw design
In [ ]: