Commit c7be8418 authored by Christina Yu's avatar Christina Yu
Browse files

lab6

parent 68e3de8b
......@@ -41,9 +41,6 @@ def display():
else:
rs2imm_str = f"rs2: {rs2Val} [{int(instr.rs2b, 2)}] imm: xxxx"
#if instr.u_imm != None:
# rs2imm_str = f"rs2: xxxxxxxx [xx] i_imm: {instr.u_imm:04x}"
if instr.rd != None:
rd_str = f"rd: {RF.read(int(instr.rdb, 2))} [{instr.rd}] "
else:
......@@ -59,10 +56,6 @@ def display():
f" op: {instr.opcode} f3: {instr.funct3} f7: {instr.funct7}" + \
f" alu_fun: {alu_str}"
#f"rd: {RF.read(int(instr.rdb, 2))} [{int(instr.rdb, 2)}] " + rs1_str + rs2imm_str + \
#f" op: {int(instr.opcode, 2):x} f3: {int(instr.funct3)} f7: {int(instr.funct7)}" + \
#f" alu_fun: {alu_str}\n"
startup = True
# generate system clocks until we reach a stopping condition
# this is basically the run function from the last lab
......@@ -84,17 +77,11 @@ for t in itertools.count():
rs1Val = None
rs2Val = None
#rs1Val = lambda: RF.read(int(instr.rs1b, 2)) if RF.read(int(instr.rs1b, 2)) else 0
#rs2Val = lambda: RF.read(int(instr.rs2b, 2)) if RF.read(int(instr.rs2b, 2)) else 0
if instr.rs1 != None:
rs1Val = RF.read(int(instr.rs1b, 2))
if instr.rs2 != None:
rs2Val = RF.read(int(instr.rs2b, 2))
#if instr.name == "li":
# instr.name = "addi"
iType = lambda: twos_comp(int(instr.binVal[0:12], 2), 12)
sType = lambda: twos_comp(int(instr.binVal[0:7] + instr.binVal[20:25], 2), 12)
uType = lambda: twos_comp(int(instr.binVal[0:20], 2), 20) << 12
......@@ -125,14 +112,12 @@ for t in itertools.count():
wdMux = lambda x: [pc_val + 4, aluVal, rData][x]
wd = wdMux(wb_sel)
#print(wb_sel)
# writeback
rd = int(instr.binVal[20:25], 2)
RF.clock(rd, wd, rf_wen)
# print one line at the end of the clock cycle
#print(f"{t}:", display())
print(f"{t:20d}:", display())
RF.display()
if instr.name == 'ecall':
......@@ -158,7 +143,6 @@ for t in itertools.count():
# clock logic blocks, PC is the only clocked module!
# here the next pc value is always +4
#PC.clock(4 + pc_val)
takeBranch = False
if instr.name == "beq":
takeBranch = (rs1Val == rs2Val)
......
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