OpenCores
URL https://opencores.org/ocsvn/i650/i650/trunk

Subversion Repositories i650

[/] [i650/] [trunk/] [rtl/] [operator_ctl.v] - Blame information for rev 23

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 7 eightycc
`timescale 1ns / 1ps
2
//////////////////////////////////////////////////////////////////////////////////
3
// IBM 650 Reconstruction in Verilog (i650)
4
// 
5
// This file is part of the IBM 650 Reconstruction in Verilog (i650) project
6
// http:////www.opencores.org/project,i650
7
//
8
// Description: Operator console and external control interface.
9
// 
10
// Additional Comments: See US 2959351, Fig. 75, 76, 76 and 77. Also implements
11
//  a simple command-based control interface.
12
//
13
// Copyright (c) 2015 Robert Abeles
14
//
15
// This source file is free software; you can redistribute it
16
// and/or modify it under the terms of the GNU Lesser General
17
// Public License as published by the Free Software Foundation;
18
// either version 2.1 of the License, or (at your option) any
19
// later version.
20
//
21
// This source is distributed in the hope that it will be
22
// useful, but WITHOUT ANY WARRANTY; without even the implied
23
// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
24
// PURPOSE.  See the GNU Lesser General Public License for more
25
// details.
26
//
27
// You should have received a copy of the GNU Lesser General
28
// Public License along with this source; if not, download it
29
// from http://www.opencores.org/lgpl.shtml
30
//////////////////////////////////////////////////////////////////////////////////
31
`include "defines.v"
32
 
33
module operator_ctl (
34 11 eightycc
      input rst, clk,
35 7 eightycc
      input ap, dp,
36 16 eightycc
      input dx, d0, d1, d2, d3, d4, d5, d6, d9, d10,
37
      input wu, wl, hp,
38 7 eightycc
      input [0:3] early_idx, ontime_idx,
39
 
40 15 eightycc
      input [0:6] cmd_digit_in, io_buffer_in, gs_in, acc_ontime, dist_ontime,
41
                  prog_ontime,
42 7 eightycc
      input [0:5] command,
43 22 eightycc
      input restart_reset,
44 7 eightycc
 
45 11 eightycc
      output reg[0:6] data_out, addr_out, console_out,
46 15 eightycc
      output [0:6] display_digit,
47 21 eightycc
      output reg console_to_addr, acc_ri_console,
48 7 eightycc
      output reg[0:14] gs_ram_addr,
49 10 eightycc
      output reg read_gs, write_gs,
50 7 eightycc
      output reg pgm_start, pgm_stop, err_reset, err_sense_reset,
51
      output run_control, half_or_pgm_stop, ri_storage, ro_storage,
52 23 eightycc
             storage_control, err_restart_sw, ovflw_stop_sw, ovflw_sense_sw,
53 16 eightycc
      output reg man_pgm_reset, man_acc_reset, hard_reset,
54
      output set_8000, reset_8000,
55 7 eightycc
 
56
      output reg[0:6] cmd_digit_out,
57 22 eightycc
      output reg busy, digit_ready, restart_reset_busy,
58 7 eightycc
      output reg punch_card, read_card, card_digit_ready
59
   );
60
 
61
   //-----------------------------------------------------------------------------
62 12 eightycc
   // Operator console switch settings and their control signals.
63 7 eightycc
   //-----------------------------------------------------------------------------
64
   reg pgm_sw_stop, pgm_sw_run,
65
       half_cycle_sw_run, half_cycle_sw_half,
66
       ctl_sw_addr_stop, ctl_sw_run, ctl_sw_manual,
67
       disp_sw_lacc, disp_sw_uacc, disp_sw_dist, disp_sw_pgm,
68
       disp_sw_ri, disp_sw_ro,
69
       ovflw_sw_stop, ovflw_sw_sense, err_sw_stop, err_sw_sense;
70
   reg [0:6] storage_entry_sw [0:15];
71
   reg [0:6] addr_sel_sw [0:3];
72
   assign run_control = disp_sw_lacc | disp_sw_uacc | disp_sw_dist | disp_sw_pgm;
73
   assign half_or_pgm_stop = half_cycle_sw_half | pgm_stop;
74
   assign ri_storage = disp_sw_ri;
75
   assign ro_storage = disp_sw_ro;
76
   assign storage_control = run_control | disp_sw_ro;
77 15 eightycc
   assign display_digit = (disp_sw_lacc | disp_sw_uacc)? acc_ontime
78
                        : (disp_sw_dist | disp_sw_ri | disp_sw_ro)? dist_ontime
79
                        : disp_sw_pgm? prog_ontime
