summaryrefslogtreecommitdiff
path: root/eater_cpu
diff options
context:
space:
mode:
Diffstat (limited to 'eater_cpu')
-rw-r--r--eater_cpu/cpp/Veater_computer__main.cpp2
-rw-r--r--eater_cpu/eater_decoder.sv8
-rw-r--r--eater_cpu/eater_types.sv4
-rw-r--r--eater_cpu/readme.txt1
4 files changed, 15 insertions, 0 deletions
diff --git a/eater_cpu/cpp/Veater_computer__main.cpp b/eater_cpu/cpp/Veater_computer__main.cpp
index fbfc978..4de8454 100644
--- a/eater_cpu/cpp/Veater_computer__main.cpp
+++ b/eater_cpu/cpp/Veater_computer__main.cpp
@@ -29,6 +29,8 @@ void load_program(const std::unique_ptr<Veater_computer> &topp) {
// OUT
0xe0,
+ // LDI 4
+ 0x54,
// NOP
0x00,
// HALT
diff --git a/eater_cpu/eater_decoder.sv b/eater_cpu/eater_decoder.sv
index fea00e0..20e3e0b 100644
--- a/eater_cpu/eater_decoder.sv
+++ b/eater_cpu/eater_decoder.sv
@@ -30,6 +30,7 @@ function CpuState insdep_state;
ADD: insdep_state = ADD_INS_to_MAR;
SUB: insdep_state = SUB_INS_to_MAR;
STA: insdep_state = STA_INS_to_MAR;
+ LDI: insdep_state = LDI_INS_to_A;
OUT: insdep_state = OUT_A_to_OUT;
HALT_op: insdep_state = HALT_st;
@@ -65,6 +66,8 @@ always @(posedge clk_i) begin
STA_INS_to_MAR: next_state = STA_A_to_MEM;
STA_A_to_MEM: next_state = PC_to_MAR;
+ LDI_INS_to_A: next_state = PC_to_MAR;
+
OUT_A_to_OUT: next_state = PC_to_MAR;
HALT_st: next_state = HALT_st;
@@ -153,6 +156,11 @@ always_comb begin
internal_flags.A_out = 1;
end
+ LDI_INS_to_A: begin
+ internal_flags.INS_out = 1;
+ internal_flags.A_in = 1;
+ 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 6f69b4b..43e3a0d 100644
--- a/eater_cpu/eater_types.sv
+++ b/eater_cpu/eater_types.sv
@@ -44,6 +44,9 @@ typedef enum logic[7:0] {
// STA: b) A -> MEM
STA_A_to_MEM,
+ // LDI: a) LSB of INStruction into A
+ LDI_INS_to_A,
+
// OUT: A -> OUT
OUT_A_to_OUT,
@@ -57,6 +60,7 @@ typedef enum logic[3:0] {
ADD = 'b0010,
SUB = 'b0011,
STA = 'b0100,
+ LDI = 'b0101,
OUT = 'b1110,
HALT_op = 'b1111
} eater_instruction;
diff --git a/eater_cpu/readme.txt b/eater_cpu/readme.txt
index 402f0bb..57c65ef 100644
--- a/eater_cpu/readme.txt
+++ b/eater_cpu/readme.txt
@@ -33,6 +33,7 @@ LDA <memaddress> 0b_0001_<memaddress> Load memory > A
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
OUT ____________ 0b_1110_xxxx Output A -> OUT
HLT ____________ 0b_1111_xxxx Sets halt flag
---