from nmigen import Module, Signal
from nmigen.back.pysim import Simulator, Delay
from nmigen.test.utils import FHDLTestCase
-from nmigen.cli import rtlil
-import os
import unittest
from soc.decoder.power_decoder import (create_pdecode)
from soc.decoder.power_enums import (Function, InternalOp,
- In1Sel, In2Sel,In3Sel,
+ In1Sel, In2Sel, In3Sel,
OutSel, RC, LdstLen, CryIn,
single_bit_flags, Form,
get_signal_name, get_csv)
InternalOp.OP_AND: "and",
InternalOp.OP_OR: "or"}
+
class Register:
def __init__(self, num):
self.num = num
args = ["powerpc64-linux-gnu-as",
"-o",
outfile.name]
- p = subprocess.Popen(args, stdin = subprocess.PIPE)
+ p = subprocess.Popen(args, stdin=subprocess.PIPE)
p.communicate(instruction.encode('utf-8'))
assert(p.wait() == 0)
binfile.name]
subprocess.check_output(args)
binary = struct.unpack('>i', binfile.read(4))[0]
- return binary
+ return binary
def test_decoder(self):
m = Module()
pdecode = create_pdecode()
m.submodules.pdecode2 = pdecode2 = PowerDecode2(pdecode)
- dec1 = pdecode2.dec
comb += pdecode2.dec.opcode_in.eq(instruction)
sim = Simulator(m)
r2 = Register(random.randrange(32))
r3 = Register(random.randrange(32))
- instruction_str = self.generate_opcode_string(opcode, r1, r2, r3)
+ instruction_str = self.generate_opcode_string(
+ opcode, r1, r2, r3)
print("instr", instruction_str.strip())
- instruction_bin = self.get_assembled_instruction(instruction_str)
+ instruction_bin = self.get_assembled_instruction(
+ instruction_str)
print("code", hex(instruction_bin), bin(instruction_bin))
yield instruction.eq(instruction_bin)
assert(r1sel == r1.num)
assert(r3sel == r3.num)
assert(r2sel == r2.num)
-
+
sim.add_process(process)
with sim.write_vcd("gas.vcd", "gas.gtkw", traces=[pdecode2.ports()]):
sim.run()
-
-
+
if __name__ == "__main__":
unittest.main()