80
                        : `biq_blank;
81 16 eightycc
   assign set_8000 = man_pgm_reset & (ctl_sw_addr_stop | ctl_sw_run);
82
   assign reset_8000 = man_pgm_reset & ctl_sw_manual;
83 23 eightycc
   assign err_restart_sw = err_sw_sense;
84
   assign ovflw_stop_sw  = ovflw_sw_stop;
85
   assign ovflw_sense_sw = ovflw_sw_sense;
86 7 eightycc
 
87 12 eightycc
   //-----------------------------------------------------------------------------
88
   // Calculate the RAM address of the general storage word at address gs_addr_.
89
   //-----------------------------------------------------------------------------
90 7 eightycc
   reg [0:6] gs_addr_th, gs_addr_h, gs_addr_t, gs_addr_u;
91 9 eightycc
   wire [0:14] gs_band_addr;
92 10 eightycc
   wire [0:9] gs_word_offset;
93 9 eightycc
   ram_band_addr rba(gs_addr_th, gs_addr_h, gs_addr_t, gs_band_addr);
94 7 eightycc
   ram_word_offset rwo(gs_addr_t, gs_addr_u, gs_word_offset);
95
   wire [0:14] gs_word_addr = gs_band_addr + gs_word_offset;
96
 
97 12 eightycc
   //-----------------------------------------------------------------------------
98
   // Operator console state machine
99
   //-----------------------------------------------------------------------------
100
   reg do_power_on_reset, do_reset_console, do_err_reset, do_err_sense_reset,
101
       do_pgm_reset, do_acc_reset, do_hard_reset, do_clear_drum;
102
   reg [0:5] state;
103
 
104 7 eightycc
   `define state_idle                  6'd0
105
 
106
   `define state_reset_console_1       6'd1
107
   `define state_reset_console_2       6'd2
108
   `define state_pgm_reset_1           6'd3
109
   `define state_pgm_reset_2           6'd4
110
   `define state_acc_reset_1           6'd5
111
   `define state_acc_reset_2           6'd6
112
   `define state_err_reset_1           6'd7
113
   `define state_err_reset_2           6'd8
114
   `define state_err_sense_reset_1     6'd9
115
   `define state_err_sense_reset_2     6'd10
116 11 eightycc
   `define state_hard_reset_1          6'd11
117 7 eightycc
 
118 11 eightycc
   `define state_storage_entry_sw_1    6'd12
119
   `define state_storage_entry_sw_2    6'd13
120
   `define state_addr_sel_sw_1         6'd14
121
   `define state_addr_sel_sw_2         6'd15
122 7 eightycc
 
123 11 eightycc
   `define state_xfer_key_1            6'd16
124
   `define state_xfer_key_2            6'd17
125
   `define state_pgm_start_key_1       6'd18
126
   `define state_pgm_start_key_2       6'd19
127
   `define state_pgm_stop_key_1        6'd20
128
   `define state_pgm_stop_key_2        6'd21
129 7 eightycc
 
130 11 eightycc
   `define state_read_gs_1             6'd30
131
   `define state_read_gs_2             6'd31
132
   `define state_read_gs_3             6'd32
133
   `define state_read_gs_4             6'd33
134
   `define state_read_gs_5             6'd34
135 12 eightycc
   `define state_read_gs_6             6'd35
136 13 eightycc
   `define state_write_gs_1            6'd36
137
   `define state_write_gs_2            6'd37
138
   `define state_write_gs_3            6'd38
139
   `define state_write_gs_4            6'd39
140
   `define state_write_gs_5            6'd40
141 16 eightycc
   `define state_read_acc_1            6'd41
142
   `define state_read_acc_2            6'd42
143
   `define state_read_acc_3            6'd43
144
   `define state_read_dist_1           6'd44
145
   `define state_read_dist_2           6'd45
146
   `define state_read_dist_3           6'd46
147
   `define state_read_prog_1           6'd47
148
   `define state_read_prog_2           6'd48
149
   `define state_read_prog_3           6'd49
150 21 eightycc
   `define state_write_acc_1           6'd50
151
   `define state_write_acc_2           6'd51
152
   `define state_write_acc_3           6'd52
153
   `define state_clear_drum_1          6'd53
154
   `define state_clear_drum_2          6'd54
155
   `define state_clear_drum_3          6'd55
156
   `define state_load_gs_1             6'd56
157
   `define state_load_gs_2             6'd57
158
   `define state_dump_gs_1             6'd58
159
   `define state_dump_gs_2             6'd59
160
   `define state_dump_gs_3             6'd60
161
   `define state_dump_gs_4             6'd61
162 7 eightycc
 
163 20 eightycc
   always @(posedge clk)
164 7 eightycc
      if (rst) begin
165
         console_to_addr  <= 0;
166
         pgm_start        <= 0;
167
         pgm_stop         <= 0;
168
         err_reset        <= 0;
169
         err_sense_reset  <= 0;
170
         man_pgm_reset    <= 0;
171
         man_acc_reset    <= 0;
172 11 eightycc
         hard_reset       <= 0;
173 7 eightycc
 
174
         // reset console switches
175
         pgm_sw_stop      <= 0;
176
         pgm_sw_run       <= 1;
177 11 eightycc
         half_cycle_sw_run <= 1;
178
         half_cycle_sw_half <= 0;
179 7 eightycc
         ctl_sw_addr_stop <= 0;
180
         ctl_sw_run       <= 1;
181
         ctl_sw_manual    <= 0;
182
         disp_sw_lacc     <= 0;
183
         disp_sw_uacc     <= 0;
184
         disp_sw_dist     <= 1;
185 22 eightycc
         disp_sw_pgm      <= 0;
186 7 eightycc
         disp_sw_ri       <= 0;
187
         disp_sw_ro       <= 0;
188
         ovflw_sw_stop    <= 1;
189
         ovflw_sw_sense   <= 0;
190
         err_sw_stop      <= 1;
191
         err_sw_sense     <= 0;
192
 
193
         state         <= `state_idle;
