Py4Hw User Guide> 2.3 Bit Manipulation Operations¶

Next: 3.1 Registers¶

In [1]:
import py4hw
import wavedrom as wd
In [2]:
hw = py4hw.HWSystem()
a = hw.wire('a', 8)
b = hw.wire('b', 8)


a_ls = hw.wires('a_ls_bits', 8, 1)
a_ms = hw.wires('a_ms_bits', 8, 1)

py4hw.Sequence(hw, 'a', [1, 2, 8, 0x0F, 0xF0, 0x80, 0x70, 0x30, 0x10], a)

py4hw.BitsLSBF(hw, 'lsbf',  a, a_ls)
py4hw.BitsMSBF(hw, 'msbf',  a, a_ms)

py4hw.ConcatenateMSBF(hw, 'con', a_ls, b)

watch = [a]
watch.extend(a_ls)
watch.extend(a_ms)
watch.append(b)
wvf = py4hw.Waveform(hw, 'wvf', watch)

hw.getSimulator().clk(20)

wd.render(str(wvf.get_wavedrom(shortNames=True)))
Out[2]:
wvf0123456789101112131415161718192021clka0128FF080703010128FF0807030101a_ls_bits_0a_ls_bits_1a_ls_bits_2a_ls_bits_3a_ls_bits_4a_ls_bits_5a_ls_bits_6a_ls_bits_7a_ms_bits_0a_ms_bits_1a_ms_bits_2a_ms_bits_3a_ms_bits_4a_ms_bits_5a_ms_bits_6a_ms_bits_7b0804010F0F1EC8804010F0F1EC880

Summary¶

  • In py4hw, bits from a wire cannot be obtained or concatenated without using a circuit. This was done to simplify the simulation infrastructure
In [ ]: