diff options
| -rw-r--r-- | eater_cpu/cpp/disas.h | 4 | ||||
| -rw-r--r-- | eater_cpu/eater_computer.sv | 2 | ||||
| -rw-r--r-- | eater_cpu/eater_decoder.sv | 16 | ||||
| -rw-r--r-- | eater_cpu/eater_types.sv | 5 | ||||
| -rw-r--r-- | eater_cpu/readme.txt | 2 |
5 files changed, 27 insertions, 2 deletions
diff --git a/eater_cpu/cpp/disas.h b/eater_cpu/cpp/disas.h index 3fd4670..2b7da85 100644 --- a/eater_cpu/cpp/disas.h +++ b/eater_cpu/cpp/disas.h @@ -21,6 +21,10 @@ static std::string disas(uint8_t ins) { return std::format("ldi {}", arg); case 6: return std::format("jmp {}", arg); + case 7: + return std::format("jc {}", arg); + case 8: + return std::format("jz {}", arg); case 14: return std::format("out"); case 15: diff --git a/eater_cpu/eater_computer.sv b/eater_cpu/eater_computer.sv index f476986..6b9b5e1 100644 --- a/eater_cpu/eater_computer.sv +++ b/eater_cpu/eater_computer.sv @@ -187,7 +187,7 @@ eater_decoder decoder ( .clk_i(DEC_clk_neg), .instruction_i(INS_out), .flags_o(automatic_flags), - .flags_in(ALU_flags_out) + .alu_flags_in(ALU_flags_out) ); endmodule diff --git a/eater_cpu/eater_decoder.sv b/eater_cpu/eater_decoder.sv index 53ebf78..9239e92 100644 --- a/eater_cpu/eater_decoder.sv +++ b/eater_cpu/eater_decoder.sv @@ -5,7 +5,7 @@ module eater_decoder ( input clk_i, input wire [7:0] instruction_i, - input wire AluFlags flags_in, + input wire AluFlags alu_flags_in, output CpuControlFlags flags_o ); @@ -34,6 +34,9 @@ function CpuState insdep_state; STA: insdep_state = STA_INS_to_MAR; LDI: insdep_state = LDI_INS_to_A; JMP: insdep_state = JMP_INS_to_PC; + JC_op: insdep_state = JC_st_check; + JZ_op: insdep_state = JZ_st_check; + OUT_op: insdep_state = OUT_A_to_OUT; HALT_op: insdep_state = HALT_st; @@ -75,6 +78,8 @@ always @(posedge clk_i) begin JMP_INS_to_PC: next_state = PC_to_MAR; JMP_NOP: next_state = PC_to_MAR; + JC_st_check, JZ_st_check: next_state = PC_to_MAR; + OUT_A_to_OUT: next_state = PC_to_MAR; HALT_st: next_state = HALT_st; @@ -179,6 +184,15 @@ always_comb begin internal_flags.PC_in = 1; end + JC_st_check: begin + internal_flags.INS_out = alu_flags_in.Carry; + internal_flags.PC_in = alu_flags_in.Carry; + end + JZ_st_check: begin + internal_flags.INS_out = alu_flags_in.Zero; + internal_flags.PC_in = alu_flags_in.Zero; + end + JMP_NOP: begin end diff --git a/eater_cpu/eater_types.sv b/eater_cpu/eater_types.sv index 3744df1..40e9861 100644 --- a/eater_cpu/eater_types.sv +++ b/eater_cpu/eater_types.sv @@ -54,6 +54,9 @@ typedef enum logic[7:0] { // probably not needed JMP_NOP, + JC_st_check, + JZ_st_check, + // OUT: A -> OUT OUT_A_to_OUT, @@ -69,6 +72,8 @@ typedef enum logic[3:0] { STA = 'b0100, LDI = 'b0101, JMP = 'b0110, + JC_op = 'b0111, + JZ_op = 'b1000, OUT_op = 'b1110, HALT_op = 'b1111 } eater_instruction; diff --git a/eater_cpu/readme.txt b/eater_cpu/readme.txt index 44ae2d2..debb861 100644 --- a/eater_cpu/readme.txt +++ b/eater_cpu/readme.txt @@ -35,6 +35,8 @@ SUB <memaddress> 0b_0011_<memaddress> "Sub memory": mem>B, A - B-> A STA <memaddress> 0b_0100_<memaddress> Store A -> memory LDI <value> 0b_0101_<value> Store <value> -> A JMP <address> 0b_0110_<address> <address> -> PC +JC <address> 0b_0111_<address> <address> -> PC if C=1 +JZ <address> 0b_1000_<address> <address> -> PC if Z=1 OUT ____________ 0b_1110_xxxx Output A -> OUT HLT ____________ 0b_1111_xxxx Sets halt flag --- |
