From 02405eecab38bfa1d85e88d908b52a589ee53d30 Mon Sep 17 00:00:00 2001 From: Rutherther Date: Sat, 28 Oct 2023 21:25:32 +0200 Subject: [PATCH] fix: force alu operation to addition for storing memory and pc --- src/control_unit.sv | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/control_unit.sv b/src/control_unit.sv index ae4874292265f61d63aae58d0b722234d87acef4..3274f4b321c8cb026436cf826fbaced2232129e1 100755 --- a/src/control_unit.sv +++ b/src/control_unit.sv @@ -83,7 +83,12 @@ module control_unit( .reg_we(reg_we) ); - assign alu_op = conditional_jump ? alu_jump_op : alu_reg_op; + // if jump, set alu_jump_op + // if loading or storing memory or loading pc, always add + // else do the register operation + assign alu_op = conditional_jump ? alu_jump_op : + ((load_memory || memory_we || load_pc) ? 3'b000 : + alu_reg_op); assign alu_add_one = conditional_jump ? alu_jump_add_one : alu_reg_add_one; assign alu_negate = conditional_jump ? alu_jump_negate : alu_reg_negate; assign alu_signed = conditional_jump ? 0 : alu_reg_signed;