OpenCores
URL https://opencores.org/ocsvn/a-z80/a-z80/trunk

Subversion Repositories a-z80

[/] [a-z80/] [trunk/] [cpu/] [alu/] [alu.v] - Blame information for rev 11

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

Line No. Rev Author Line
1 3 gdevic
// Copyright (C) 1991-2013 Altera Corporation
2
// Your use of Altera Corporation's design tools, logic functions 
3
// and other software and tools, and its AMPP partner logic 
4
// functions, and any output files from any of the foregoing 
5
// (including device programming or simulation files), and any 
6
// associated documentation or information are expressly subject 
7
// to the terms and conditions of the Altera Program License 
8
// Subscription Agreement, Altera MegaCore Function License 
9
// Agreement, or other applicable license agreement, including, 
10
// without limitation, that your use is for the sole purpose of 
11
// programming logic devices manufactured by Altera and sold by 
12
// Altera or its authorized distributors.  Please refer to the 
13
// applicable agreement for further details.
14
 
15
// PROGRAM              "Quartus II 64-Bit"
16
// VERSION              "Version 13.0.1 Build 232 06/12/2013 Service Pack 1 SJ Web Edition"
17
// CREATED              "Fri Nov 07 19:44:45 2014"
18
 
19
module alu(
20
        alu_core_R,
21
        alu_core_V,
22
        alu_core_S,
23
        alu_bs_oe,
24
        alu_parity_in,
25
        alu_oe,
26
        alu_shift_oe,
27
        alu_core_cf_in,
28
        alu_op2_oe,
29
        alu_op1_oe,
30
        alu_res_oe,
31
        alu_op1_sel_low,
32
        alu_op1_sel_zero,
33
        alu_op1_sel_bus,
34
        alu_op2_sel_zero,
35
        alu_op2_sel_bus,
36
        alu_op2_sel_lq,
37
        alu_op_low,
38
        alu_shift_in,
39
        alu_sel_op2_neg,
40
        alu_sel_op2_high,
41
        alu_shift_left,
42
        alu_shift_right,
43
        clk,
44
        bsel,
45
        alu_zero,
46
        alu_parity_out,
47
        alu_high_eq_9,
48
        alu_high_gt_9,
49
        alu_low_gt_9,
50
        alu_shift_db0,
51
        alu_shift_db7,
52
        alu_core_cf_out,
53
        alu_sf_out,
54
        alu_yf_out,
55
        alu_xf_out,
56
        alu_vf_out,
57
        db,
58
        test_db_high,
59
        test_db_low
60
);
61
 
62
 
63
input wire      alu_core_R;
64
input wire      alu_core_V;
65
input wire      alu_core_S;
66
input wire      alu_bs_oe;
67
input wire      alu_parity_in;
68
input wire      alu_oe;
69
input wire      alu_shift_oe;
70
input wire      alu_core_cf_in;
71
input wire      alu_op2_oe;
72
input wire      alu_op1_oe;
73
input wire      alu_res_oe;
74
input wire      alu_op1_sel_low;
75
input wire      alu_op1_sel_zero;
76
input wire      alu_op1_sel_bus;
77
input wire      alu_op2_sel_zero;
78
input wire      alu_op2_sel_bus;
79
input wire      alu_op2_sel_lq;
80
input wire      alu_op_low;
81
input wire      alu_shift_in;
82
input wire      alu_sel_op2_neg;
83
input wire      alu_sel_op2_high;
84
input wire      alu_shift_left;
85
input wire      alu_shift_right;
86
input wire      clk;
87
input wire      [2:0] bsel;
88
output wire     alu_zero;
89
output wire     alu_parity_out;
90
output wire     alu_high_eq_9;
91
output wire     alu_high_gt_9;
92
output wire     alu_low_gt_9;
93
output wire     alu_shift_db0;
94
output wire     alu_shift_db7;
95
output wire     alu_core_cf_out;
96
output wire     alu_sf_out;
97
output wire     alu_yf_out;
98
output wire     alu_xf_out;
99
output wire     alu_vf_out;
100
inout wire      [7:0] db;
101
output wire     [3:0] test_db_high;
102
output wire     [3:0] test_db_low;
103
 
