1 from nmigen
.compat
.sim
import run_simulation
3 from test_helper
import check
6 def set_cam(dut
, c
, a
, k
, d
):
7 yield dut
.command
.eq(c
)
8 yield dut
.address
.eq(a
)
10 yield dut
.data_in
.eq(d
)
13 def check_data_hit(dut
, data_hit
, op
):
14 out_dh
= yield dut
.data_hit
15 yield from check("Data Hit", out_dh
, data_hit
, op
)
17 def check_data(dut
, data
, op
):
18 out_d
= yield dut
.data
19 yield from check("Data", out_d
, data
, op
)
21 def check_all(dut
, data_hit
, data
, dh_op
, d_op
):
22 yield from check_data_hit(dut
, data_hit
, dh_op
)
23 yield from check_data(dut
, data
, d_op
)
33 yield from set_cam(dut
, command
, address
, key
, data
)
34 yield from check_data_hit(dut
, data_hit
, 0)
42 yield from set_cam(dut
, command
, address
, key
, data
)
43 yield from check_data_hit(dut
, data_hit
, 0)
51 yield from set_cam(dut
, command
, address
, key
, data
)
52 yield from check_data_hit(dut
, data_hit
, 0)
54 if __name__
== "__main__":
56 run_simulation(dut
, testbench(dut
), vcd_name
="Waveforms/cam_test.vcd")
57 print("Cam Unit Test Success")