from collections import namedtuple
from nmigen.cli import rtlil
-from soc.config.test.test_loadstore import TestMemPspec
+from soc.config.test.test_loadstore import TestMemPspec
+import sys
+sys.setrecursionlimit(10**6)
def read_from_addr(dut, addr):
yield dut.a_pc_i.eq(addr)
return res
-def tst_lsmemtype(ifacetype):
+def tst_lsmemtype(ifacetype, sram_depth=32):
m = Module()
- pspec = TestMemPspec(ldst_ifacetype=ifacetype,
+ pspec = TestMemPspec(ldst_ifacetype=ifacetype,
imem_ifacetype=ifacetype, addr_wid=64,
mask_wid=4,
- reg_wid=32)
+ reg_wid=32,
+ imem_test_depth=sram_depth)
dut = ConfigFetchUnit(pspec).fu
vl = rtlil.convert(dut, ports=[]) # TODOdut.ports())
with open("test_fetch_%s.il" % ifacetype, "w") as f:
sim.run()
if __name__ == '__main__':
- tst_lsmemtype('test_bare_wb')
+ tst_lsmemtype('test_bare_wb', sram_depth=32768)
tst_lsmemtype('testmem')
def setup_i_memory(imem, startaddr, instructions):
mem = imem
- print ("insn before, init mem", mem.depth, mem.width, mem)
+ print ("insn before, init mem", mem.depth, mem.width, mem,
+ len(instructions))
for i in range(mem.depth):
yield mem._array[i].eq(0)
yield Settle()
startaddr //= 4 # instructions are 32-bit
mask = ((1<<64)-1)
- for insn, code in instructions:
+ for ins in instructions:
+ if isinstance(ins, tuple):
+ insn, code = ins
+ else:
+ insn, code = ins, ''
msbs = (startaddr>>1) & mask
val = yield mem._array[msbs]
- print ("before set", hex(startaddr), hex(msbs), hex(val))
+ if insn != 0:
+ print ("before set", hex(startaddr), hex(msbs), hex(val), hex(insn))
lsb = 1 if (startaddr & 1) else 0
val = (val | (insn << (lsb*32))) & mask
yield mem._array[msbs].eq(val)
yield Settle()
- print ("after set", hex(startaddr), hex(msbs), hex(val))
- print ("instr: %06x 0x%x %s %08x" % (4*startaddr, insn, code, val))
+ if insn != 0:
+ print ("after set", hex(startaddr), hex(msbs), hex(val))
+ print ("instr: %06x 0x%x %s %08x" % (4*startaddr, insn, code, val))
startaddr += 1
startaddr = startaddr & mask
unittest.main(exit=False)
suite = unittest.TestSuite()
suite.addTest(TestRunner(AttnTestCase.test_data))
- #suite.addTest(TestRunner(GeneralTestCases.test_data))
- #suite.addTest(TestRunner(LDSTTestCase.test_data))
- #suite.addTest(TestRunner(CRTestCase.test_data))
- #suite.addTest(TestRunner(ShiftRotTestCase.test_data))
- #suite.addTest(TestRunner(LogicalTestCase.test_data))
- #suite.addTest(TestRunner(ALUTestCase.test_data))
- #suite.addTest(TestRunner(BranchTestCase.test_data))
- #suite.addTest(TestRunner(SPRTestCase.test_data))
+ suite.addTest(TestRunner(GeneralTestCases.test_data))
+ suite.addTest(TestRunner(LDSTTestCase.test_data))
+ suite.addTest(TestRunner(CRTestCase.test_data))
+ suite.addTest(TestRunner(ShiftRotTestCase.test_data))
+ suite.addTest(TestRunner(LogicalTestCase.test_data))
+ suite.addTest(TestRunner(ALUTestCase.test_data))
+ suite.addTest(TestRunner(BranchTestCase.test_data))
+ suite.addTest(TestRunner(SPRTestCase.test_data))
runner = unittest.TextTestRunner()
runner.run(suite)
class Program:
def __init__(self, instructions):
- if isinstance(instructions, list):
- instructions = '\n'.join(instructions)
- self.assembly = instructions + '\n' # plus final newline
- self._assemble()
+ if isinstance(instructions, str): # filename
+ self.binfile = open(instructions, "rb")
+ self.assembly = '' # noo disassemble number fiiive
+ print ("program", self.binfile)
+ else:
+ if isinstance(instructions, list):
+ instructions = '\n'.join(instructions)
+ self.assembly = instructions + '\n' # plus final newline
+ self._assemble()
self._instructions = list(self._get_instructions())
def __enter__(self):