104
wire    [3:0] alu_op1;
105
wire    [3:0] alu_op2;
106
wire    [3:0] db_high;
107
wire    [3:0] db_low;
108
reg     [3:0] op1_high;
109
reg     [3:0] op1_low;
110
reg     [3:0] op2_high;
111
reg     [3:0] op2_low;
112
wire    [3:0] result_hi;
113
reg     [3:0] result_lo;
114
wire    [3:0] SYNTHESIZED_WIRE_0;
115
wire    [3:0] SYNTHESIZED_WIRE_1;
116
wire    [3:0] SYNTHESIZED_WIRE_2;
117
wire    [3:0] SYNTHESIZED_WIRE_3;
118
wire    SYNTHESIZED_WIRE_35;
119
wire    [3:0] SYNTHESIZED_WIRE_5;
120
wire    [3:0] SYNTHESIZED_WIRE_7;
121
wire    [3:0] SYNTHESIZED_WIRE_8;
122
wire    SYNTHESIZED_WIRE_9;
123
wire    [3:0] SYNTHESIZED_WIRE_10;
124
wire    [3:0] SYNTHESIZED_WIRE_11;
125
wire    [3:0] SYNTHESIZED_WIRE_12;
126
wire    [3:0] SYNTHESIZED_WIRE_13;
127
wire    [3:0] SYNTHESIZED_WIRE_14;
128
wire    [3:0] SYNTHESIZED_WIRE_15;
129
wire    [3:0] SYNTHESIZED_WIRE_16;
130
wire    SYNTHESIZED_WIRE_17;
131
wire    [3:0] SYNTHESIZED_WIRE_18;
132
wire    SYNTHESIZED_WIRE_36;
133
wire    SYNTHESIZED_WIRE_20;
134
wire    [3:0] SYNTHESIZED_WIRE_21;
135
wire    SYNTHESIZED_WIRE_23;
136
wire    [3:0] SYNTHESIZED_WIRE_24;
137
wire    SYNTHESIZED_WIRE_37;
138
wire    SYNTHESIZED_WIRE_26;
139
wire    [3:0] SYNTHESIZED_WIRE_27;
140
wire    SYNTHESIZED_WIRE_29;
141
wire    SYNTHESIZED_WIRE_30;
142
wire    SYNTHESIZED_WIRE_31;
143
wire    SYNTHESIZED_WIRE_32;
144
wire    [3:0] SYNTHESIZED_WIRE_33;
145
wire    [3:0] SYNTHESIZED_WIRE_34;
146
 
147
 
148
 
149
 
150
assign  db_low[3] = alu_bs_oe ? SYNTHESIZED_WIRE_0[3] : 1'bz;
151
assign  db_low[2] = alu_bs_oe ? SYNTHESIZED_WIRE_0[2] : 1'bz;
152
assign  db_low[1] = alu_bs_oe ? SYNTHESIZED_WIRE_0[1] : 1'bz;
153
assign  db_low[0] = alu_bs_oe ? SYNTHESIZED_WIRE_0[0] : 1'bz;
154
 
155
assign  db_high[3] = alu_bs_oe ? SYNTHESIZED_WIRE_1[3] : 1'bz;
156
assign  db_high[2] = alu_bs_oe ? SYNTHESIZED_WIRE_1[2] : 1'bz;
157
assign  db_high[1] = alu_bs_oe ? SYNTHESIZED_WIRE_1[1] : 1'bz;
158
assign  db_high[0] = alu_bs_oe ? SYNTHESIZED_WIRE_1[0] : 1'bz;
159
 
160
 
161
alu_core        b2v_core(
162
        .cy_in(alu_core_cf_in),
163
        .S(alu_core_S),
164
        .V(alu_core_V),
165
        .R(alu_core_R),
166
        .op1(alu_op1),
167
        .op2(alu_op2),
168
        .cy_out(alu_core_cf_out),
169
        .vf_out(alu_vf_out),
170
        .result(result_hi));
