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

Subversion Repositories i650

[/] [i650/] [trunk/] [rtl/] [arith_ctl.v] - Blame information for rev 29

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 29 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: Arithmetic operation control.
9
// 
10
// Additional Comments: See US 2959351, Fig. 85.
11
//
12
// Copyright (c) 2015 Robert Abeles
13
//
14
// This source file is free software; you can redistribute it
15
// and/or modify it under the terms of the GNU Lesser General
16
// Public License as published by the Free Software Foundation;
17
// either version 2.1 of the License, or (at your option) any
18
// later version.
19
//
20
// This source is distributed in the hope that it will be
21
// useful, but WITHOUT ANY WARRANTY; without even the implied
22
// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
23
// PURPOSE.  See the GNU Lesser General Public License for more
24
// details.
25
//
26
// You should have received a copy of the GNU Lesser General
27
// Public License along with this source; if not, download it
28
// from http://www.opencores.org/lgpl.shtml
29
//////////////////////////////////////////////////////////////////////////////////
30
`include "defines.v"
31
 
32
module arith_ctl (
33
   input rst,
34
   input ap, bp, cp,
35
   input dx, d0, d5, d9, dxl, d0l, d1l,
36
   input wu,
37
 
38
   input [0:6] adder_out,
39
   input man_acc_reset, overflow_stop,
40
   input prog_add_d0,
41
   input half_correct_sig,
42
 
43
   output end_of_operation, arith_restart_d5, zero_insert, carry_blank,
44
          no_carry_blank, carry_insert, no_carry_insert,
45
   output reg compl_adj, divide, multiply, acc_true_add,
46
   output reg half_correct, hc_add_5
47
   );
48
 
49
   // registers to be defined:
50
   // reg compl_adj, divide, multiply;
51
   reg compl_result, end_mult_div, acc_compl_add, left_shift, shift_count,
52
       right_shift, dist_true;
53
 
54
   //-----------------------------------------------------------------------------
55
   // Special control circuits
56
   //
57
   // [88:70] Several special control circuits which are not associated with any
58
   // particular operation or group of operations are energized by the arithmetic
59
   // controls.
60
   //
61
   // These are: (1) Arithmetic operation and arithmetic restart. (2) Upper-lower
62
   // check (adder control gate). (3) Adder output zero insert control. (4) No
63
   // carry insert-carry blank and carry insert-no carry blank. (5) Accumulator
64
   // sign read-out.
65
   //-----------------------------------------------------------------------------
66
 
67
   //-----------------------------------------------------------------------------
68
   // Arithmetic operation and arithmetic restart
69
   //
70
   // [89:20] On arithmetic operations the restart signal is sent back to program
71
   // control shortly after the operation signal is received by arithmetic
72
   // control, before the operation is completed. This allows the control
73
   // commutator to advance on its "I" half cycle, find the next instruction and
74
   // begin its interpretation, concurrently with the performance of the operation
75
   // by arithmetic control. The control commutator's operation interlock will
76
   // prevent its advance beyond the point where there would be conflict between
77
   // the arithmetic operation in process and an operation called for by the new
78
   // instruction. Athe the end of the arithmetic operation in process, and end of
79
   // operation signal developed by arithmetic control releases the operation
80
   // interlock and allows the contorl commutator to advance.
81
   //-----------------------------------------------------------------------------
82
   reg arith_operation, arith_restart;
83
   assign arith_restart_d5 = arith_restart & d5;
84
   wire arith_op_on_p =   compl_adj
85
                        | divide
86
                        | multiply
87
                        | compl_result
88
                        | acc_true_add
89
                        | acc_compl_add
90
                        | hc_add_5
91
                        | left_shift
92
                        | shift_count
93
                        | right_shift
94
                        | overflow_stop
95
                        | end_mult_div;
96
 
97
   always @(posedge ap)
98
      if (rst) begin
99
         arith_operation <= 0;
100
         arith_restart   <= 0;
101
      end else begin
102
         arith_operation <= arith_op_on_p? 1'b1
103
                          : dx?            1'b0
104
                          :                arith_operation;
105
         arith_restart   <= (arith_op_on_p & ~arith_operation)? 1'b1
106
                          : d9?                                 1'b0
107
                          :                                     arith_restart;
108
      end;
109
   digit_pulse eop (rst, bp, ~arith_operation, 1'b1, end_of_operation);
110
 
111
`ifdef 0
112
   //-----------------------------------------------------------------------------