194
         busy          <= 1;
195
         digit_ready   <= 0;
196
         cmd_digit_out <= `biq_blank;
197 22 eightycc
         restart_reset_busy <= 0;
198 7 eightycc
 
199
         do_power_on_reset  <= 1;
200
         do_reset_console   <= 0;
201
         do_err_reset       <= 0;
202
         do_err_sense_reset <= 0;
203
         do_pgm_reset       <= 0;
204
         do_acc_reset       <= 0;
205 11 eightycc
         do_hard_reset      <= 0;
206
         do_clear_drum      <= 0;
207 7 eightycc
 
208
         gs_ram_addr        <= 15'd0;
209 9 eightycc
         read_gs            <= 0;
210 10 eightycc
         write_gs           <= 0;
211 21 eightycc
         acc_ri_console     <= 0;
212 11 eightycc
         console_out        <= `biq_blank;
213
      end else if (dp) begin
214 7 eightycc
         case (state)
215
            `state_idle: begin
216
               case (command)
217
                  `cmd_none: begin
218 22 eightycc
                     if (restart_reset) begin
219
                        do_pgm_reset       <= 1;
220
                        do_acc_reset       <= 1;
221
                        do_err_reset       <= 1;
222
                        restart_reset_busy <= 1;
223
                     end else if (do_power_on_reset) begin
224 7 eightycc
                        do_power_on_reset  <= 0;
225
                        do_reset_console   <= 1;
226
                        do_pgm_reset       <= 1;
227
                        do_acc_reset       <= 1;
228
                        do_err_reset       <= 1;
229
                        do_err_sense_reset <= 1;
230 11 eightycc
                        do_hard_reset      <= 1;
231
                        do_clear_drum      <= 1;
232
                     end else if (do_hard_reset) begin
233 22 eightycc
                        do_hard_reset      <= 0;
234
                        hard_reset         <= 1;
235 11 eightycc
                        state <= `state_hard_reset_1;
236 7 eightycc
                     end else if (do_reset_console) begin
237
                        do_reset_console   <= 0;
238
                        state <= `state_reset_console_1;
239
                     end else if (do_pgm_reset) begin
240
                        do_pgm_reset       <= 0;
241
                        state <= `state_pgm_reset_1;
242
                     end else if (do_acc_reset) begin
243
                        do_acc_reset       <= 0;
244
                        man_acc_reset      <= 1;
245
                        state <= `state_acc_reset_1;
246
                     end else if (do_err_reset) begin
247
                        do_err_reset       <= 0;
248
                        err_reset          <= 1;
249
                        state <= `state_err_reset_1;
250
                     end else if (do_err_sense_reset) begin
251
                        do_err_sense_reset <= 0;
252 22 eightycc
                        err_sense_reset    <= 1;
253 7 eightycc
                        state <= `state_err_sense_reset_1;
254 21 eightycc
                     end else if (do_clear_drum) begin
255 22 eightycc
                        do_clear_drum      <= 0;
256 21 eightycc
                        state <= `state_clear_drum_1;
257 7 eightycc
                     end else begin
258
                        busy <= 0;
259
                        digit_ready <= 0;
260 22 eightycc
                        restart_reset_busy <= 0;
261 7 eightycc
                     end
262
                  end
263
 
264
                  `cmd_pgm_sw_stop: begin
265
                     busy <= 1;
266
                     pgm_sw_stop <= 1;
267
                     pgm_sw_run  <= 0;
268
                  end
269
 
270
                  `cmd_pgm_sw_run: begin
271
                     busy <= 1;
272
                     pgm_sw_stop <= 0;
273
                     pgm_sw_run  <= 1;
274
                  end
275
 
276
                  `cmd_half_cycle_sw_run: begin
277
                     busy <= 1;
278
                     half_cycle_sw_run  <= 1;
279
                     half_cycle_sw_half <= 0;
280
                  end
281
 
282
                  `cmd_half_cycle_sw_half: begin
283
                     busy <= 1;
284
                     half_cycle_sw_run  <= 0;
285
                     half_cycle_sw_half <= 1;
286
                  end
287
 
288
                  `cmd_ctl_sw_addr_stop: begin
289
                     busy <= 1;
290
                     ctl_sw_addr_stop <= 1;
291
                     ctl_sw_run       <= 0;
