diff options
| author | uvok | 2026-01-22 19:53:08 +0100 |
|---|---|---|
| committer | uvok | 2026-01-22 19:53:08 +0100 |
| commit | be20c4149da8af929bbdc26f32c17bfcd0981cd9 (patch) | |
| tree | 890e7a5796a8fe1c122343e208aa1cff45c110fb /eater_cpu | |
| parent | 63ca6b95b1f06f18ade4e58ba7ba42b09eeeb5d5 (diff) | |
Implement JMP
and get rid of arbitrary run limitation.
Diffstat (limited to 'eater_cpu')
| -rw-r--r-- | eater_cpu/cpp/Veater_computer__main.cpp | 6 | ||||
| -rw-r--r-- | eater_cpu/eater_decoder.sv | 12 | ||||
| -rw-r--r-- | eater_cpu/eater_types.sv | 6 | ||||
| -rw-r--r-- | eater_cpu/readme.txt | 1 |
4 files changed, 21 insertions, 4 deletions
diff --git a/eater_cpu/cpp/Veater_computer__main.cpp b/eater_cpu/cpp/Veater_computer__main.cpp index 4de8454..b4cd413 100644 --- a/eater_cpu/cpp/Veater_computer__main.cpp +++ b/eater_cpu/cpp/Veater_computer__main.cpp @@ -33,6 +33,8 @@ void load_program(const std::unique_ptr<Veater_computer> &topp) { 0x54, // NOP 0x00, + // JMP -> @0 + 0x60, // HALT 0xf0}; std::copy(instructions.begin(), instructions.end(), @@ -84,10 +86,6 @@ int main(int argc, char **argv, char **) { contextp->timeInc(1); topp->clk_in = !topp->clk_in; - - if (topp->eater_computer->PC_out == 6 && - topp->eater_computer->decoder__DOT__internal_state == 0x01) - break; } contextp->timeInc(10); tfp->dump(contextp->time()); diff --git a/eater_cpu/eater_decoder.sv b/eater_cpu/eater_decoder.sv index 20e3e0b..f6a73e6 100644 --- a/eater_cpu/eater_decoder.sv +++ b/eater_cpu/eater_decoder.sv @@ -31,6 +31,7 @@ function CpuState insdep_state; SUB: insdep_state = SUB_INS_to_MAR; STA: insdep_state = STA_INS_to_MAR; LDI: insdep_state = LDI_INS_to_A; + JMP: insdep_state = JMP_INS_to_PC; OUT: insdep_state = OUT_A_to_OUT; HALT_op: insdep_state = HALT_st; @@ -68,6 +69,9 @@ always @(posedge clk_i) begin LDI_INS_to_A: next_state = PC_to_MAR; + JMP_INS_to_PC: next_state = JMP_NOP; + JMP_NOP: next_state = PC_to_MAR; + OUT_A_to_OUT: next_state = PC_to_MAR; HALT_st: next_state = HALT_st; @@ -161,6 +165,14 @@ always_comb begin internal_flags.A_in = 1; end + JMP_INS_to_PC: begin + internal_flags.INS_out = 1; + internal_flags.PC_in = 1; + end + + JMP_NOP: begin + end + OUT_A_to_OUT: begin internal_flags.A_out = 1; internal_flags.OUT_in = 1; diff --git a/eater_cpu/eater_types.sv b/eater_cpu/eater_types.sv index 43e3a0d..14c7736 100644 --- a/eater_cpu/eater_types.sv +++ b/eater_cpu/eater_types.sv @@ -47,6 +47,11 @@ typedef enum logic[7:0] { // LDI: a) LSB of INStruction into A LDI_INS_to_A, + // JMP: a) Put 4 LSB of INS -> PC + JMP_INS_to_PC, + // JMP: b) Needed??? Wait for value to be clocked in to be actually used + JMP_NOP, + // OUT: A -> OUT OUT_A_to_OUT, @@ -61,6 +66,7 @@ typedef enum logic[3:0] { SUB = 'b0011, STA = 'b0100, LDI = 'b0101, + JMP = 'b0110, OUT = 'b1110, HALT_op = 'b1111 } eater_instruction; diff --git a/eater_cpu/readme.txt b/eater_cpu/readme.txt index 57c65ef..e4b28cd 100644 --- a/eater_cpu/readme.txt +++ b/eater_cpu/readme.txt @@ -34,6 +34,7 @@ ADD <memaddress> 0b_0010_<memaddress> "Add memory": mem>B, A + B -> A 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 OUT ____________ 0b_1110_xxxx Output A -> OUT HLT ____________ 0b_1111_xxxx Sets halt flag --- |
