diff options
Diffstat (limited to '')
| -rw-r--r-- | PLAN | 16 | ||||
| -rw-r--r-- | hdl/core.sv | 56 | ||||
| -rw-r--r-- | hdl/top.sv | 27 |
3 files changed, 84 insertions, 15 deletions
| @@ -1,15 +1,15 @@ | |||
| 1 | Turn on blinkenlights from the PDP core | 1 | Turn on blinkenlights from the PDP core |
| 2 | 2 | ||
| 3 | Implement switch features: | 3 | Implement 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 | ||
| 10 | Don't ignore 6000 and 6001 | 9 | Don't ignore 6000 and 6001 |
| 11 | 10 | ||
| 12 | Add "interrupts enabled" flag | 11 | Add "interrupts enabled" flag |
| 12 | switch_start clears this | ||
| 13 | 6000, 6001, 6002 should properly handle it | 13 | 6000, 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 | |||
| 30 | Implement IF/DF fields | ||
| 31 | Will need to update behaviour of switch_load_add | ||
| 32 | |||
| 33 | Add a macro for reversing polarity of switch_sing_step and switch_sing_inst and | ||
| 34 | making 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 | ||
| 45 | bit run; | 52 | bit run; |
| 53 | bit switch_start_observed; | ||
| 54 | bit switch_load_add_observed; | ||
| 55 | bit switch_dep_observed; | ||
| 56 | bit switch_exam_observed; | ||
| 46 | bit switch_cont_observed; | 57 | bit switch_cont_observed; |
| 47 | assign led_run = run; | 58 | assign led_run = run; |
| 48 | 59 | ||
| @@ -53,8 +64,8 @@ bit [ADDR_BITS-1:0] mem_address; | |||
| 53 | bit [DATA_BITS-1:0] mem_write_data; | 64 | bit [DATA_BITS-1:0] mem_write_data; |
| 54 | assign led_current_address = mem_valid; | 65 | assign led_current_address = mem_valid; |
| 55 | 66 | ||
| 56 | assign led_df = 0; | 67 | assign led_df = switch_df; // FIXME actually implement DF and IF |
| 57 | assign led_if = 0; | 68 | assign led_if = switch_if; |
| 58 | assign led_memaddr = mem_address; | 69 | assign led_memaddr = mem_address; |
| 59 | 70 | ||
| 60 | bit mem_read_valid; | 71 | bit mem_read_valid; |
| @@ -151,6 +162,10 @@ assign led_pause = state == MEMWAIT || state == HALT; | |||
| 151 | always_ff @(posedge clk) begin | 162 | always_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) |
| @@ -49,9 +49,9 @@ panel fp | |||
| 49 | , .gpioc(gpioc) | 49 | , .gpioc(gpioc) |
| 50 | ); | 50 | ); |
| 51 | 51 | ||
| 52 | bit [3:1] switch_df; | 52 | bit [2:0] switch_df; |
| 53 | bit [3:1] switch_if; | 53 | bit [2:0] switch_if; |
| 54 | bit [12:1] switch_sr; | 54 | bit [11:0] switch_sr; |
| 55 | bit switch_start; | 55 | bit switch_start; |
| 56 | bit switch_load_add; | 56 | bit switch_load_add; |
| 57 | bit switch_dep; | 57 | bit switch_dep; |
| @@ -61,9 +61,12 @@ bit switch_stop; | |||
| 61 | bit switch_sing_step; | 61 | bit switch_sing_step; |
| 62 | bit switch_sing_inst; | 62 | bit switch_sing_inst; |
| 63 | 63 | ||
| 64 | assign switch_df = switch[2][3:1]; | 64 | // Note that we are reversing the order here on a number of aggregates because |
| 65 | assign switch_if = switch[2][6:4]; | 65 | // the panel model gives us LEDs and switches in schematic-order, which is the |
| 66 | assign switch_sr = switch[1]; | 66 | // opposite of the bit order |
| 67 | assign switch_df = {switch[2][1], switch[2][2], switch[2][3]}; | ||
| 68 | assign switch_if = {switch[2][4], switch[2][5], switch[2][6]}; | ||
| 69 | assign 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]}; | ||
| 67 | assign switch_start = switch[3][1]; | 70 | assign switch_start = switch[3][1]; |
| 68 | assign switch_load_add = switch[3][2]; | 71 | assign switch_load_add = switch[3][2]; |
| 69 | assign switch_dep = switch[3][3]; | 72 | assign switch_dep = switch[3][3]; |
| @@ -100,6 +103,9 @@ bit [2:0] led_df; | |||
| 100 | bit [2:0] led_if; | 103 | bit [2:0] led_if; |
| 101 | bit led_link; | 104 | bit 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 | ||
| 103 | assign 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]}; | 109 | assign 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]}; |
| 104 | assign 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]}; | 110 | assign 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]}; |
| 105 | assign 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]}; | 111 | assign 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 | |||
| 107 | assign 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]}; | 113 | assign 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]}; |
| 108 | assign 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}; | 114 | assign 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}; |
| 109 | assign led[7] = {2'b0, led_step_counter, led_run, led_pause, led_ion, led_break, led_current_address}; | 115 | assign led[7] = {2'b0, led_step_counter, led_run, led_pause, led_ion, led_break, led_current_address}; |
| 110 | assign led[8] = {5'b0, led_link, led_if, led_df}; | 116 | assign 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 | ||
| 112 | core cpu | 118 | core 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) |