171
 
172
assign  db[3] = alu_oe ? db_low[3] : 1'bz;
173
assign  db[2] = alu_oe ? db_low[2] : 1'bz;
174
assign  db[1] = alu_oe ? db_low[1] : 1'bz;
175
assign  db[0] = alu_oe ? db_low[0] : 1'bz;
176
 
177
assign  db[7] = alu_oe ? db_high[3] : 1'bz;
178
assign  db[6] = alu_oe ? db_high[2] : 1'bz;
179
assign  db[5] = alu_oe ? db_high[1] : 1'bz;
180
assign  db[4] = alu_oe ? db_high[0] : 1'bz;
181
 
182
 
183
alu_bit_select  b2v_input_bit_select(
184
        .bsel(bsel),
185
        .bs_out_high(SYNTHESIZED_WIRE_1),
186
        .bs_out_low(SYNTHESIZED_WIRE_0));
187
 
188
 
189
alu_shifter_core        b2v_input_shift(
190
        .shift_in(alu_shift_in),
191
        .shift_left(alu_shift_left),
192
        .shift_right(alu_shift_right),
193
        .db(db),
194
        .shift_db0(alu_shift_db0),
195
        .shift_db7(alu_shift_db7),
196
        .out_high(SYNTHESIZED_WIRE_34),
197
        .out_low(SYNTHESIZED_WIRE_33));
198
 
199
 
200
always@(posedge clk)
201
begin
202
if (alu_op_low)
203
        begin
204
        result_lo[3:0] <= result_hi[3:0];
205
        end
206
end
207
 
208
assign  alu_op1 = SYNTHESIZED_WIRE_2 | SYNTHESIZED_WIRE_3;
209
 
210
assign  SYNTHESIZED_WIRE_17 =  ~alu_op_low;
211
 
212
assign  db_low[3] = alu_op2_oe ? op2_low[3] : 1'bz;
213
assign  db_low[2] = alu_op2_oe ? op2_low[2] : 1'bz;
214
assign  db_low[1] = alu_op2_oe ? op2_low[1] : 1'bz;
215
assign  db_low[0] = alu_op2_oe ? op2_low[0] : 1'bz;
216
 
217
assign  db_high[3] = alu_op2_oe ? op2_high[3] : 1'bz;
218
assign  db_high[2] = alu_op2_oe ? op2_high[2] : 1'bz;
219
assign  db_high[1] = alu_op2_oe ? op2_high[1] : 1'bz;
220
assign  db_high[0] = alu_op2_oe ? op2_high[0] : 1'bz;
221
 
222
assign  SYNTHESIZED_WIRE_5 =  ~op2_low;
223
 
224
assign  SYNTHESIZED_WIRE_7 =  ~op2_high;
225
 
226
assign  SYNTHESIZED_WIRE_12 = op2_low & {SYNTHESIZED_WIRE_35,SYNTHESIZED_WIRE_35,SYNTHESIZED_WIRE_35,SYNTHESIZED_WIRE_35};
227
 
228
assign  SYNTHESIZED_WIRE_11 = {alu_sel_op2_neg,alu_sel_op2_neg,alu_sel_op2_neg,alu_sel_op2_neg} & SYNTHESIZED_WIRE_5;
229
 
230
assign  SYNTHESIZED_WIRE_14 = op2_high & {SYNTHESIZED_WIRE_35,SYNTHESIZED_WIRE_35,SYNTHESIZED_WIRE_35,SYNTHESIZED_WIRE_35};
231
 
232
assign  SYNTHESIZED_WIRE_13 = {alu_sel_op2_neg,alu_sel_op2_neg,alu_sel_op2_neg,alu_sel_op2_neg} & SYNTHESIZED_WIRE_7;
233
 
234
assign  SYNTHESIZED_WIRE_16 = SYNTHESIZED_WIRE_8 & {SYNTHESIZED_WIRE_9,SYNTHESIZED_WIRE_9,SYNTHESIZED_WIRE_9,SYNTHESIZED_WIRE_9};
235
 
