summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulian Blake Kongslie2021-11-21 13:28:55 -0800
committerJulian Blake Kongslie2021-11-21 13:28:55 -0800
commita9a3b8f7ab7f2067843a9a642447a9b7270440ce (patch)
treefc7a5ba3dd7c5c0f5d77593c18a58f7fa376f2b5
parentImplement single-stepping the core. (diff)
downloadnoncpu-a9a3b8f7ab7f2067843a9a642447a9b7270440ce.tar.xz
Implement switches Start and LoadAdd.
Diffstat (limited to '')
-rw-r--r--PLAN16
-rw-r--r--hdl/core.sv56
-rw-r--r--hdl/top.sv27
3 files changed, 84 insertions, 15 deletions
diff --git a/PLAN b/PLAN
index bdf6256..562c8ab 100644
--- a/PLAN
+++ b/PLAN
@@ -1,15 +1,15 @@
1Turn on blinkenlights from the PDP core 1Turn on blinkenlights from the PDP core
2 2
3Implement switch features: 3Implement switch features:
4 Start 4 Deposit - needs a state machine
5 Load_Add 5 [pc++] = switch_sr
6 Deposit 6 Examine - needs a state machine
7 Examine 7 led_memdata = [pc++]
8 The DF* IF* and SR* data switches
9 8
10Don't ignore 6000 and 6001 9Don't ignore 6000 and 6001
11 10
12Add "interrupts enabled" flag 11Add "interrupts enabled" flag
12 switch_start clears this
136000, 6001, 6002 should properly handle it 136000, 6001, 6002 should properly handle it
14 6000 - skip next instruction if interrupts are enabled; disable interrupts (we should probably do this immediately) 14 6000 - skip next instruction if interrupts are enabled; disable interrupts (we should probably do this immediately)
15 6001 - enable interrupts (after next instruction) 15 6001 - enable interrupts (after next instruction)
@@ -26,3 +26,9 @@ Sources of interrupts observed:
26 TTO ready for output interrupt - this looks like a very likely candidate 26 TTO ready for output interrupt - this looks like a very likely candidate
27 TTI input ready interrupt - this looks like a very likely candidate 27 TTI input ready interrupt - this looks like a very likely candidate
28 Looks like these happen even when there is no input available - might be caused by the program itself doing something a little funny 28 Looks like these happen even when there is no input available - might be caused by the program itself doing something a little funny
29
30Implement IF/DF fields
31 Will need to update behaviour of switch_load_add
32
33Add a macro for reversing polarity of switch_sing_step and switch_sing_inst and
34making switch_dep happen on key lift instead of key press
diff --git a/hdl/core.sv b/hdl/core.sv
index 43a4a1a..14660f5 100644
--- a/hdl/core.sv
+++ b/hdl/core.sv
@@ -7,6 +7,13 @@ module core
7 ( input bit clk 7 ( input bit clk
8 , input bit reset 8 , input bit reset
9 9
10 , input bit [2:0] switch_df
11 , input bit [2:0] switch_if
12 , input bit [ADDR_BITS-1:0] switch_sr
13 , input bit switch_start
14 , input bit switch_load_add
15 , input bit switch_dep
16 , input bit switch_exam
10 , input bit switch_cont 17 , input bit switch_cont
11 , input bit switch_stop 18 , input bit switch_stop
12 , input bit switch_sing_step 19 , input bit switch_sing_step
@@ -43,6 +50,10 @@ module core
43 ); 50 );
44 51
45bit run; 52bit run;
53bit switch_start_observed;
54bit switch_load_add_observed;
55bit switch_dep_observed;
56bit switch_exam_observed;
46bit switch_cont_observed; 57bit switch_cont_observed;
47assign led_run = run; 58assign led_run = run;
48 59
@@ -53,8 +64,8 @@ bit [ADDR_BITS-1:0] mem_address;
53bit [DATA_BITS-1:0] mem_write_data; 64bit [DATA_BITS-1:0] mem_write_data;
54assign led_current_address = mem_valid; 65assign led_current_address = mem_valid;
55 66
56assign led_df = 0; 67assign led_df = switch_df; // FIXME actually implement DF and IF
57assign led_if = 0; 68assign led_if = switch_if;
58assign led_memaddr = mem_address; 69assign led_memaddr = mem_address;
59 70
60bit mem_read_valid; 71bit mem_read_valid;
@@ -151,6 +162,10 @@ assign led_pause = state == MEMWAIT || state == HALT;
151always_ff @(posedge clk) begin 162always_ff @(posedge clk) begin
152 if (reset) begin 163 if (reset) begin
153 run = 0; 164 run = 0;
165 switch_start_observed = 0;
166 switch_load_add_observed = 0;
167 switch_dep_observed = 0;
168 switch_exam_observed = 0;
154 switch_cont_observed = 0; 169 switch_cont_observed = 0;
155 mem_valid = 0; 170 mem_valid = 0;
156 rx_ready = 0; 171 rx_ready = 0;
@@ -163,9 +178,44 @@ always_ff @(posedge clk) begin
163 kbd_valid = 0; 178 kbd_valid = 0;
164 state = state.first; 179 state = state.first;
165 end else begin 180 end else begin
166 if (switch_cont && !switch_cont_observed) begin 181 if (switch_start && !switch_start_observed) begin
182 switch_start_observed = 1;
167 run = 1; 183 run = 1;
184 mem_valid = 0;
185 acc = 0;
186 link = 1;
187 state = state.first;
188 end
189
190 if (!switch_start)
191 switch_start_observed = 0;
192
193 if (switch_load_add && !switch_load_add_observed) begin
194 switch_load_add_observed = 1;
195 pc = switch_sr;
196 led_pc = pc;
197 end
198
199 if (!switch_load_add)
200 switch_load_add_observed = 0;
201
202 if (switch_dep && !switch_dep_observed) begin
203 switch_dep_observed = 1;
204 end
205
206 if (!switch_dep)
207 switch_dep_observed = 0;
208
209 if (switch_exam && !switch_exam_observed) begin
210 switch_exam_observed = 1;
211 end
212
213 if (!switch_exam)
214 switch_exam_observed = 0;
215
216 if (switch_cont && !switch_cont_observed) begin
168 switch_cont_observed = 1; 217 switch_cont_observed = 1;
218 run = 1;
169 end 219 end
170 220
171 if (!switch_cont) 221 if (!switch_cont)
diff --git a/hdl/top.sv b/hdl/top.sv
index 00225ee..8ed2bc6 100644
--- a/hdl/top.sv
+++ b/hdl/top.sv
@@ -49,9 +49,9 @@ panel fp
49 , .gpioc(gpioc) 49 , .gpioc(gpioc)
50 ); 50 );
51 51
52bit [3:1] switch_df; 52bit [2:0] switch_df;
53bit [3:1] switch_if; 53bit [2:0] switch_if;
54bit [12:1] switch_sr; 54bit [11:0] switch_sr;
55bit switch_start; 55bit switch_start;
56bit switch_load_add; 56bit switch_load_add;
57bit switch_dep; 57bit switch_dep;
@@ -61,9 +61,12 @@ bit switch_stop;
61bit switch_sing_step; 61bit switch_sing_step;
62bit switch_sing_inst; 62bit switch_sing_inst;
63 63
64assign switch_df = switch[2][3:1]; 64// Note that we are reversing the order here on a number of aggregates because
65assign switch_if = switch[2][6:4]; 65// the panel model gives us LEDs and switches in schematic-order, which is the
66assign switch_sr = switch[1]; 66// opposite of the bit order
67assign switch_df = {switch[2][1], switch[2][2], switch[2][3]};
68assign switch_if = {switch[2][4], switch[2][5], switch[2][6]};
69assign switch_sr = {switch[1][1], switch[1][2], switch[1][3], switch[1][4], switch[1][5], switch[1][6], switch[1][7], switch[1][8], switch[1][9], switch[1][10], switch[1][11], switch[1][12]};
67assign switch_start = switch[3][1]; 70assign switch_start = switch[3][1];
68assign switch_load_add = switch[3][2]; 71assign switch_load_add = switch[3][2];
69assign switch_dep = switch[3][3]; 72assign switch_dep = switch[3][3];
@@ -100,6 +103,9 @@ bit [2:0] led_df;
100bit [2:0] led_if; 103bit [2:0] led_if;
101bit led_link; 104bit led_link;
102 105
106// Note that we are reversing the order here on a number of aggregates because
107// the panel model gives us LEDs and switches in schematic-order, which is the
108// opposite of the bit order
103assign led[1] = {led_pc[0], led_pc[1], led_pc[2], led_pc[3], led_pc[4], led_pc[5], led_pc[6], led_pc[7], led_pc[8], led_pc[9], led_pc[10], led_pc[11]}; 109assign led[1] = {led_pc[0], led_pc[1], led_pc[2], led_pc[3], led_pc[4], led_pc[5], led_pc[6], led_pc[7], led_pc[8], led_pc[9], led_pc[10], led_pc[11]};
104assign led[2] = {led_memaddr[0], led_memaddr[1], led_memaddr[2], led_memaddr[3], led_memaddr[4], led_memaddr[5], led_memaddr[6], led_memaddr[7], led_memaddr[8], led_memaddr[9], led_memaddr[10], led_memaddr[11]}; 110assign led[2] = {led_memaddr[0], led_memaddr[1], led_memaddr[2], led_memaddr[3], led_memaddr[4], led_memaddr[5], led_memaddr[6], led_memaddr[7], led_memaddr[8], led_memaddr[9], led_memaddr[10], led_memaddr[11]};
105assign led[3] = {led_memdata[0], led_memdata[1], led_memdata[2], led_memdata[3], led_memdata[4], led_memdata[5], led_memdata[6], led_memdata[7], led_memdata[8], led_memdata[9], led_memdata[10], led_memdata[11]}; 111assign led[3] = {led_memdata[0], led_memdata[1], led_memdata[2], led_memdata[3], led_memdata[4], led_memdata[5], led_memdata[6], led_memdata[7], led_memdata[8], led_memdata[9], led_memdata[10], led_memdata[11]};
@@ -107,12 +113,19 @@ assign led[4] = {led_acc[0], led_acc[1], led_acc[2], led_acc[3], led_acc[4], led
107assign led[5] = {led_mq[0], led_mq[1], led_mq[2], led_mq[3], led_mq[4], led_mq[5], led_mq[6], led_mq[7], led_mq[8], led_mq[9], led_mq[10], led_mq[11]}; 113assign led[5] = {led_mq[0], led_mq[1], led_mq[2], led_mq[3], led_mq[4], led_mq[5], led_mq[6], led_mq[7], led_mq[8], led_mq[9], led_mq[10], led_mq[11]};
108assign led[6] = {led_word_count, led_defer, led_execute, led_fetch, led_opr, led_iot, led_jmp, led_jms, led_dca, led_isz, led_tad, led_and}; 114assign led[6] = {led_word_count, led_defer, led_execute, led_fetch, led_opr, led_iot, led_jmp, led_jms, led_dca, led_isz, led_tad, led_and};
109assign led[7] = {2'b0, led_step_counter, led_run, led_pause, led_ion, led_break, led_current_address}; 115assign led[7] = {2'b0, led_step_counter, led_run, led_pause, led_ion, led_break, led_current_address};
110assign led[8] = {5'b0, led_link, led_if, led_df}; 116assign led[8] = {5'b0, led_link, led_if[0], led_if[1], led_if[2], led_df[0], led_df[1], led_df[2]};
111 117
112core cpu 118core cpu
113 ( .clk(clk) 119 ( .clk(clk)
114 , .reset(reset) 120 , .reset(reset)
115 121
122 , .switch_df(switch_df)
123 , .switch_if(switch_if)
124 , .switch_sr(switch_sr)
125 , .switch_start(switch_start)
126 , .switch_load_add(switch_load_add)
127 , .switch_dep(switch_dep)
128 , .switch_exam(switch_exam)
116 , .switch_cont(switch_cont) 129 , .switch_cont(switch_cont)
117 , .switch_stop(switch_stop) 130 , .switch_stop(switch_stop)
118 , .switch_sing_step(switch_sing_step) 131 , .switch_sing_step(switch_sing_step)