summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to '')
-rwxr-xr-xasm.rb1
-rw-r--r--hdl/top.sv12
-rw-r--r--mem/jtag_uart.hex2
-rw-r--r--mem/mem.hex27
4 files changed, 38 insertions, 4 deletions
diff --git a/asm.rb b/asm.rb
index c94ecf7..6da40fb 100755
--- a/asm.rb
+++ b/asm.rb
@@ -12,6 +12,7 @@ OPCODES = {
12 "++acc" => 0x002, 12 "++acc" => 0x002,
13 "--acc" => 0x004, 13 "--acc" => 0x004,
14 "tx" => 0x040, 14 "tx" => 0x040,
15 "rx" => 0x080,
15 "halt" => 0x000, 16 "halt" => 0x000,
16 } 17 }
17 18
diff --git a/hdl/top.sv b/hdl/top.sv
index 3cda157..8d83f35 100644
--- a/hdl/top.sv
+++ b/hdl/top.sv
@@ -118,6 +118,10 @@ always_ff @(posedge clk) begin
118 if (operand[1]) ++acc; 118 if (operand[1]) ++acc;
119 if (operand[2]) --acc; 119 if (operand[2]) --acc;
120 if (operand[6]) state = MEMORY; 120 if (operand[6]) state = MEMORY;
121 if (operand[7]) begin
122 rx_ready = 1;
123 state = MEMORY;
124 end
121 if (operand == 0) state = HALT; 125 if (operand == 0) state = HALT;
122 end 126 end
123 'h1: acc = sign_extended_operand; 127 'h1: acc = sign_extended_operand;
@@ -205,6 +209,14 @@ always_ff @(posedge clk) begin
205 tx_data = acc[7:0]; 209 tx_data = acc[7:0];
206 end 210 end
207 end 211 end
212 if (operand[7]) begin
213 if (`lag(rx_valid)) begin
214 rx_ready = 0;
215 acc = {{(DATA_BITS-8){1'b0}}, `lag(rx_data)};
216 end else begin
217 state = MEMORY;
218 end
219 end
208 end 220 end
209 'h2: begin 221 'h2: begin
210 if (`lag(mem_read_valid)) begin 222 if (`lag(mem_read_valid)) begin
diff --git a/mem/jtag_uart.hex b/mem/jtag_uart.hex
index 7b08c66..efe4169 100644
--- a/mem/jtag_uart.hex
+++ b/mem/jtag_uart.hex
@@ -1,3 +1,5 @@
1@0 1@0
2 2
348 65 6c 6c 6f 2c 20 46 50 47 41 21 0d 0a
4
300 500
diff --git a/mem/mem.hex b/mem/mem.hex
index 84caf6d..8619b48 100644
--- a/mem/mem.hex
+++ b/mem/mem.hex
@@ -9,20 +9,32 @@
9000 // fib0: j: 0 # fib[n]; clobbered by ascii printer for inner loop index 9000 // fib0: j: 0 # fib[n]; clobbered by ascii printer for inner loop index
10000 // fib1: x: 0 # fib[n+1]; clobbered by ascii printer for digit being printed 10000 // fib1: x: 0 # fib[n+1]; clobbered by ascii printer for digit being printed
11000 // fib2: 0 # fib[n+2] 11000 // fib2: 0 # fib[n+2]
12116 // start: acc= @fib # for the toy indirect jump to fib 12116 // start: acc= @echo # for the toy indirect jump to fib
13306 // store @fib0 13307 // store @x
14170 // acc= 0x70 14170 // acc= 0x70
15301 // store @i 15301 // store @i
16001 // loop: cla 16001 // loop: cla
17281 // ladd i @i 17281 // ladd i @i
18400 // ifeq 0 18400 // ifeq 0
19586 // jmp i @fib0 # toy indirect jump to fib 19587 // jmp i @x # toy indirect jump to fib
20040 // tx 20040 // tx
21003 // cla ++acc 21003 // cla ++acc
22201 // ladd @i 22201 // ladd @i
23301 // store @i 23301 // store @i
24577 // jmp loop 24577 // jmp loop
25301 // fib: store @i # zero, it is known 25080 // echo: rx
2640a // ifeq 0x0a
27504 // jmp fib
2840d // ifeq 0x0d
29502 // jmp fib
30040 // tx
31579 // jmp echo
3210d // fib: acc= 0x0d
33040 // tx
3410a // acc= 0x0a
35040 // tx
36001 // cla
37301 // store @i
26370 // store 0x70 # 0x70 is now beginning of Fibonacci sequence (0) 38370 // store 0x70 # 0x70 is now beginning of Fibonacci sequence (0)
27003 // cla ++acc 39003 // cla ++acc
28371 // store 0x71 # 0x71 is 1 40371 // store 0x71 # 0x71 is 1
@@ -101,6 +113,13 @@
10106c // l 11306c // l
102064 // d 114064 // d
103021 // ! 115021 // !
11600d // \r
10400a // \n 11700a // \n
118045 // E
119063 // c
120068 // h
12106f // o
12203a // :
123020 // ' '
105 124
106000 125000