summaryrefslogtreecommitdiff
path: root/hdl/core.sv
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--hdl/core.sv27
1 files changed, 25 insertions, 2 deletions
diff --git a/hdl/core.sv b/hdl/core.sv
index 02ff231..7edf523 100644
--- a/hdl/core.sv
+++ b/hdl/core.sv
@@ -67,6 +67,9 @@ bit [8:0] operand;
67bit [DATA_BITS-1:0] acc; 67bit [DATA_BITS-1:0] acc;
68bit link; 68bit link;
69 69
70bit kbd_valid;
71bit [DATA_BITS-1:0] kbd_data;
72
70bit i; 73bit i;
71bit z; 74bit z;
72bit [6:0] wip; 75bit [6:0] wip;
@@ -93,9 +96,14 @@ always_ff @(posedge clk) begin
93 pc = 'o200; 96 pc = 'o200;
94 acc = 0; 97 acc = 0;
95 link = 0; 98 link = 0;
99 kbd_valid = 0;
96 state = state.first; 100 state = state.first;
97 end else begin 101 end else begin
98 if (`lag(tx_ready)) tx_valid = 0; 102 if (`lag(tx_ready)) tx_valid = 0;
103 if (rx_ready && `lag(rx_valid)) begin
104 kbd_valid = 1;
105 kbd_data = {4'b0, 1'b1, `lag(rx_data[6:0])};
106 end
99 107
100 case (state) 108 case (state)
101 FETCH: begin 109 FETCH: begin
@@ -115,7 +123,7 @@ always_ff @(posedge clk) begin
115 if (`lag(mem_read_valid)) begin 123 if (`lag(mem_read_valid)) begin
116 state = FETCH; 124 state = FETCH;
117 {opcode, operand} = `lag(mem_read_data); 125 {opcode, operand} = `lag(mem_read_data);
118 $display("%d decode %x: %b %b", $time, pc-1, opcode, operand); 126 //$display("%d decode %x: %b %b", $time, pc-1, opcode, operand);
119 {i, z, wip} = operand; 127 {i, z, wip} = operand;
120 if (z) 128 if (z)
121 address = {page, wip}; 129 address = {page, wip};
@@ -191,6 +199,19 @@ always_ff @(posedge clk) begin
191 end 199 end
192 'b110: begin 200 'b110: begin
193 case (operand[8:3]) 201 case (operand[8:3])
202 'b000011: begin
203 case (operand[2:0])
204 'b001: if (kbd_valid) pc++;
205 'b110: begin
206 acc = kbd_data;
207 kbd_valid = 0;
208 end
209 default: begin
210 $display("unsupported keyboard op %b", operand[2:0]);
211 $finish;
212 end
213 endcase
214 end
194 'b000100: begin 215 'b000100: begin
195 case (operand[2:0]) 216 case (operand[2:0])
196 'b001: if (!tx_valid) pc++; 217 'b001: if (!tx_valid) pc++;
@@ -199,7 +220,7 @@ always_ff @(posedge clk) begin
199 tx_data = {1'b0, acc[6:0]}; 220 tx_data = {1'b0, acc[6:0]};
200 end 221 end
201 default: begin 222 default: begin
202 $display("unsupported device op %b", operand[2:0]); 223 $display("unsupported tty op %b", operand[2:0]);
203 $finish; 224 $finish;
204 end 225 end
205 endcase 226 endcase
@@ -320,6 +341,8 @@ always_ff @(posedge clk) begin
320 $finish; 341 $finish;
321 end 342 end
322 endcase 343 endcase
344
345 rx_ready = !kbd_valid;
323 end 346 end
324end 347end
325 348