ccdeda8f9bfcfdf957aa26796d9a6967082a71ab
1 from nmigen
import Module
, Signal
, Elaboratable
2 from nmigen
.asserts
import Assert
, AnyConst
3 from nmigen
.test
.utils
import FHDLTestCase
5 from soc
.decoder
.power_decoder
import create_pdecode
, PowerOp
6 from soc
.decoder
.power_enums
import (In1Sel
, In2Sel
, In3Sel
,
8 from soc
.decoder
.power_decoder2
import (PowerDecode2
,
12 class Driver(Elaboratable
):
17 def elaborate(self
, platform
):
19 self
.comb
= self
.m
.d
.comb
20 instruction
= Signal(32)
22 self
.comb
+= instruction
.eq(AnyConst(32))
24 pdecode
= create_pdecode()
26 self
.m
.submodules
.pdecode2
= pdecode2
= PowerDecode2(pdecode
)
27 self
.comb
+= pdecode2
.dec
.opcode_in
.eq(instruction
)
29 self
.test_in1(pdecode2
, pdecode
)
33 def test_in1(self
, pdecode2
, pdecode
):
37 with m
.If(pdecode
.op
.in1_sel
== In1Sel
.RA
):
38 comb
+= Assert(pdecode2
.e
.read_reg1
.data
== ra
)
39 comb
+= Assert(pdecode2
.e
.read_reg1
.ok
== 1)
40 with m
.If(pdecode
.op
.in1_sel
== In1Sel
.RA_OR_ZERO
):
42 comb
+= Assert(pdecode2
.e
.read_reg1
.ok
== 0)
44 comb
+= Assert(pdecode2
.e
.read_reg1
.data
== ra
)
45 comb
+= Assert(pdecode2
.e
.read_reg1
.ok
== 1)
46 op
= pdecode
.op
.internal_op
47 with m
.If((op
== InternalOp
.OP_BC
) |
48 (op
== InternalOp
.OP_BCREG
)):
49 with m
.If(~pdecode
.BO
[2]):
50 comb
+= Assert(pdecode2
.e
.read_spr1
.data
== SPR
.CTR
)
51 comb
+= Assert(pdecode2
.e
.read_spr1
.ok
== 1)
52 with m
.If((op
== InternalOp
.OP_MFSPR
) |
53 (op
== InternalOp
.OP_MTSPR
)):
54 comb
+= Assert(pdecode2
.e
.read_spr1
.data
==
56 comb
+= Assert(pdecode2
.e
.read_spr1
.ok
== 1)
58 class Decoder2TestCase(FHDLTestCase
):
59 def test_decoder2(self
):
61 self
.assertFormal(module
, mode
="bmc", depth
=4)
63 if __name__
== '__main__':