summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulian Blake Kongslie2021-05-09 13:53:41 -0700
committerJulian Blake Kongslie2021-05-09 13:53:41 -0700
commitd677fc5de0568924b39eecae11a24f40566860b9 (patch)
tree83b2d9a3064ff1536acca05bb88601fa7194e7cd
parentDelete no-longer-used hex file for pre-PDP-8 ISA. (diff)
downloadnoncpu-d677fc5de0568924b39eecae11a24f40566860b9.tar.xz
Keyboard input.
-rw-r--r--hdl/core.sv27
-rw-r--r--mem/hello.pal13
2 files changed, 35 insertions, 5 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
diff --git a/mem/hello.pal b/mem/hello.pal
index 437ccf9..989eff8 100644
--- a/mem/hello.pal
+++ b/mem/hello.pal
@@ -4,14 +4,19 @@ START, CLA CLL
4 DCA 10 4 DCA 10
5LOOP, TAD I 10 5LOOP, TAD I 10
6 SNA 6 SNA
7 JMP EXIT 7 JMP ECHO
8 TLS 8 TLS
9 TSF 9 TSF
10 JMP .-1 10 JMP .-1
11 CLA 11 CLA
12 JMP LOOP 12 JMP LOOP
13EXIT, HLT 13ECHO, KSF
14 JMP START 14 JMP .-1
15 KRB
16 TLS
17 TSF
18 JMP .-1
19 JMP ECHO
15HELLO, . 20HELLO, .
16 "H 21 "H
17 "e 22 "e
@@ -26,5 +31,7 @@ HELLO, .
26 "l 31 "l
27 "d 32 "d
28 "! 33 "!
34 15
35 12
29 0 36 0
30$ 37$