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

Subversion Repositories i650

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

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

powered by: WebSVN 2.1.0

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