292
                     ctl_sw_manual    <= 0;
293
                  end
294
 
295
                  `cmd_ctl_sw_run: begin
296
                     busy <= 1;
297
                     ctl_sw_addr_stop <= 0;
298
                     ctl_sw_run       <= 1;
299
                     ctl_sw_manual    <= 0;
300
                  end
301
 
302
                  `cmd_ctl_sw_manual: begin
303
                     busy <= 1;
304
                     ctl_sw_addr_stop <= 0;
305
                     ctl_sw_run       <= 0;
306
                     ctl_sw_manual    <= 1;
307
                  end
308
 
309
                  `cmd_disp_sw_lacc: begin
310
                     busy <= 1;
311
                     disp_sw_lacc <= 1;
312
                     disp_sw_uacc <= 0;
313
                     disp_sw_dist <= 0;
314 22 eightycc
                     disp_sw_pgm  <= 0;
315 7 eightycc
                     disp_sw_ri   <= 0;
316
                     disp_sw_ro   <= 0;
317
                  end
318
 
319
                  `cmd_disp_sw_uacc: begin
320
                     busy <= 1;
321
                     disp_sw_lacc <= 0;
322
                     disp_sw_uacc <= 1;
323
                     disp_sw_dist <= 0;
324
                     disp_sw_pgm <= 0;
325
                     disp_sw_ri   <= 0;
326
                     disp_sw_ro   <= 0;
327
                  end
328
 
329
                  `cmd_disp_sw_dist: begin
330
                     busy <= 1;
331
                     disp_sw_lacc <= 0;
332
                     disp_sw_uacc <= 0;
333
                     disp_sw_dist <= 1;
334
                     disp_sw_pgm <= 0;
335
                     disp_sw_ri   <= 0;
336
                     disp_sw_ro   <= 0;
337
                  end
338
 
339
                  `cmd_disp_sw_prog: begin
340
                     busy <= 1;
341
                     disp_sw_lacc <= 0;
342
                     disp_sw_uacc <= 0;
343
                     disp_sw_dist <= 0;
344
                     disp_sw_pgm <= 1;
345
                     disp_sw_ri   <= 0;
346
                     disp_sw_ro   <= 0;
347
                  end
348
 
349
                  `cmd_disp_sw_ri: begin
350
                     busy <= 1;
351
                     disp_sw_lacc <= 0;
352
                     disp_sw_uacc <= 0;
353
                     disp_sw_dist <= 0;
354
                     disp_sw_pgm <= 0;
355
                     disp_sw_ri   <= 1;
356
                     disp_sw_ro   <= 0;
357
                  end
358
 
359
                  `cmd_disp_sw_ro: begin
360
                     busy <= 1;
361
                     disp_sw_lacc <= 0;
362
                     disp_sw_uacc <= 0;
363
                     disp_sw_dist <= 0;
364
                     disp_sw_pgm <= 0;
365
                     disp_sw_ri   <= 0;
366
                     disp_sw_ro   <= 1;
367
                  end
368
 
369
                  `cmd_ovflw_sw_stop: begin
370
                     busy <= 1;
371
                     ovflw_sw_stop  <= 1;
372
                     ovflw_sw_sense <= 0;
373
                  end
374
 
375
                  `cmd_ovflw_sw_sense: begin
376
                     busy <= 1;
377
                     ovflw_sw_stop  <= 0;
378
                     ovflw_sw_sense <= 1;
379
                  end
380
 
381
                  `cmd_err_sw_stop: begin
382
                     busy <= 1;
383
                     err_sw_stop  <= 1;
384
                     err_sw_sense <= 0;
385
                  end
386
 
387
                  `cmd_err_sw_sense: begin
388
                     busy <= 1;
389
                     err_sw_stop  <= 0;
390
                     err_sw_sense <= 1;
391
                  end
392
 
393
                  `cmd_storage_entry_sw: begin
394
                     busy <= 1;
395
                     state <= `state_storage_entry_sw_1;
396
                  end
397
 
398
                  `cmd_addr_sel_sw: begin
399
                     busy <= 1;
400
                     state <= `state_addr_sel_sw_1;
401
                  end
402
 
403
                  `cmd_xfer_key: begin
404
                     if (ctl_sw_manual) begin
405
                        busy <= 1;
406
                        state <= `state_xfer_key_1;
407
                     end
408
                  end
409
 
410
                  `cmd_pgm_start_key: begin
411
                     busy <= 1;
412
                     state <= `state_pgm_start_key_1;
413
                  end
414
 
415
                  `cmd_pgm_stop_key: begin
416
                     busy <= 1;
417
                     pgm_stop <= 1;
418
                     state <= `state_pgm_stop_key_1;
419
                  end
420
 
421
                  `cmd_pgm_reset_key: begin
422 11 eightycc
                     busy <= 1;
423 7 eightycc
                     do_pgm_reset <= 1;
424
                     do_err_reset <= 1;
425
                  end
426
 
427
                  `cmd_comp_reset_key: begin
