self.core = core = NonProductionCore(addrwid, ifacetype=ifacetype)
# Test Instruction memory
- self.imem = TestMemory(32, idepth)
+ self.imemwid = 64
+ self.imem = TestMemory(self.imemwid, idepth)
self.i_rd = self.imem.rdport
- #self.i_wr = self.imem.write_port() errr...
+ # one-row cache of instruction read
+ self.iline = Signal(64) # one instruction line
+ self.iprev_adr = Signal(64) # previous address: if different, do read
# instruction go/monitor
self.go_insn_i = Signal(reset_less=True)
# capture the PC and also drop it into Insn Memory
# we have joined a pair of combinatorial memory
# lookups together. this is Generally Bad.
- comb += self.i_rd.addr.eq(pc[2:]) # ignore last 2 bits
- comb += current_insn.eq(self.i_rd.data)
+ comb += self.i_rd.addr.eq(pc[3:]) # ignore last 3 bits
sync += current_pc.eq(pc)
m.next = "INSN_READ" # move to "issue" phase
# got the instruction: start issue
with m.State("INSN_READ"):
- comb += current_insn.eq(self.i_rd.data)
+ insn = self.i_rd.data.word_select(current_pc[2], 32) #
+ comb += current_insn.eq(insn)
comb += core_ivalid_i.eq(1) # say instruction is valid
comb += core_issue_i.eq(1) # and issued (ivalid_i redundant)
comb += core_be_i.eq(0) # little-endian mode
print ("insn before, init mem", mem.depth, mem.width, mem)
for i in range(mem.depth):
yield mem._array[i].eq(0)
- startaddr //= 4 # assume i-mem is 32-bit wide
+ yield Settle()
+ startaddr //= 4 # instructions are 32-bit
+ mask = ((1<<64)-1)
for insn, code in instructions:
- print ("instr: %06x 0x%x %s" % (4*startaddr, insn, code))
- yield mem._array[startaddr].eq(insn)
+ msbs = (startaddr>>1) & mask
+ val = yield mem._array[msbs]
+ print ("before set", hex(startaddr), hex(msbs), hex(val))
+ 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))
startaddr += 1
+ startaddr = startaddr & mask
class TestRunner(FHDLTestCase):