2 sys
.path
.append("../src")
3 sys
.path
.append("../../TestUtil")
5 from nmigen
.compat
.sim
import run_simulation
7 from PteEntry
import PteEntry
9 from test_helper
import assert_op
11 def set_entry(dut
, i
):
15 def check_dirty(dut
, d
, op
):
17 assert_op("Dirty", out_d
, d
, op
)
19 def check_accessed(dut
, a
, op
):
21 assert_op("Accessed", out_a
, a
, op
)
23 def check_global(dut
, o
, op
):
25 assert_op("Global", out
, o
, op
)
27 def check_user(dut
, o
, op
):
29 assert_op("User Mode", out
, o
, op
)
31 def check_xwr(dut
, o
, op
):
33 assert_op("XWR", out
, o
, op
)
35 def check_asid(dut
, o
, op
):
37 assert_op("ASID", out
, o
, op
)
39 def check_pte(dut
, o
, op
):
41 assert_op("ASID", out
, o
, op
)
43 def check_valid(dut
, v
, op
):
45 assert_op("Valid", out_v
, v
, op
)
47 def check_all(dut
, d
, a
, g
, u
, xwr
, v
, asid
, pte
):
48 yield from check_dirty(dut
, d
, 0)
49 yield from check_accessed(dut
, a
, 0)
50 yield from check_global(dut
, g
, 0)
51 yield from check_user(dut
, u
, 0)
52 yield from check_xwr(dut
, xwr
, 0)
53 yield from check_asid(dut
, asid
, 0)
54 yield from check_pte(dut
, pte
, 0)
55 yield from check_valid(dut
, v
, 0)
58 # 80 bits represented. Ignore the MSB as it will be truncated
59 # ASID is bits first 4 hex values (bits 64 - 78)
61 i
= 0x7FFF0000000000000031
69 pte
= 0x0000000000000031
70 yield from set_entry(dut
, i
)
71 yield from check_all(dut
, dirty
, access
, glob
, user
, xwr
, valid
, asid
, pte
)
73 i
= 0x0FFF00000000000000FF
81 pte
= 0x00000000000000FF
82 yield from set_entry(dut
, i
)
83 yield from check_all(dut
, dirty
, access
, glob
, user
, xwr
, valid
, asid
, pte
)
85 i
= 0x0721000000001100001F
93 pte
= 0x000000001100001F
94 yield from set_entry(dut
, i
)
95 yield from check_all(dut
, dirty
, access
, glob
, user
, xwr
, valid
, asid
, pte
)
100 if __name__
== "__main__":
101 dut
= PteEntry(15, 64);
102 run_simulation(dut
, testbench(dut
), vcd_name
="Waveforms/test_pte_entry.vcd")
103 print("PteEntry Unit Test Success")