428 11 eightycc
                     busy <= 1;
429 7 eightycc
                     do_pgm_reset <= 1;
430
                     do_acc_reset <= 1;
431
                     do_err_reset <= 1;
432
                  end
433
 
434
                  `cmd_acc_reset_key: begin
435 11 eightycc
                     busy <= 1;
436 7 eightycc
                     do_acc_reset <= 1;
437
                     do_err_reset <= 1;
438
                  end
439
 
440
                  `cmd_err_reset_key: begin
441 11 eightycc
                     busy <= 1;
442 7 eightycc
                     do_err_reset <= 1;
443
                  end
444
 
445
                  `cmd_err_sense_reset_key: begin
446 11 eightycc
                     busy <= 1;
447 7 eightycc
                     do_err_sense_reset <= 1;
448
                  end
449
 
450
                  //--------------------------------------------------------------
451
                  // Read from general storage:
452
                  //    --> 4 digits address, little-endian
453
                  //    <-- 1 digit sign, 10 digits, little-endian
454
                  // 0 : Ignore if CPU not stopped
455
                  //     Accept low-order address digit
456
                  // 1 : Accept remaining address digits
457
                  // 2 : Calculate word origin in gs RAM
458
                  //     Validate address
459
                  //     console_read_gs <= 1;
460
                  // 3 : Send gs-early digit to out
461
                  //     digit_ready <= 1;
462
                  // 4 : digit_ready <= 0;
463
                  //--------------------------------------------------------------
464
                  `cmd_read_gs: begin
465
                     if (ctl_sw_manual) begin
466
                        busy <= 1;
467
                        state <= `state_read_gs_1;
468
                     end
469
                  end
470 10 eightycc
 
471 13 eightycc
                  // Write word to general storage:
472
                  //    --> 4 digits address, little-endian
473
                  //    <-- dx digit, sign digit, d1-d10
474
                  // 0: Ignore if not in manual
475
                  // 1: Readin low-order addr digit
476
                  // 2: Readin remaining addr digits
477
                  // 3: Synchronize with d10
478
                  //    digit_ready <- 1
479
                  // 4: Readin first digit
480
                  // 5: Write digit
481
                  //    Readin next digit
482
                  // 6: Cleanup
483 9 eightycc
                  `cmd_write_gs: begin
484 13 eightycc
                     if (ctl_sw_manual) begin
485
                        busy <= 1;
486
                        state <= `state_write_gs_1;
487
                     end
488 10 eightycc
                  end
489
 
490 9 eightycc
                  `cmd_read_acc: begin
491 16 eightycc
                     busy <= 1;
492
                     state <= `state_read_acc_1;
493 10 eightycc
                  end
494
 
495 9 eightycc
                  `cmd_read_dist: begin
496 16 eightycc
                     busy <= 1;
497
                     state <= `state_read_dist_1;
498 10 eightycc
                  end
499
 
500 9 eightycc
                  `cmd_read_prog: begin
501 16 eightycc
                     busy <= 1;
502
                     state <= `state_read_prog_1;
503 10 eightycc
                  end
504
 
505 21 eightycc
                  `cmd_write_acc: begin
506
                     busy <= 1;
507
                     state <= `state_write_acc_1;
508
                  end
509
 
510 10 eightycc
                  // 0 : Ignore if not in manual
511
                  //     Clear gs_ram_addr
512
                  // 1 : Synchronize with d10
513
                  //     Turn on console_write_gs
514
                  // 2 : Put a digit:
515
                  //     dx: blank
516
                  //     d0: minus
517
                  //     d1-d10: zero
518
                  //     gs_ram_addr++
519 9 eightycc
                  `cmd_clear_gs: begin
520 11 eightycc
                     if (ctl_sw_manual) begin
521
                        busy <= 1;
522
                        do_clear_drum <= 1;
523
                     end
524 10 eightycc
                  end
525
 
526 9 eightycc
                  `cmd_load_gs: begin
527 13 eightycc
                     if (ctl_sw_manual) begin
528
                        busy <= 1;
529
                        state <= `state_load_gs_1;
530
                        digit_ready <= 1;
531
                     end
532 10 eightycc
                  end
533
 
534 9 eightycc
                  `cmd_dump_gs: begin
535 15 eightycc
                     if (ctl_sw_manual) begin
536
                        busy <= 1;
537
                        state <= `state_dump_gs_1;
538
                     end
539 10 eightycc
                  end
540
 
541 9 eightycc
                  `cmd_power_on_reset: begin
542 13 eightycc
                     busy <= 1;
543
                     do_power_on_reset <= 1;
544 10 eightycc
                  end
545
 
546 9 eightycc
                  `cmd_reset_console: begin
547 13 eightycc
                     busy <= 1;
548
                     do_reset_console <= 1;
549 10 eightycc
                  end
550 7 eightycc
 
551 11 eightycc
                  `cmd_hard_reset: begin
552
                     busy <= 1;
553
                     do_hard_reset <= 1;
554
                  end
555
 
556 7 eightycc
               endcase;
557
            end
558
 
559
            // Reset console            
560
            `state_reset_console_1: begin
