self.write_cr = Data(3, name="cr_out")
# decode operand data
+ print ("decode2execute init", name, opkls)
self.do = opkls(name)
# sigh reconstruct the assembly instruction name
ov_en = yield self.dec2.e.do.oe.oe
ov_ok = yield self.dec2.e.do.oe.ok
- rc_en = yield self.dec2.e.do.rc.data
+ rc_en = yield self.dec2.e.do.rc.rc
rc_ok = yield self.dec2.e.do.rc.ok
# grrrr have to special-case MUL op (see DecodeOE)
print("ov %d en %d rc %d en %d op %d" % \
if not asmop.endswith("."): # don't add "." to "andis."
if rc_en & rc_ok:
asmop += "."
- lk = yield self.dec2.e.do.lk
- if lk:
- asmop += "l"
+ if hasattr(self.dec2.e.do, "lk"):
+ lk = yield self.dec2.e.do.lk
+ if lk:
+ asmop += "l"
print("int_op", int_op)
if int_op in [MicrOp.OP_B.value, MicrOp.OP_BC.value]:
AA = yield self.dec2.dec.fields.FormI.AA[0:-1]
if ov_en & ov_ok:
yield from self.handle_overflow(inputs, results, overflow)
- rc_en = yield self.dec2.e.do.rc.data
+ rc_en = yield self.dec2.e.do.rc.rc
if rc_en:
self.handle_comparison(results)
"""
- def __init__(self, dec, fn_unit=None):
+ def __init__(self, dec, opkls=None, fn_name=None, col_subset=None):
if dec is None:
- self.opkls = fn_unit.opsubsetkls
- self.fn_name = fn_unit.fnunit.name
+ self.opkls = opkls
+ self.fn_name = fn_name
self.dec = create_pdecode(name=fn_name, col_subset=col_subset,
row_subset=self.rowsubsetfn)
else:
# state information needed by the Decoder (TODO: this as a Record)
self.state = CoreState("dec2")
- def rowsubsetfn(opcode, row):
+ def rowsubsetfn(self, opcode, row):
return row['unit'] == self.fn_name
def ports(self):
comb += dec_c.sel_in.eq(op.in3_sel)
comb += dec_o.sel_in.eq(op.out_sel)
comb += dec_o2.sel_in.eq(op.out_sel)
- comb += dec_o2.lk.eq(do.lk)
+ if hasattr(do, "lk"):
+ comb += dec_o2.lk.eq(do.lk)
# registers a, b, c and out and out2 (LD/ST EA)
comb += e.read_reg1.eq(dec_a.reg_out)
with m.If(op.internal_op == MicrOp.OP_TRAP):
# *DO NOT* call self.trap here. that would reset absolutely
# rverything including destroying read of RA and RB.
- comb += do.trapaddr.eq(0x70) # addr=0x700 (strip first nibble)
+ comb += self.do_copy("trapaddr", 0x70, True) # strip first nibble
# check if instruction is privileged
is_priv_insn = instr_is_priv(m, op.internal_op, e.do.insn)
if hasattr(op, "imm_data"):
# select immediate if opcode says so. however also change the latch
# to trigger *from* the opcode latch instead.
- op_is_imm = op.imm_data.imm_ok
- imm = op.imm_data.imm
+ op_is_imm = op.imm_data.ok
+ imm = op.imm_data.data
self._mux_op(m, sl, op_is_imm, imm, 1)
# create a latch/register for src1/src2 (even if it is a copy of imm)
m.d.comb += src1_or_z.eq(Mux(op_is_z, 0, srl[0]))
# select either immediate or src2 if opcode says so
- op_is_imm = oper_r.imm_data.imm_ok
+ op_is_imm = oper_r.imm_data.ok
src2_or_imm = Signal(self.data_wid, reset_less=True)
- m.d.comb += src2_or_imm.eq(Mux(op_is_imm, oper_r.imm_data.imm, srl[1]))
+ m.d.comb += src2_or_imm.eq(Mux(op_is_imm, oper_r.imm_data.data, srl[1]))
# now do the ALU addr add: one cycle, and say "ready" (next cycle, too)
comb += alu_o.eq(src1_or_z + src2_or_imm) # actual EA
yield dut.src2_i.eq(src2)
yield dut.src3_i.eq(src3)
yield dut.oper_i.imm_data.imm.eq(imm)
- yield dut.oper_i.imm_data.imm_ok.eq(imm_ok)
+ yield dut.oper_i.imm_data.ok.eq(imm_ok)
yield dut.oper_i.update.eq(update)
yield dut.issue_i.eq(1)
yield
yield dut.src2_i.eq(src2)
yield dut.oper_i.zero_a.eq(zero_a)
yield dut.oper_i.imm_data.imm.eq(imm)
- yield dut.oper_i.imm_data.imm_ok.eq(imm_ok)
+ yield dut.oper_i.imm_data.ok.eq(imm_ok)
yield dut.issue_i.eq(1)
yield
yield dut.issue_i.eq(0)
yield dut.src_i[1].eq(b)
yield dut.oper_i.insn_type.eq(op)
yield dut.oper_i.invert_in.eq(inv_a)
- yield dut.oper_i.imm_data.imm.eq(imm)
- yield dut.oper_i.imm_data.imm_ok.eq(imm_ok)
+ yield dut.oper_i.imm_data.data.eq(imm)
+ yield dut.oper_i.imm_data.ok.eq(imm_ok)
yield dut.oper_i.zero_a.eq(zero_a)
yield dut.issue_i.eq(1)
yield
# at the same time, present the operation
yield self.dut.oper_i.insn_type.eq(self.op)
yield self.dut.oper_i.invert_in.eq(self.inv_a)
- yield self.dut.oper_i.imm_data.imm.eq(self.imm)
- yield self.dut.oper_i.imm_data.imm_ok.eq(self.imm_ok)
+ yield self.dut.oper_i.imm_data.data.eq(self.imm)
+ yield self.dut.oper_i.imm_data.ok.eq(self.imm_ok)
yield self.dut.oper_i.zero_a.eq(self.zero_a)
rdmaskn = self.rdmaskn[0] | (self.rdmaskn[1] << 1)
yield self.dut.rdmaskn.eq(rdmaskn)
# TODO: deactivate rdmaskn when the busy_o cycle ends
yield self.dut.oper_i.insn_type.eq(0)
yield self.dut.oper_i.invert_in.eq(0)
- yield self.dut.oper_i.imm_data.imm.eq(0)
- yield self.dut.oper_i.imm_data.imm_ok.eq(0)
+ yield self.dut.oper_i.imm_data.data.eq(0)
+ yield self.dut.oper_i.imm_data.ok.eq(0)
yield self.dut.oper_i.zero_a.eq(0)
yield
def __init__(self, name=None):
layout = (('insn_type', MicrOp),
('fn_unit', Function),
- ('imm_data', Layout((("imm", 64), ("imm_ok", 1)))),
- ('rc', Layout((("rc", 1), ("rc_ok", 1)))), # Data
- ('oe', Layout((("oe", 1), ("oe_ok", 1)))), # Data
+ ('imm_data', Layout((("data", 64), ("ok", 1)))),
+ ('rc', Layout((("rc", 1), ("ok", 1)))), # Data
+ ('oe', Layout((("oe", 1), ("ok", 1)))), # Data
('invert_in', 1),
('zero_a', 1),
('invert_out', 1),
# are actually required (oe enabled/set) otherwise the CompALU
# can (will) ignore them.
oe = Signal(reset_less=True)
- comb += oe.eq(op.oe.oe & op.oe.oe_ok)
+ comb += oe.eq(op.oe.oe & op.oe.ok)
with m.If(oe):
# XXX see https://bugs.libre-soc.org/show_bug.cgi?id=319#c5
comb += xer_so_o.data.eq(xer_so_i[0] | xer_ov_i[0]) # SO
comb = m.d.comb
instruction = Signal(32)
- pdecode = create_pdecode()
+ fn_name = "ALU"
+ opkls = ALUPipeSpec.opsubsetkls
- m.submodules.pdecode2 = pdecode2 = PowerDecode2(pdecode)
+ m.submodules.pdecode2 = pdecode2 = PowerDecode2(None, opkls, fn_name)
+ pdecode = pdecode2.dec
pspec = ALUPipeSpec(id_wid=2)
m.submodules.alu = alu = ALUBasePipe(pspec)
def check_alu_outputs(self, alu, dec2, sim, code):
- rc = yield dec2.e.do.rc.data
+ rc = yield dec2.e.do.rc.rc
cridx_ok = yield dec2.e.write_cr.ok
cridx = yield dec2.e.write_cr.data
('insn_type', MicrOp),
('fn_unit', Function),
('insn', 32),
- ('imm_data', Layout((("imm", 64), ("imm_ok", 1)))),
+ ('imm_data', Layout((("data", 64), ("ok", 1)))),
('lk', 1),
('is_32bit', 1),
)
xer_so_o = self.o.xer_so.data[0]
so = Signal(reset_less=True)
oe = Signal(reset_less=True)
- comb += oe.eq(op.oe.oe & op.oe.oe_ok)
+ comb += oe.eq(op.oe.oe & op.oe.ok)
with m.If(oe):
comb += so.eq(xer_so_o)
with m.Else():
"""
def __init__(self, name=None):
layout = (('insn_type', MicrOp),
- ('imm_data', Layout((("imm", 64), ("imm_ok", 1)))),
+ ('imm_data', Layout((("data", 64), ("ok", 1)))),
('zero_a', 1),
- ('rc', Layout((("rc", 1), ("rc_ok", 1)))), # for later
- ('oe', Layout((("oe", 1), ("oe_ok", 1)))), # for later
+ ('rc', Layout((("rc", 1), ("ok", 1)))), # for later
+ ('oe', Layout((("oe", 1), ("ok", 1)))), # for later
('is_32bit', 1),
('is_signed', 1),
('data_len', 4),
def __init__(self, name=None):
layout = (('insn_type', MicrOp),
('fn_unit', Function),
- ('imm_data', Layout((("imm", 64), ("imm_ok", 1)))),
- ('rc', Layout((("rc", 1), ("rc_ok", 1)))),
- ('oe', Layout((("oe", 1), ("oe_ok", 1)))),
+ ('imm_data', Layout((("data", 64), ("ok", 1)))),
+ ('rc', Layout((("rc", 1), ("ok", 1)))),
+ ('oe', Layout((("oe", 1), ("ok", 1)))),
('invert_in', 1),
('zero_a', 1),
('input_carry', CryIn),
def __init__(self, name=None):
layout = (('insn_type', MicrOp),
('fn_unit', Function),
- ('imm_data', Layout((("imm", 64), ("imm_ok", 1)))),
- ('rc', Layout((("rc", 1), ("rc_ok", 1)))), # Data
- ('oe', Layout((("oe", 1), ("oe_ok", 1)))), # Data
+ ('imm_data', Layout((("data", 64), ("ok", 1)))),
+ ('rc', Layout((("rc", 1), ("ok", 1)))), # Data
+ ('oe', Layout((("oe", 1), ("ok", 1)))), # Data
('write_cr0', 1),
('is_32bit', 1),
('is_signed', 1),
def __init__(self, name=None):
layout = (('insn_type', MicrOp),
('fn_unit', Function),
- ('imm_data', Layout((("imm", 64), ("imm_ok", 1)))),
- ('rc', Layout((("rc", 1), ("rc_ok", 1)))),
- ('oe', Layout((("oe", 1), ("oe_ok", 1)))),
+ ('imm_data', Layout((("data", 64), ("ok", 1)))),
+ ('rc', Layout((("rc", 1), ("ok", 1)))),
+ ('oe', Layout((("oe", 1), ("ok", 1)))),
('write_cr0', 1),
('input_carry', CryIn),
('output_carry', 1),
if 'rb' in inp:
yield alu.p.data_i.rb.eq(inp['rb'])
# If there's an immediate, set the B operand to that
- imm_ok = yield dec2.e.do.imm_data.imm_ok
+ imm_ok = yield dec2.e.do.imm_data.ok
if imm_ok:
- data2 = yield dec2.e.do.imm_data.imm
+ data2 = yield dec2.e.do.imm_data.data
yield alu.p.data_i.rb.eq(data2)
def set_int_rc(alu, dec2, inp):