+"""MMU PortInterface Test
+
+quite basic, calls pi_ld to get data via PortInterface. this test
+shouldn't really exist, it's superceded by test_ldst_pi.py
+"""
+
from nmigen import (C, Module, Signal, Elaboratable, Mux, Cat, Repl, Signal)
from nmigen.cli import main
from nmigen.cli import rtlil
# will take at least one week (10.10.2020)
# many unconnected signals
+
class TestMicrowattMemoryPortInterface(PortInterfaceBase):
"""TestMicrowattMemoryPortInterface
This is a Test Class for MMU and DCache conforming to PortInterface
"""
- def __init__(self, mmu, dcache, regwid=64, addrwid=4,):
+ def __init__(self, mmu, dcache, regwid=64, addrwid=4):
super().__init__(regwid, addrwid)
self.mmu = mmu
self.dcache = dcache
- def set_wr_addr(self, m, addr, mask, misalign):
+ def set_wr_addr(self, m, addr, mask, misalign, msr_pr):
m.d.comb += self.dcache.d_in.addr.eq(addr)
m.d.comb += self.mmu.l_in.addr.eq(addr)
m.d.comb += self.mmu.l_in.load.eq(0)
- m.d.comb += self.mmu.l_in.priv.eq(1)
+ m.d.comb += self.mmu.l_in.priv.eq(1) # TODO put msr_pr here
m.d.comb += self.mmu.l_in.valid.eq(1)
- def set_rd_addr(self, m, addr, mask, misalign):
+ def set_rd_addr(self, m, addr, mask, misalign, msr_pr):
m.d.comb += self.dcache.d_in.addr.eq(addr)
m.d.comb += self.mmu.l_in.addr.eq(addr)
m.d.comb += self.mmu.l_in.load.eq(1)
- m.d.comb += self.mmu.l_in.priv.eq(1)
+ m.d.comb += self.mmu.l_in.priv.eq(1) # TODO put msr_pr here
m.d.comb += self.mmu.l_in.valid.eq(1)
def set_wr_data(self, m, data, wen):
data = self.dcache.d_out.data
return data, ld_ok
+
# DCacheToLoadStore1Type NC
# store_done
# error
yield
addr = (yield dc.wb_out.adr) << 3
if addr not in mem:
- print (" DCACHE LOOKUP FAIL %x" % (addr))
- stop = True
- return
+ print (" WB LOOKUP NO entry @ %x, returning zero" % (addr))
- yield
- data = mem[addr]
+ data = mem.get(addr, 0)
yield dc.wb_in.dat.eq(data)
print (" DCACHE get %x data %x" % (addr, data))
yield dc.wb_in.ack.eq(1)
yield
yield dc.wb_in.ack.eq(0)
+ yield
def mmu_lookup(dut, addr):
mmu = dut.mmu
global stop
- print("pi_st")
+ print("pi_ld")
yield from pi_ld(dut.pi, addr, 1)
- print("pi_st_done")
+ print("pi_ld done")
"""
# original test code kept for reference
while not stop: # wait for dc_valid / err
stop = True
+
def test_mmu():
mmu = MMU()
dcache = DCache()
with sim.write_vcd('test_mmu_pi.vcd'):
sim.run()
+
if __name__ == '__main__':
test_mmu()