561
               if (d10) state <= `state_reset_console_2;
562
            end
563
 
564
            `state_reset_console_2: begin
565 11 eightycc
               storage_entry_sw[ontime_idx] <= dx? `biq_blank
566
                                             : d0? `biq_plus : `biq_0;
567 7 eightycc
               addr_sel_sw[ontime_idx[2:3]] <= `biq_0;
568
               if (d10) state <= `state_idle;
569
            end
570
 
571
            // Program reset key press
572
            `state_pgm_reset_1: begin
573
               if (wu & d10) begin
574
                  man_pgm_reset <= 1;
575
                  state <= `state_pgm_reset_2;
576
               end
577
            end
578
 
579
            `state_pgm_reset_2: begin
580
               if (wu & d10) begin
581
                  man_pgm_reset <= 0;
582
                  state <= `state_idle;
583
               end
584
            end
585
 
586
            // Accumulator reset key press
587
            `state_acc_reset_1: begin
588
               if (wu & d10) begin
589
                  man_acc_reset <= 1;
590
                  state <= `state_acc_reset_2;
591
               end
592
            end
593
 
594
            `state_acc_reset_2: begin
595
               if (wu & d10) begin
596
                  man_acc_reset <= 0;
597
                  state <= `state_idle;
598
               end
599
            end
600
 
601
            // Error reset key press
602
            `state_err_reset_1: begin
603
               if (wu & d10) begin
604
                  err_reset <= 1;
605
                  state <= `state_err_reset_2;
606
               end
607
            end
608
 
609
            `state_err_reset_2: begin
610
               if (wu & d10) begin
611
                  err_reset <= 0;
612
                  state <= `state_idle;
613
               end
614
            end
615
 
616
            // Error sense reset key press
617
            `state_err_sense_reset_1: begin
618
               if (wu & d10) begin
619
                  err_sense_reset <= 1;
620
                  state <= `state_err_sense_reset_2;
621
               end
622
            end
623
 
624
            `state_err_sense_reset_2: begin
625
               if (wu & d10) begin
626
                  err_sense_reset <= 0;
627
                  state <= `state_idle;
628
               end
629
            end
630
 
631 11 eightycc
            // Hard reset
632
            `state_hard_reset_1: begin
633
               hard_reset <= 0;
634
               state <= `state_idle;
635
            end
636
 
637 7 eightycc
            // Set storage entry switches
638
            `state_storage_entry_sw_1: begin
639
               if (d0) begin
640
                  state <= `state_storage_entry_sw_2;
641
                  digit_ready <= 1;
642
                  storage_entry_sw[ontime_idx] <= cmd_digit_in;
643
               end
644
            end
645
 
646
            `state_storage_entry_sw_2: begin
647
               storage_entry_sw[ontime_idx] <= cmd_digit_in;
648
               if (d10) begin
649
                  state <= `state_idle;
650
                  digit_ready <= 0;
651
               end
652
            end
653
 
654
            // Set address selection switches
655
            `state_addr_sel_sw_1: begin
656
               if (dx) begin
657
                  state <= `state_addr_sel_sw_2;
658
                  digit_ready <= 1;
659
                  addr_sel_sw[ontime_idx[2:3]] <= cmd_digit_in;
660
               end
661
            end
662
 
663
            `state_addr_sel_sw_2: begin
664
               addr_sel_sw[ontime_idx[2:3]] <= cmd_digit_in;
665
               if (d2) begin
666
                  state <= `state_idle;
667
                  digit_ready <= 0;
668
               end
669
            end
670
 
671
            // Transfer key press
672
            `state_xfer_key_1: begin
673
               if (d10) begin
674
                  console_to_addr <= 1;
675
                  state <= `state_xfer_key_2;
676
               end
677
            end
678
 
679
            `state_xfer_key_2: begin
680
               if (d10) begin
681
                  console_to_addr <= 0;
682
                  state <= `state_idle;
683
               end
684
            end
685
 
686
            // Start key press
687
            `state_pgm_start_key_1: begin
688
               if (wu & d10) begin
689
                  pgm_start <= 1;
690
                  state <= `state_pgm_start_key_2;
691
               end
692
            end
693
 
694
            `state_pgm_start_key_2: begin
695
               if (wu & d10) begin
696
                  pgm_start <= 0;
697
                  state <= `state_idle;
698
               end
699
            end
700
 
701
            // Stop key press
702
            `state_pgm_stop_key_1: begin
703
               if (hp) state <= `state_pgm_stop_key_2;
704
            end
705
 
706
            `state_pgm_stop_key_2: begin
707
               if (hp) begin
708
                  pgm_stop <= 0;
