Commit dbca3b2e authored by alan's avatar alan
Browse files

fixed signs for memory ops

parent ac41ffe3
......@@ -43,7 +43,7 @@ def run_cpu(imem, dmem, symbols, debug):
# this is basically the run function from the last lab
for t in itertools.count(): # t represents clock
# sample inputs
pc_val = PC.out()
pc_val = as_twos_comp(PC.out())
# access instruction memory
instr = Instruction(imem[pc_val], pc_val)
# RESET the PC register
......@@ -109,10 +109,10 @@ def run_cpu(imem, dmem, symbols, debug):
# Data Memory Read
if mem_wr == 0 and mem_em == 1:
rdata = dmem.out(result)
rdata = dmem.out(as_twos_comp(result))
# Data Memory Write
dmem.clock(result, rs2_value, mem_wr, mem_val)
dmem.clock(as_twos_comp(result), rs2_value, mem_wr, mem_val)
if instr.instr_name == "slli":
writeback_mux = make_mux(lambda : 4 + pc_val, lambda: sextend_res, lambda: rdata, lambda: 0) # replace first None with dmem.out() and 2nd None with csr
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment