From cffef4c5d8abcc868c18e9e81185ec9b63e45ed2 Mon Sep 17 00:00:00 2001 From: Luke Kenneth Casson Leighton Date: Wed, 17 Jun 2020 12:17:31 +0100 Subject: [PATCH] split out TestIssuer into separate module --- src/soc/simple/core.py | 126 +----------------------- src/soc/simple/issuer.py | 150 +++++++++++++++++++++++++++++ src/soc/simple/test/test_issuer.py | 2 +- 3 files changed, 152 insertions(+), 126 deletions(-) create mode 100644 src/soc/simple/issuer.py diff --git a/src/soc/simple/core.py b/src/soc/simple/core.py index cb234628..837e1d06 100644 --- a/src/soc/simple/core.py +++ b/src/soc/simple/core.py @@ -31,8 +31,6 @@ from soc.decoder.power_decoder import create_pdecode from soc.decoder.power_decoder2 import PowerDecode2 from soc.decoder.decode2execute1 import Data from soc.experiment.l0_cache import TstL0CacheBuffer # test only -from soc.experiment.testmem import TestMemory # test only for instructions -from soc.regfile.regfiles import FastRegs import operator @@ -41,6 +39,7 @@ import operator def ortreereduce(tree, attr="data_o"): return treereduce(tree, operator.or_, lambda x: getattr(x, attr)) + # helper function to place full regs declarations first def sort_fuspecs(fuspecs): res = [] @@ -310,131 +309,8 @@ class NonProductionCore(Elaboratable): return list(self) -class TestIssuer(Elaboratable): - """TestIssuer - reads instructions from TestMemory and issues them - - efficiency and speed is not the main goal here: functional correctness is. - """ - def __init__(self, addrwid=6, idepth=6): - # main instruction core - self.core = core = NonProductionCore(addrwid) - - # Test Instruction memory - self.imem = TestMemory(32, idepth) - self.i_rd = self.imem.rdport - #self.i_wr = self.imem.write_port() errr... - - # instruction go/monitor - self.go_insn_i = Signal(reset_less=True) - self.pc_o = Signal(64, reset_less=True) - self.pc_i = Data(64, "pc") # set "ok" to indicate "please change me" - self.busy_o = core.busy_o - self.memerr_o = Signal(reset_less=True) - - # FAST regfile read /write ports - self.fast_rd1 = self.core.regs.rf['fast'].r_ports['d_rd1'] - self.fast_wr1 = self.core.regs.rf['fast'].w_ports['d_wr1'] - - def elaborate(self, platform): - m = Module() - comb, sync = m.d.comb, m.d.sync - - m.submodules.core = core = self.core - m.submodules.imem = imem = self.imem - - # temporary hack: says "go" immediately for both address gen and ST - l0 = core.l0 - ldst = core.fus.fus['ldst0'] - m.d.comb += ldst.ad.go.eq(ldst.ad.rel) # link addr-go direct to rel - m.d.comb += ldst.st.go.eq(ldst.st.rel) # link store-go direct to rel - - # PC and instruction from I-Memory - current_insn = Signal(32) # current fetched instruction (note sync) - current_pc = Signal(64) # current PC (note it is reset/sync) - comb += self.pc_o.eq(current_pc) - ilatch = Signal(32) - - # next instruction (+4 on current) - nia = Signal(64, reset_less=True) - comb += nia.eq(current_pc + 4) - - # temporaries - core_busy_o = core.busy_o # core is busy - core_ivalid_i = core.ivalid_i # instruction is valid - core_issue_i = core.issue_i # instruction is issued - core_be_i = core.bigendian_i # bigendian mode - core_opcode_i = core.raw_opcode_i # raw opcode - - # actually use a nmigen FSM for the first time (w00t) - with m.FSM() as fsm: - - # waiting (zzz) - with m.State("IDLE"): - with m.If(self.go_insn_i): - # instruction allowed to go: start by reading the PC - pc = Signal(64, reset_less=True) - with m.If(self.pc_i.ok): - # incoming override (start from pc_i) - comb += pc.eq(self.pc_i.data) - with m.Else(): - # otherwise read FastRegs regfile for PC - comb += self.fast_rd1.ren.eq(1<