709
                  state <= `state_idle;
710
               end
711
            end
712
 
713
            // Read word from general storage
714
            //    --> 4 digits address, little-endian
715
            //    <-- 1 digit sign, 10 digits, little-endian
716
            // 0 : Ignore if CPU not stopped
717 12 eightycc
            // 1 : Accept first address digit
718
            // 2 : Accept remaining address digits
719 7 eightycc
            // 2 : Calculate word origin in gs RAM
720
            //     Validate address
721
            //     console_read_gs <= 1;
722
            // 3 : Send gs-early digit to out
723
            //     digit_ready <= 1;
724
            // 4 : digit_ready <= 0;
725
            `state_read_gs_1: begin
726
               if (dx) begin
727
                  state <= `state_read_gs_2;
728
                  digit_ready <= 1;
729
                  gs_addr_u <= cmd_digit_in;
730
               end
731
            end
732
 
733
            `state_read_gs_2: begin
734
               if (d0) gs_addr_t <= cmd_digit_in;
735
               else if (d1) gs_addr_h <= cmd_digit_in;
736
               else if (d2) begin
737
                  gs_addr_th <= cmd_digit_in;
738
                  state <= `state_read_gs_3;
739
                  digit_ready <= 0;
740
               end
741
            end
742
 
743
            `state_read_gs_3: begin
744 12 eightycc
               if (d10) begin
745
                  gs_ram_addr <= gs_word_addr;
746
                  read_gs <= 1;
747
                  state <= `state_read_gs_4;
748
               end
749 7 eightycc
            end
750
 
751 10 eightycc
            `state_read_gs_4: begin
752
               state <= `state_read_gs_5;
753 15 eightycc
               gs_ram_addr <= (gs_ram_addr + 1) % 32768;
754 10 eightycc
            end
755 12 eightycc
 
756
            `state_read_gs_5: begin
757
               digit_ready <= 1;
758
               cmd_digit_out <= gs_in;
759 15 eightycc
               gs_ram_addr <= (gs_ram_addr + 1) % 32768;
760 12 eightycc
               if (dx) begin
761
                  state <= `state_read_gs_6;
762
                  read_gs <= 0;
763
               end
764
            end
765
 
766
            `state_read_gs_6: begin
767
               digit_ready <= 0;
768
               state <= `state_idle;
769
            end
770 11 eightycc
 
771 13 eightycc
            // Write word to general storage:
772
            //    --> 4 digits address, little-endian
773
            //    <-- dx digit, sign digit, d1-d10
774
            // 0: Ignore if not in manual
775
            // 1: Readin low-order addr digit
776
            // 2: Readin remaining addr digits
777
            // 3: Synchronize with d10
778
            //    digit_ready <- 1
779
            // 4: Readin and write digit
780
            // 5: Write digit
781
            //    Readin next digit
782
            // 6: Cleanup
783
 
784
            `state_write_gs_1: begin
785
               if (dx) begin
786
                  state <= `state_write_gs_2;
787
                  digit_ready <= 1;
788
                  gs_addr_u <= cmd_digit_in;
789
               end
790
            end
791
 
792
            `state_write_gs_2: begin
793
               if (d0) gs_addr_t <= cmd_digit_in;
794
               else if (d1) gs_addr_h <= cmd_digit_in;
795
               else if (d2) begin
796
                  gs_addr_th <= cmd_digit_in;
797
                  state <= `state_write_gs_3;
798
                  digit_ready <= 0;
799
               end
800
            end
801
 
802
            `state_write_gs_3: begin
803
               if (d10) begin
804
                  gs_ram_addr <= gs_word_addr;
805
                  digit_ready <= 1;
806
                  state <= `state_write_gs_4;
807
               end
808
            end
809
 
810
            `state_write_gs_4: begin
811
               write_gs <= 1;
812
               console_out <= cmd_digit_in;
813 16 eightycc
               if (write_gs)
814
                  gs_ram_addr <= (gs_ram_addr + 1) % 32768;
815 13 eightycc
               if (d10) begin
816
                  digit_ready <= 0;
817
                  state <= `state_write_gs_5;
818
               end
819
            end
820
 
821
            `state_write_gs_5: begin
822
               write_gs <= 0;
823
               state <= `state_idle;
824
            end
825
 
826 16 eightycc
            `state_read_acc_1: begin
827
               if (wl & d10) begin
828
                  state <= `state_read_acc_2;
829
               end
830
            end
831
 
832
            `state_read_acc_2: begin
833
               digit_ready <= 1;
834
               cmd_digit_out <= acc_ontime;
835
               if (wu & d10) begin
836
                  state <= `state_read_acc_3;
837
               end
838
            end
839
 
840
            `state_read_acc_3: begin
841
               digit_ready <= 0;
842
               state <= `state_idle;
843
            end
844
 
845
            `state_read_dist_1: begin
846
               if (d10) begin
847
                  state <= `state_read_dist_2;
848
               end
849
            end
850
 
851
            `state_read_dist_2: begin
852
               digit_ready <= 1;
853
               cmd_digit_out <= dist_ontime;
854
               if (d10) begin
855
                  state <= `state_read_dist_3;
856
               end
857
            end
858
 
859
            `state_read_dist_3: begin
