X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=src%2Fsoc%2Fexperiment%2Fscore6600.py;h=cef0c86650241c6fa3db0d9dd9a7382a0647eeb7;hb=83f98eac357043f8940984eeeaf8d29072c32cb4;hp=c98ac04a8eddcb555ccf5d353f35bb0bbcef4530;hpb=1117d7c3cd52cc73a757f3c6f62c6602551d7ad3;p=soc.git diff --git a/src/soc/experiment/score6600.py b/src/soc/experiment/score6600.py index c98ac04a..cef0c866 100644 --- a/src/soc/experiment/score6600.py +++ b/src/soc/experiment/score6600.py @@ -13,11 +13,11 @@ from soc.scoreboard.shadow import ShadowMatrix, BranchSpeculationRecord from soc.scoreboard.instruction_q import Instruction, InstructionQ from soc.scoreboard.memfu import MemFunctionUnits -from compalu import ComputationUnitNoDelay -from compldst import LDSTCompUnit -from testmem import TestMemory +from .compalu import ComputationUnitNoDelay +from .compldst import LDSTCompUnit +from .testmem import TestMemory -from alu_hier import ALU, BranchALU +from .alu_hier import ALU, BranchALU from nmutil.latch import SRLatch from nmutil.nmoperator import eq @@ -54,6 +54,7 @@ class CompUnitsBase(Elaboratable): Computation Unit" as defined by Mitch Alsup (see section 11.4.9.3) """ + def __init__(self, rwid, units, ldstmode=False): """ Inputs: @@ -89,8 +90,8 @@ class CompUnitsBase(Elaboratable): self.req_rel_o = Signal(n_units, reset_less=True) self.done_o = Signal(n_units, reset_less=True) if ldstmode: - self.ld_o = Signal(n_units, reset_less=True) # op is LD - self.st_o = Signal(n_units, reset_less=True) # op is ST + self.ld_o = Signal(n_units, reset_less=True) # op is LD + self.st_o = Signal(n_units, reset_less=True) # op is ST self.adr_rel_o = Signal(n_units, reset_less=True) self.sto_rel_o = Signal(n_units, reset_less=True) self.load_mem_o = Signal(n_units, reset_less=True) @@ -206,7 +207,7 @@ class CompUnitLDSTs(CompUnitsBase): units = [] for alu in self.alus: - aluopwid = 4 # see compldst.py for "internal" opcode + aluopwid = 4 # see compldst.py for "internal" opcode units.append(LDSTCompUnit(rwid, aluopwid, alu, mem)) CompUnitsBase.__init__(self, rwid, units, ldstmode=True) @@ -245,7 +246,7 @@ class CompUnitALUs(CompUnitsBase): units = [] for alu in alus: - aluopwid = 3 # extra bit for immediate mode + aluopwid = 3 # extra bit for immediate mode units.append(ComputationUnitNoDelay(rwid, aluopwid, alu)) CompUnitsBase.__init__(self, rwid, units) @@ -281,7 +282,7 @@ class CompUnitBR(CompUnitsBase): # Branch ALU and CU self.bgt = BranchALU(rwid) - aluopwid = 3 # extra bit for immediate mode + aluopwid = 3 # extra bit for immediate mode self.br1 = ComputationUnitNoDelay(rwid, aluopwid, self.bgt) CompUnitsBase.__init__(self, rwid, [self.br1]) @@ -303,16 +304,16 @@ class FunctionUnits(Elaboratable): self.n_regs = n_regs self.n_int_alus = n_int_alus - self.dest_i = Signal(n_regs, reset_less=True) # Dest R# in - self.src1_i = Signal(n_regs, reset_less=True) # oper1 R# in - self.src2_i = Signal(n_regs, reset_less=True) # oper2 R# in + self.dest_i = Signal(n_regs, reset_less=True) # Dest R# in + self.src1_i = Signal(n_regs, reset_less=True) # oper1 R# in + self.src2_i = Signal(n_regs, reset_less=True) # oper2 R# in self.g_int_rd_pend_o = Signal(n_regs, reset_less=True) self.g_int_wr_pend_o = Signal(n_regs, reset_less=True) - self.dest_rsel_o = Signal(n_regs, reset_less=True) # dest reg (bot) - self.src1_rsel_o = Signal(n_regs, reset_less=True) # src1 reg (bot) - self.src2_rsel_o = Signal(n_regs, reset_less=True) # src2 reg (bot) + self.dest_rsel_o = Signal(n_regs, reset_less=True) # dest reg (bot) + self.src1_rsel_o = Signal(n_regs, reset_less=True) # src1 reg (bot) + self.src2_rsel_o = Signal(n_regs, reset_less=True) # src2 reg (bot) self.readable_o = Signal(n_int_alus, reset_less=True) self.writable_o = Signal(n_int_alus, reset_less=True) @@ -346,7 +347,7 @@ class FunctionUnits(Elaboratable): comb += intfudeps.rd_pend_i.eq(intregdeps.rd_pend_o) comb += intfudeps.wr_pend_i.eq(intregdeps.wr_pend_o) - self.wr_pend_o = intregdeps.wr_pend_o # also output for use in WaWGrid + self.wr_pend_o = intregdeps.wr_pend_o # also output for use in WaWGrid comb += intfudeps.issue_i.eq(self.fn_issue_i) comb += intfudeps.go_rd_i.eq(self.go_rd_i) @@ -387,7 +388,7 @@ class Scoreboard(Elaboratable): self.fpregs = RegFileArray(rwid, n_regs) # Memory (test for now) - self.mem = TestMemory(self.rwid, 8) # not too big, takes too long + self.mem = TestMemory(self.rwid, 8) # not too big, takes too long # issue q needs to get at these self.aluissue = IssueUnitGroup(2) @@ -402,14 +403,14 @@ class Scoreboard(Elaboratable): self.ls_imm_i = Signal(rwid, reset_less=True) # inputs - self.int_dest_i = Signal(range(n_regs), reset_less=True) # Dest R# in - self.int_src1_i = Signal(range(n_regs), reset_less=True) # oper1 R# in - self.int_src2_i = Signal(range(n_regs), reset_less=True) # oper2 R# in - self.reg_enable_i = Signal(reset_less=True) # enable reg decode + self.int_dest_i = Signal(range(n_regs), reset_less=True) # Dest R# in + self.int_src1_i = Signal(range(n_regs), reset_less=True) # oper1 R# in + self.int_src2_i = Signal(range(n_regs), reset_less=True) # oper2 R# in + self.reg_enable_i = Signal(reset_less=True) # enable reg decode # outputs - self.issue_o = Signal(reset_less=True) # instruction was accepted - self.busy_o = Signal(reset_less=True) # at least one CU is busy + self.issue_o = Signal(reset_less=True) # instruction was accepted + self.busy_o = Signal(reset_less=True) # at least one CU is busy # for branch speculation experiment. branch_direction = 0 if # the branch hasn't been met yet. 1 indicates "success", 2 is "fail" @@ -440,7 +441,7 @@ class Scoreboard(Elaboratable): # Int ALUs and BR ALUs n_int_alus = 5 cua = CompUnitALUs(self.rwid, 3, n_alus=self.aluissue.n_insns) - cub = CompUnitBR(self.rwid, 3) # 1 BR ALUs + cub = CompUnitBR(self.rwid, 3) # 1 BR ALUs # LDST Comp Units n_ldsts = 2 @@ -448,7 +449,7 @@ class Scoreboard(Elaboratable): # Comp Units m.submodules.cu = cu = CompUnitsBase(self.rwid, [cua, cul, cub]) - bgt = cub.bgt # get at the branch computation unit + bgt = cub.bgt # get at the branch computation unit br1 = cub.br1 # Int FUs @@ -458,15 +459,17 @@ class Scoreboard(Elaboratable): m.submodules.memfus = memfus = MemFunctionUnits(n_ldsts, 5) # Memory Priority Picker 1: one gateway per memory port - mempick1 = GroupPicker(n_ldsts) # picks 1 reader and 1 writer to intreg + # picks 1 reader and 1 writer to intreg + mempick1 = GroupPicker(n_ldsts) m.submodules.mempick1 = mempick1 # Count of number of FUs n_intfus = n_int_alus - n_fp_fus = 0 # for now + n_fp_fus = 0 # for now # Integer Priority Picker 1: Adder + Subtractor (and LD/ST) - intpick1 = GroupPicker(n_intfus) # picks 1 reader and 1 writer to intreg + # picks 1 reader and 1 writer to intreg + intpick1 = GroupPicker(n_intfus) m.submodules.intpick1 = intpick1 # INT/FP Issue Unit @@ -489,21 +492,21 @@ class Scoreboard(Elaboratable): # allow/cancel can be issued as appropriate. m.submodules.specrec = bspec = BranchSpeculationRecord(n_intfus) - #--------- + # --------- # ok start wiring things together... # "now hear de word of de looord... dem bones dem bones dem dryy bones" # https://www.youtube.com/watch?v=pYb8Wm6-QfA - #--------- + # --------- - #--------- + # --------- # Issue Unit is where it starts. set up some in/outs for this module - #--------- - comb += [ regdecode.dest_i.eq(self.int_dest_i), - regdecode.src1_i.eq(self.int_src1_i), - regdecode.src2_i.eq(self.int_src2_i), - regdecode.enable_i.eq(self.reg_enable_i), - self.issue_o.eq(issueunit.issue_o) - ] + # --------- + comb += [regdecode.dest_i.eq(self.int_dest_i), + regdecode.src1_i.eq(self.int_src1_i), + regdecode.src2_i.eq(self.int_src2_i), + regdecode.enable_i.eq(self.reg_enable_i), + self.issue_o.eq(issueunit.issue_o) + ] # take these to outside (issue needs them) comb += cua.oper_i.eq(self.alu_oper_i) @@ -526,24 +529,24 @@ class Scoreboard(Elaboratable): comb += issueunit.busy_i.eq(cu.busy_o) comb += self.busy_o.eq(cu.busy_o.bool()) - #--------- + # --------- # Memory Function Unit - #--------- + # --------- reset_b = Signal(cul.n_units, reset_less=True) sync += reset_b.eq(cul.go_st_i | cul.go_wr_i | cul.go_die_i) - comb += memfus.fn_issue_i.eq(cul.issue_i) # Comp Unit Issue -> Mem FUs - comb += memfus.addr_en_i.eq(cul.adr_rel_o) # Match enable on adr rel - comb += memfus.addr_rs_i.eq(reset_b) # reset same as LDSTCompUnit + comb += memfus.fn_issue_i.eq(cul.issue_i) # Comp Unit Issue -> Mem FUs + comb += memfus.addr_en_i.eq(cul.adr_rel_o) # Match enable on adr rel + comb += memfus.addr_rs_i.eq(reset_b) # reset same as LDSTCompUnit # LD/STs have to accumulate prior LD/STs (TODO: multi-issue as well, # in a transitive fashion). This cycle activates based on LDSTCompUnit # issue_i. multi-issue gets a bit more complex but not a lot. prior_ldsts = Signal(cul.n_units, reset_less=True) sync += prior_ldsts.eq(memfus.g_int_ld_pend_o | memfus.g_int_st_pend_o) - with m.If(self.ls_oper_i[3]): # LD bit of operand + with m.If(self.ls_oper_i[3]): # LD bit of operand comb += memfus.ld_i.eq(cul.issue_i | prior_ldsts) - with m.If(self.ls_oper_i[2]): # ST bit of operand + with m.If(self.ls_oper_i[2]): # ST bit of operand comb += memfus.st_i.eq(cul.issue_i | prior_ldsts) # TODO: adr_rel_o needs to go into L1 Cache. for now, @@ -558,10 +561,10 @@ class Scoreboard(Elaboratable): # XXX should only be done when the memory ld/st has actually happened! go_st_i = Signal(cul.n_units, reset_less=True) go_ld_i = Signal(cul.n_units, reset_less=True) - comb += go_ld_i.eq(memfus.loadable_o & memfus.addr_nomatch_o &\ - cul.adr_rel_o & cul.ld_o) - comb += go_st_i.eq(memfus.storable_o & memfus.addr_nomatch_o &\ - cul.sto_rel_o & cul.st_o) + comb += go_ld_i.eq(memfus.loadable_o & memfus.addr_nomatch_o & + cul.adr_rel_o & cul.ld_o) + comb += go_st_i.eq(memfus.storable_o & memfus.addr_nomatch_o & + cul.sto_rel_o & cul.st_o) comb += memfus.go_ld_i.eq(go_ld_i) comb += memfus.go_st_i.eq(go_st_i) #comb += cul.go_wr_i.eq(go_ld_i) @@ -571,9 +574,9 @@ class Scoreboard(Elaboratable): #comb += cu.go_wr_i[0:n_intfus].eq(go_wr_o[0:n_intfus]) #comb += cu.issue_i[0:n_intfus].eq(fn_issue_o[0:n_intfus]) - #--------- + # --------- # merge shadow matrices outputs - #--------- + # --------- # these are explained in ShadowMatrix docstring, and are to be # connected to the FUReg and FUFU Matrices, to get them to reset @@ -584,9 +587,9 @@ class Scoreboard(Elaboratable): comb += anydie.eq(shadows.go_die_o | bshadow.go_die_o) comb += shreset.eq(bspec.match_g_o | bspec.match_f_o) - #--------- + # --------- # connect fu-fu matrix - #--------- + # --------- # Group Picker... done manually for now. go_rd_o = intpick1.go_rd_o @@ -595,12 +598,12 @@ class Scoreboard(Elaboratable): go_wr_i = intfus.go_wr_i go_die_i = intfus.go_die_i # NOTE: connect to the shadowed versions so that they can "die" (reset) - comb += go_rd_i[0:n_intfus].eq(go_rd_o[0:n_intfus]) # rd - comb += go_wr_i[0:n_intfus].eq(go_wr_o[0:n_intfus]) # wr - comb += go_die_i[0:n_intfus].eq(anydie[0:n_intfus]) # die + comb += go_rd_i[0:n_intfus].eq(go_rd_o[0:n_intfus]) # rd + comb += go_wr_i[0:n_intfus].eq(go_wr_o[0:n_intfus]) # wr + comb += go_die_i[0:n_intfus].eq(anydie[0:n_intfus]) # die # Connect Picker - #--------- + # --------- comb += intpick1.rd_rel_i[0:n_intfus].eq(cu.rd_rel_o[0:n_intfus]) comb += intpick1.req_rel_i[0:n_intfus].eq(cu.done_o[0:n_intfus]) int_rd_o = intfus.readable_o @@ -608,14 +611,14 @@ class Scoreboard(Elaboratable): comb += intpick1.readable_i[0:n_intfus].eq(int_rd_o[0:n_intfus]) comb += intpick1.writable_i[0:n_intfus].eq(int_wr_o[0:n_intfus]) - #--------- + # --------- # Shadow Matrix - #--------- + # --------- comb += shadows.issue_i.eq(fn_issue_o) #comb += shadows.reset_i[0:n_intfus].eq(bshadow.go_die_o[0:n_intfus]) comb += shadows.reset_i[0:n_intfus].eq(bshadow.go_die_o[0:n_intfus]) - #--------- + # --------- # NOTE; this setup is for the instruction order preservation... # connect shadows / go_dies to Computation Units @@ -636,7 +639,7 @@ class Scoreboard(Elaboratable): for i in range(n_intfus): comb += shadows.shadow_i[i][0:n_intfus].eq(prev_shadow) - #--------- + # --------- # ... and this is for branch speculation. it uses the extra bit # tacked onto the ShadowMatrix (hence shadow_wid=n_intfus+1) # only needs to set shadow_i, s_fail_i and s_good_i @@ -651,7 +654,7 @@ class Scoreboard(Elaboratable): with m.If(bactive & (self.branch_succ_i | self.branch_fail_i)): comb += bshadow.issue_i.eq(fn_issue_o) for i in range(n_intfus): - with m.If(fn_issue_o & (Const(1<