[libre-riscv-dev] [Bug 305] Create Pipelined ALU similar to alu_hier.py
bugzilla-daemon at libre-soc.org
bugzilla-daemon at libre-soc.org
Mon May 11 17:03:25 BST 2020
https://bugs.libre-soc.org/show_bug.cgi?id=305
--- Comment #40 from Luke Kenneth Casson Leighton <lkcl at lkcl.net> ---
(In reply to Michael Nolan from comment #38)
> Ugh. I added support to the alu testbench for reading the registers
> specified in the instruction, instead of hardcoding them to 1, 2, and 3. I
> have it read the register select ports in the decoder in the order [3, 1,
> 2], and the first 2 with valid data end up in the a and b inputs of the ALU.
> I'm a bit annoyed about the weird order, but everything seems to work
hmmm hmmm hang on hang on - this is removing the order. if there's 3 regs,
then 3 regs are needed.
what's needed is like this:
inputs = []
reg3_ok = yield dec2.e.read_reg3.ok
reg3_sel = 0
if reg3_ok:
reg3_sel = yield dec2.e.read_reg3.data
reg3_sel = (sim.gpr(reg3_sel).value
inputs.append(reg3_sel, reg3_ok)
...
...
followed by:
yield alu.p.data_i.a.eq(input[0][0]) # RA
yield alu.p.data_i.b.eq(input[1][0]) # RB
yield alu.p.data_i.c.eq(input[2][0]) # RC
def set_alu_inputs(alu, dec2, sim):
inputs = []
reg3_ok = yield dec2.e.read_reg3.ok
if reg3_ok:
reg3_sel = yield dec2.e.read_reg3.data
inputs.append(sim.gpr(reg3_sel).value)
reg1_ok = yield dec2.e.read_reg1.ok
if reg1_ok:
reg1_sel = yield dec2.e.read_reg1.data
inputs.append(sim.gpr(reg1_sel).value)
reg2_ok = yield dec2.e.read_reg2.ok
if reg2_ok:
reg2_sel = yield dec2.e.read_reg2.data
inputs.append(sim.gpr(reg2_sel).value)
print(inputs)
if len(inputs) == 0:
yield alu.p.data_i.a.eq(0)
yield alu.p.data_i.b.eq(0)
if len(inputs) == 1:
yield alu.p.data_i.a.eq(inputs[0])
yield alu.p.data_i.b.eq(0)
if len(inputs) == 2:
yield alu.p.data_i.a.eq(inputs[0])
yield alu.p.data_i.b.eq(inputs[1])
--
You are receiving this mail because:
You are on the CC list for the bug.
More information about the libre-riscv-dev
mailing list