860
               digit_ready <= 0;
861
               state <= `state_idle;
862
            end
863
 
864
            `state_read_prog_1: begin
865
               if (d10) begin
866
                  state <= `state_read_prog_2;
867
               end
868
            end
869
 
870
            `state_read_prog_2: begin
871
               digit_ready <= 1;
872
               cmd_digit_out <= prog_ontime;
873
               if (d10) begin
874
                  state <= `state_read_prog_3;
875
               end
876
            end
877
 
878
            `state_read_prog_3: begin
879
               digit_ready <= 0;
880
               state <= `state_idle;
881
            end
882
 
883 21 eightycc
            `state_write_acc_1: begin
884 22 eightycc
               if (wl & dx) begin
885 21 eightycc
                  console_out <= cmd_digit_in;
886
                  acc_ri_console <= 1;
887
                  digit_ready <= 1;
888
                  state <= `state_write_acc_2;
889
               end
890
            end
891
 
892
            `state_write_acc_2: begin
893
               console_out <= cmd_digit_in;
894
               if (wu & d10) begin
895
                  digit_ready <= 0;
896
                  state <= `state_write_acc_3;
897
               end
898
            end
899
 
900
            `state_write_acc_3: begin
901
               acc_ri_console <= 0;
902
               state <= `state_idle;
903
            end
904
 
905 11 eightycc
            // 0 : Ignore if not in manual
906 15 eightycc
            // 1 : Synchronize with dx
907
            //     Put first dx digit
908 11 eightycc
            // 2 : Put a digit:
909
            //     dx: blank
910
            //     d0: minus
911
            //     d1-d10: zero
912
            `state_clear_drum_1: begin
913 15 eightycc
               if (dx) begin
914 13 eightycc
                  console_out <= `biq_blank;
915
                  gs_ram_addr <= 15'd0;
916
                  write_gs <= 1;
917 11 eightycc
                  state <= `state_clear_drum_2;
918
               end
919
            end
920 10 eightycc
 
921 11 eightycc
            `state_clear_drum_2: begin
922
               console_out <= dx? `biq_blank
923
                            : d0? `biq_minus
924
                            : `biq_0;
925 15 eightycc
               gs_ram_addr <= (gs_ram_addr + 1) % 32768;
926 11 eightycc
               if (gs_ram_addr == 15'd23999) begin
927
                  write_gs <= 0;
928
                  state <= `state_idle;
929
               end
930
            end
931
 
932 13 eightycc
            `state_load_gs_1: begin
933
               gs_ram_addr <= 15'd0;
934
               write_gs <= 1;
935
               console_out <= cmd_digit_in;
936
               state <= `state_load_gs_2;
937
            end
938
 
939
            `state_load_gs_2: begin
940 15 eightycc
               gs_ram_addr <= (gs_ram_addr + 1) % 32768;
941 13 eightycc
               console_out <= cmd_digit_in;
942 15 eightycc
               if (gs_ram_addr == 15'd23999) begin
943 13 eightycc
                  write_gs <= 0;
944
                  digit_ready <= 0;
945
                  state <= `state_idle;
946
               end
947
            end
948
 
949 15 eightycc
            `state_dump_gs_1: begin
950
               gs_ram_addr <= 15'd0;
951
               read_gs <= 1;
952
               state <= `state_dump_gs_2;
953
            end
954
 
955
            `state_dump_gs_2: begin
956
               gs_ram_addr <= (gs_ram_addr + 1) % 32768;
957
               state <= `state_dump_gs_3;
958
            end
959
 
960
            `state_dump_gs_3: begin
961
               digit_ready <= 1;
962
               gs_ram_addr <= (gs_ram_addr + 1) % 32768;
963
               cmd_digit_out <= gs_in;
964
               if (gs_ram_addr == 15'd23999) begin
965
                  state <= `state_dump_gs_4;
966
               end
967
            end
968
 
969
            `state_dump_gs_4: begin
970
               digit_ready <= 0;
971
               read_gs <= 0;
972
               state <= `state_idle;
973
            end
974
 
975 7 eightycc
         endcase;
976 20 eightycc
      end;
977 7 eightycc
 
978 20 eightycc
   always @(posedge ap)
979 11 eightycc
      if (hard_reset) begin
980 7 eightycc
         data_out <= `biq_blank;
981
         addr_out <= `biq_blank;
982
      end else begin
983
         data_out <= d10? `biq_blank : storage_entry_sw[early_idx];
984
         addr_out <= (d3 | d4 | d5 | d6)? addr_sel_sw[early_idx[2:3]] : `biq_blank;
985 20 eightycc
      end;
986 7 eightycc
 
987 20 eightycc
   always @(posedge ap)
988 11 eightycc
      if (hard_reset) begin
989 7 eightycc
         punch_card       <= 0;
990
         read_card        <= 0;
991
         card_digit_ready <= 0;
992 20 eightycc
      end;
993 7 eightycc
 
994
endmodule

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.