RecordObject.__init__(self, name=name)
+ # current "state" (TODO: this in its own Record)
+ self.msr = Signal(64, reset_less=True)
+ self.cia = Signal(64, reset_less=True)
+
+ # instruction, type and decoded information
+ self.insn = Signal(32, reset_less=True) # original instruction
self.insn_type = Signal(MicrOp, reset_less=True)
self.fn_unit = Signal(Function, reset_less=True)
self.imm_data = Data(64, name="imm")
-
self.lk = Signal(reset_less=True)
self.rc = Data(1, "rc")
self.oe = Data(1, "oe")
self.invert_out = Signal(reset_less=True)
self.is_32bit = Signal(reset_less=True)
self.is_signed = Signal(reset_less=True)
- self.insn = Signal(32, reset_less=True)
self.data_len = Signal(4, reset_less=True) # bytes
self.byte_reverse = Signal(reset_less=True)
self.sign_extend = Signal(reset_less=True)# do we need this?
self.e = Decode2ToExecute1Type()
self.valid = Signal() # sync signal
- # state information needed by the Decoder
+ # state information needed by the Decoder (TODO: this as a Record)
self.msr = Signal(64, reset_less=True) # copy of MSR
+ self.cia = Signal(64, reset_less=True) # copy of Program Counter
def ports(self):
return self.dec.ports() + self.e.ports()
def elaborate(self, platform):
m = Module()
comb = m.d.comb
- e, op, do, msr = self.e, self.dec.op, self.e.do, self.msr
+ e, op, do, msr, cia = self.e, self.dec.op, self.e.do, self.msr, self.cia
# set up submodule decoders
m.submodules.dec = self.dec
comb += dec_cr_out.sel_in.eq(op.cr_out)
comb += dec_cr_out.rc_in.eq(dec_rc.rc_out.data)
+ # copy "state" over
+ comb += do.msr.eq(self.msr)
+ comb += do.cia.eq(self.cia)
+
# set up instruction, pick fn unit
comb += do.insn_type.eq(op.internal_op) # no op: defaults to OP_ILLEGAL
comb += do.fn_unit.eq(op.function_unit)
insn_type = core.pdecode2.e.do.insn_type
insn_msr = core.pdecode2.msr
+ insn_cia = core.pdecode2.cia
# only run if not in halted state
with m.If(~core.core_terminated_o):
comb += core_opcode_i.eq(current_insn) # actual opcode
sync += ilatch.eq(current_insn) # latch current insn
- # read MSR
+ # read MSR, latch it, and put it in decode "state"
comb += self.fast_r_msr.ren.eq(1<<FastRegs.MSR)
comb += msr.eq(self.fast_r_msr.data_o)
comb += insn_msr.eq(msr)
sync += cur_msr.eq(msr) # latch current MSR
+ # also drop PC into decode "state"
+ comb += insn_cia.eq(cur_pc)
+
m.next = "INSN_ACTIVE" # move to "wait completion"
# instruction started: must wait till it finishes
comb += core_ivalid_i.eq(1) # instruction is valid
comb += core_opcode_i.eq(ilatch) # actual opcode
comb += insn_msr.eq(cur_msr) # and MSR
+ comb += insn_cia.eq(cur_pc) # and PC
with m.If(self.fast_nia.wen):
sync += pc_changed.eq(1)
with m.If(~core_busy_o): # instruction done!