236
assign  SYNTHESIZED_WIRE_15 = {alu_sel_op2_high,alu_sel_op2_high,alu_sel_op2_high,alu_sel_op2_high} & SYNTHESIZED_WIRE_10;
237
 
238
assign  SYNTHESIZED_WIRE_8 = SYNTHESIZED_WIRE_11 | SYNTHESIZED_WIRE_12;
239
 
240
assign  SYNTHESIZED_WIRE_10 = SYNTHESIZED_WIRE_13 | SYNTHESIZED_WIRE_14;
241
 
242
assign  alu_op2 = SYNTHESIZED_WIRE_15 | SYNTHESIZED_WIRE_16;
243
 
244
assign  SYNTHESIZED_WIRE_35 =  ~alu_sel_op2_neg;
245
 
246
assign  SYNTHESIZED_WIRE_9 =  ~alu_sel_op2_high;
247
 
248
assign  db_low[3] = alu_res_oe ? result_lo[3] : 1'bz;
249
assign  db_low[2] = alu_res_oe ? result_lo[2] : 1'bz;
250
assign  db_low[1] = alu_res_oe ? result_lo[1] : 1'bz;
251
assign  db_low[0] = alu_res_oe ? result_lo[0] : 1'bz;
252
 
253
assign  db_high[3] = alu_res_oe ? result_hi[3] : 1'bz;
254
assign  db_high[2] = alu_res_oe ? result_hi[2] : 1'bz;
255
assign  db_high[1] = alu_res_oe ? result_hi[1] : 1'bz;
256
assign  db_high[0] = alu_res_oe ? result_hi[0] : 1'bz;
257
 
258
assign  SYNTHESIZED_WIRE_3 = op1_low & {alu_op_low,alu_op_low,alu_op_low,alu_op_low};
259
 
260
assign  SYNTHESIZED_WIRE_2 = {SYNTHESIZED_WIRE_17,SYNTHESIZED_WIRE_17,SYNTHESIZED_WIRE_17,SYNTHESIZED_WIRE_17} & op1_high;
261
 
262
 
263
always@(posedge SYNTHESIZED_WIRE_36)
264
begin
265
if (SYNTHESIZED_WIRE_20)
266
        begin
267
        op1_high[3:0] <= SYNTHESIZED_WIRE_18[3:0];
268
        end
269
end
270
 
271
 
272
always@(posedge SYNTHESIZED_WIRE_36)
273
begin
274
if (SYNTHESIZED_WIRE_23)
275
        begin
276
        op1_low[3:0] <= SYNTHESIZED_WIRE_21[3:0];
277
        end
278
end
279
 
280
 
281
always@(posedge SYNTHESIZED_WIRE_37)
282
begin
283
if (SYNTHESIZED_WIRE_26)
284
        begin
285
        op2_high[3:0] <= SYNTHESIZED_WIRE_24[3:0];
286
        end
287
end
288
 
289
 
290
always@(posedge SYNTHESIZED_WIRE_37)
291
begin
292
if (SYNTHESIZED_WIRE_29)
293
        begin
294
        op2_low[3:0] <= SYNTHESIZED_WIRE_27[3:0];
295
        end
296
end
297
 
298
assign  db_low[3] = alu_op1_oe ? op1_low[3] : 1'bz;
299
assign  db_low[2] = alu_op1_oe ? op1_low[2] : 1'bz;
300
assign  db_low[1] = alu_op1_oe ? op1_low[1] : 1'bz;
301
assign  db_low[0] = alu_op1_oe ? op1_low[0] : 1'bz;
302
 
303
assign  db_high[3] = alu_op1_oe ? op1_high[3] : 1'bz;
304
assign  db_high[2] = alu_op1_oe ? op1_high[2] : 1'bz;
305
assign  db_high[1] = alu_op1_oe ? op1_high[1] : 1'bz;
306
assign  db_high[0] = alu_op1_oe ? op1_high[0] : 1'bz;
307
 
308
assign  SYNTHESIZED_WIRE_36 =  ~clk;
309
 
