From 1f0fc1edcea04e5c1f04803f0bdda337c2245f09 Mon Sep 17 00:00:00 2001 From: uvok Date: Mon, 19 Jan 2026 19:43:58 +0100 Subject: eater: Combine counting in prev. state save 1 cycle, as explained in video. also, only print lo->hi clk states to term. --- eater_cpu/cpp/Veater_computer__main.cpp | 2 +- eater_cpu/cpp/simpc_term.cpp | 3 +++ eater_cpu/eater_decoder.sv | 10 +++------- eater_cpu/eater_types.sv | 3 +-- eater_cpu/readme.txt | 6 ++---- 5 files changed, 10 insertions(+), 14 deletions(-) (limited to 'eater_cpu') diff --git a/eater_cpu/cpp/Veater_computer__main.cpp b/eater_cpu/cpp/Veater_computer__main.cpp index 425fa4e..315d52a 100644 --- a/eater_cpu/cpp/Veater_computer__main.cpp +++ b/eater_cpu/cpp/Veater_computer__main.cpp @@ -65,7 +65,7 @@ int main(int argc, char **argv, char **) { topp->clk_in = !topp->clk_in; - if (topp->eater_computer->PC_out == 3 && + if (topp->eater_computer->PC_out == 4 && topp->eater_computer->decoder__DOT__internal_state == 0x01) break; } diff --git a/eater_cpu/cpp/simpc_term.cpp b/eater_cpu/cpp/simpc_term.cpp index 8ddf83d..540cc98 100644 --- a/eater_cpu/cpp/simpc_term.cpp +++ b/eater_cpu/cpp/simpc_term.cpp @@ -36,6 +36,9 @@ bool paused = false; static void handle_key(); void simpc_ui_write(const std::unique_ptr &topp, uint64_t i) { + // clk hi->lo doesn't do anything, just skip this. + if (i !=0 && !topp->clk_in) + return; // uint16_t opcode = topp->eater_computer->; uint8_t opcode = topp->eater_computer->INS->r_datastore; // topp->halt diff --git a/eater_cpu/eater_decoder.sv b/eater_cpu/eater_decoder.sv index d2ea9cc..78d4e6c 100644 --- a/eater_cpu/eater_decoder.sv +++ b/eater_cpu/eater_decoder.sv @@ -41,11 +41,9 @@ always @(posedge clk_i) begin INIT: next_state = PC_to_MAR; - PC_to_MAR: next_state = MEM_to_INS; + PC_to_MAR: next_state = MEM_to_INS_and_PC_inc; - MEM_to_INS: next_state = PC_inc; - - PC_inc: next_state = insdep_state(); + MEM_to_INS_and_PC_inc: next_state = insdep_state(); LDA_INS_to_MAR: next_state = LDA_MEM_to_A; LDA_MEM_to_A: next_state = PC_to_MAR; @@ -81,11 +79,9 @@ always_comb begin internal_flags.PC_out = 1; internal_flags.MAR_in = 1; end - MEM_to_INS: begin + MEM_to_INS_and_PC_inc: begin internal_flags.RAM_out = 1; internal_flags.INS_in = 1; - end - PC_inc: begin internal_flags.PC_count = 1; end diff --git a/eater_cpu/eater_types.sv b/eater_cpu/eater_types.sv index 6be4d9d..6061a03 100644 --- a/eater_cpu/eater_types.sv +++ b/eater_cpu/eater_types.sv @@ -8,8 +8,7 @@ typedef enum logic[7:0] { // "regular" states INIT, PC_to_MAR, - MEM_to_INS, - PC_inc, + MEM_to_INS_and_PC_inc, // instruction dependent states diff --git a/eater_cpu/readme.txt b/eater_cpu/readme.txt index f92fdd7..9ff0090 100644 --- a/eater_cpu/readme.txt +++ b/eater_cpu/readme.txt @@ -40,10 +40,8 @@ operation Increment PC. a) PC out -> MAR (PC_to_bus) + (bus_to_MAR) + (clk) - b) MEM -> INS - (RAM_to_bus) + (bus_to_INS) + (clk) - c) PC++ - (PC_count_en) + (clk) + b) MEM -> INS, PC++ + (RAM_to_bus) + (bus_to_INS) + (PC_count_en) + (clk) 2. Decode and execute instruction. -- cgit v1.2.3