113
   // Upper-lower check -- adder control gate
114
   //
115
   // [90:5] It will be recalled from the description of the one digit adder in
116
   // the section on basic principles that an upper-lower check gate was required
117
   // as on of the conditions necessary to allow the distributor early outputs
118
   // through to the adder, in either true or complement form. The purpose of this
119
   // gate is to insure that either an upper or a lower signal and not both has
120
   // been sensed and that both reset and no reset are not present before allowing
121
   // distributor values to enter the adder.
122
   //-----------------------------------------------------------------------------
123
 
124
   //-----------------------------------------------------------------------------
125
   // Adder output zero insert control
126
   //
127
   // [90:45] 
128
   //-----------------------------------------------------------------------------
129
   assign zero_insert =   dxl & right_shift
130
                        | (dxl | d0l) & left_shift
131
                        | (dxl | d0l) & acc_true_add & compl_adj
132
                        | end_mult_div & acc_true_add & dist_true
133
                                       & div & no_rem & wu
134
                        | d0l & add_or_subt_sig
135
                        | dxl & mult_or_div_sig
136
                        | left_shift & (dxl | (d1l & ~significant_digit))
137
                        | mult_div_left_shift & d1l
138
                        | d0l & significant_digit;
139
 
140
   //-----------------------------------------------------------------------------
141
   // Carry insertion
142
   //-----------------------------------------------------------------------------
143
   assign carry_blank     =  dxl
144
                           | prog_add_d0
145
                           | (d0l & ~compl_acc_or_dist & ~hc_add_5);
146
   assign no_carry_blank  =  d1 & sel_stor_add_tlu
147
                           | d1l & quotient_digit & compl_acc_or_dist
148
                           | d0l & ~quotient_digit & compl_acc_or_dist;
149
   assign carry_insert    =  d1 & sel_stor_add_tlu
150
                           | d1l & quotient_digit & compl_acc_or_dist
151
                           | d0l & ~quotient_digit & compl_acc_or_dist;
152
   assign no_carry_insert =  dxl
153
                           | prog_add_d0
154
                           | (d0l & ~compl_acc_or_dist & ~hc_add_5);
155
 
156
   //-----------------------------------------------------------------------------
157
   // Sign control
158
   //-----------------------------------------------------------------------------
159
   assign acc_plus_out  =   (((~rem & d0u & ~ap) | (d0l & ~ap)) & acc_plus)
160
                          | (d0u & rem & rem_plus & ~ap);
161
   assign acc_minus_out =   (((~rem & d0u & ~ap) | (d0l & ~ap)) & acc_plus)
162
                          | (d0u & rem & rem_minus & ~ap);
163
   wire acc_sign_reset =   (d1l & add_sign_ctrl & ~divide & ~multiply)
164
                         | (d0 & mult_or_div_sig & a_c);
165
 
166
   reg acc_plus, acc_minus;
167
   //wire acc_plus_on_p =   (carry_test & compl_result_test_sig)
168
   //                     | (add_or_subt_sig & reset_op)
169
   //                     | (rem_minus & 
170
   //wire acc_minus_on_p =
171
 
172
 
173
   //-----------------------------------------------------------------------------
174
   // Adder entry controls
175
   //-----------------------------------------------------------------------------
176
 
177
 
178
   //-----------------------------------------------------------------------------
179
   // Arithmetic control
180
   //-----------------------------------------------------------------------------
181
   wire end_true_add;
182
 
183
   //-----------------------------------------------------------------------------
184
   // Half correct control
185
   //-----------------------------------------------------------------------------
186
   wire hc_ed0l_9 = ed0l & half_correct
187
                         & adder_out[`biq_b5] & adder_out[`biq_q4];
188
 
189
   always @(posedge rst, posedge cp) begin
190
      if (rst) begin
191
         half_correct <= 0;
192
         hc_add_5 <= 0;
193
      end else begin
194
         if (man_acc_reset | end_true_add) begin
195
            hc_add_5 <= 0;
196
         end else if (hc_ed0l_9) begin
197
            hc_add_5 <= 1;
198
         end
199
         if (hc_add_5 & ~hc_ed0l_9 & ed0l) begin
200
            half_correct <= 0;
201
         end else if (half_correct_sig) begin
202
            half_correct <= 1;
203
         end
204
      end
205
   end;
206
`endif
207
 
208
endmodule

powered by: WebSVN 2.1.0

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