310
assign  SYNTHESIZED_WIRE_37 =  ~clk;
311
 
312
 
313
alu_mux_2z      b2v_op1_latch_mux_high(
314
        .sel_a(alu_op1_sel_bus),
315
        .sel_zero(alu_op1_sel_zero),
316
        .a(db_high),
317
        .ena(SYNTHESIZED_WIRE_20),
318
        .Q(SYNTHESIZED_WIRE_18));
319
 
320
 
321
alu_mux_3z      b2v_op1_latch_mux_low(
322
        .sel_a(alu_op1_sel_bus),
323
        .sel_b(alu_op1_sel_low),
324
        .sel_zero(alu_op1_sel_zero),
325
        .a(db_low),
326
        .b(db_high),
327
        .ena(SYNTHESIZED_WIRE_23),
328
        .Q(SYNTHESIZED_WIRE_21));
329
 
330
 
331
alu_mux_3z      b2v_op2_latch_mux_high(
332
        .sel_a(alu_op2_sel_bus),
333
        .sel_b(alu_op2_sel_lq),
334
        .sel_zero(alu_op2_sel_zero),
335
        .a(db_high),
336
        .b(db_low),
337
        .ena(SYNTHESIZED_WIRE_26),
338
        .Q(SYNTHESIZED_WIRE_24));
339
 
340
 
341
alu_mux_3z      b2v_op2_latch_mux_low(
342
        .sel_a(alu_op2_sel_bus),
343
        .sel_b(alu_op2_sel_lq),
344
        .sel_zero(alu_op2_sel_zero),
345
        .a(db_low),
346
        .b(alu_op1),
347
        .ena(SYNTHESIZED_WIRE_29),
348
        .Q(SYNTHESIZED_WIRE_27));
349
 
350
assign  alu_parity_out = SYNTHESIZED_WIRE_30 ^ result_hi[0];
351
 
352
assign  SYNTHESIZED_WIRE_30 = SYNTHESIZED_WIRE_31 ^ result_hi[1];
353
 
354
assign  SYNTHESIZED_WIRE_31 = SYNTHESIZED_WIRE_32 ^ result_hi[2];
355
 
356
assign  SYNTHESIZED_WIRE_32 = alu_parity_in ^ result_hi[3];
357
 
358
 
359
alu_prep_daa    b2v_prep_daa(
360
        .high(op1_high),
361
        .low(op1_low),
362
        .low_gt_9(alu_low_gt_9),
363
        .high_gt_9(alu_high_gt_9),
364
        .high_eq_9(alu_high_eq_9));
365
 
366
assign  db_low[3] = alu_shift_oe ? SYNTHESIZED_WIRE_33[3] : 1'bz;
367
assign  db_low[2] = alu_shift_oe ? SYNTHESIZED_WIRE_33[2] : 1'bz;
368
assign  db_low[1] = alu_shift_oe ? SYNTHESIZED_WIRE_33[1] : 1'bz;
369
assign  db_low[0] = alu_shift_oe ? SYNTHESIZED_WIRE_33[0] : 1'bz;
370
 
371
assign  db_high[3] = alu_shift_oe ? SYNTHESIZED_WIRE_34[3] : 1'bz;
372
assign  db_high[2] = alu_shift_oe ? SYNTHESIZED_WIRE_34[2] : 1'bz;
373
assign  db_high[1] = alu_shift_oe ? SYNTHESIZED_WIRE_34[1] : 1'bz;
374
assign  db_high[0] = alu_shift_oe ? SYNTHESIZED_WIRE_34[0] : 1'bz;
375
 
376
assign  alu_zero = ~(db_low[2] | db_low[1] | db_low[3] | db_high[1] | db_high[0] | db_high[2] | db_low[0] | db_high[3]);
377
 
378
assign  alu_sf_out = db_high[3];
379
assign  alu_yf_out = db_high[1];
380
assign  alu_xf_out = db_low[3];
381
assign  test_db_high = db_high;
382
assign  test_db_low = db_low;
383
 
384
endmodule

powered by: WebSVN 2.1.0

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