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

Subversion Repositories or1k

[/] [or1k/] [branches/] [mp3_stable/] [mp3/] [lib/] [xilinx/] [coregen/] [XilinxCoreLib/] [C_COUNTER_BINARY_V3_0.v] - Blame information for rev 1765

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 266 lampret
/* $Id: C_COUNTER_BINARY_V3_0.v,v 1.1.1.1 2001-11-04 19:00:05 lampret Exp $
2
--
3
-- Filename - C_COUNTER_BINARY_V3_0.v
4
-- Author - Xilinx
5
-- Creation -14 July 1999
6
--
7
-- Description - This file contains the Verilog behavior for the Baseblocks C_COUNTER_BINARY_V3_0 module
8
*/
9
 
10
`ifdef C_COUNTER_BINARY_V3_0_DEF
11
`else
12
`define C_COUNTER_BINARY_V3_0_DEF
13
 
14
`ifdef C_ADDSUB_V3_0_DEF
15
`else
16
`include "XilinxCoreLib/C_ADDSUB_V3_0.v"
17
`endif
18
 
19
`ifdef C_COMPARE_V3_0_DEF
20
`else
21
`include "XilinxCoreLib/C_COMPARE_V3_0.v"
22
`endif
23
 
24
`ifdef C_MUX_BUS_V3_0_DEF
25
`else
26
`include "XilinxCoreLib/C_MUX_BUS_V3_0.v"
27
`endif
28
 
29
`define c_set 0
30
`define c_clear 1
31
`define c_override 0
32
`define c_no_override 1
33
`define c_signed 0
34
`define c_unsigned 1
35
`define c_pin 2
36
`define c_up 0
37
`define c_down 1
38
`define c_updown 2
39
`define allXs {C_WIDTH{1'bx}}
40
 
41
module C_COUNTER_BINARY_V3_0 (CLK, UP, CE, LOAD, L, IV, ACLR, ASET, AINIT, SCLR, SSET, SINIT, THRESH0, Q_THRESH0, THRESH1, Q_THRESH1, Q);
42
 
43
        parameter C_AINIT_VAL           = "0";
44
        parameter C_COUNT_BY            = "";
45
        parameter C_COUNT_MODE          = `c_up;
46
        parameter C_COUNT_TO            = "1111111111111111";
47
        parameter C_ENABLE_RLOCS        = 1;
48
        parameter C_HAS_ACLR            = 0;
49
        parameter C_HAS_AINIT           = 0;
50
        parameter C_HAS_ASET            = 0;
51
        parameter C_HAS_CE              = 0;
52
        parameter C_HAS_IV              = 0;
53
        parameter C_HAS_L               = 0;
54
        parameter C_HAS_LOAD            = 0;
55
        parameter C_HAS_Q_THRESH0       = 0;
56
        parameter C_HAS_Q_THRESH1       = 0;
57
        parameter C_HAS_SCLR            = 0;
58
        parameter C_HAS_SINIT           = 0;
59
        parameter C_HAS_SSET            = 0;
60
        parameter C_HAS_THRESH0         = 0;
61
        parameter C_HAS_THRESH1         = 0;
62
        parameter C_HAS_UP              = 0;
63
        parameter C_LOAD_ENABLE         = `c_no_override;
64
        parameter C_LOAD_LOW            = 0;
65
        parameter C_PIPE_STAGES         = 0;
66
        parameter C_RESTRICT_COUNT      = 0;
67
        parameter C_SINIT_VAL           = "0";
68
        parameter C_SYNC_ENABLE         = `c_override;
69
        parameter C_SYNC_PRIORITY       = `c_clear;
70
        parameter C_THRESH0_VALUE       = "1111111111111111";
71
        parameter C_THRESH1_VALUE       = "1111111111111111";
72
        parameter C_THRESH_EARLY        = 1;
73
        parameter C_WIDTH               = 16;
74
 
75
        parameter C_OUT_TYPE            = `c_signed;
76
        parameter adder_HAS_SCLR = ((C_RESTRICT_COUNT == 1) || (C_HAS_SCLR == 1) ? 1 : 0);
77
 
78
        parameter iaxero = {62{"0"}};
79
        parameter iextendC_THRESH0_VALUE = {iaxero,C_THRESH0_VALUE};
80
        parameter iextendC_THRESH1_VALUE = {iaxero,C_THRESH1_VALUE};
81
        parameter iazero = {64{"0"}};
82
        parameter intC_HAS_SCLR0 = (iextendC_THRESH0_VALUE[0] == "0" ? (iextendC_THRESH0_VALUE[1] == "0" ?
83
                                        (iextendC_THRESH0_VALUE[2] == "0" ? (iextendC_THRESH0_VALUE[3] == "0" ?
84
                                        (iextendC_THRESH0_VALUE[4] == "0" ? (iextendC_THRESH0_VALUE[5] == "0" ?
85
                                        (iextendC_THRESH0_VALUE[6] == "0" ? (iextendC_THRESH0_VALUE[7] == "0" ?
86
                                        (iextendC_THRESH0_VALUE[8] == "0" ? (iextendC_THRESH0_VALUE[9] == "0" ?
87
                                        (iextendC_THRESH0_VALUE[10] == "0" ? (iextendC_THRESH0_VALUE[11] == "0" ?
88
                                        (iextendC_THRESH0_VALUE[12] == "0" ? (iextendC_THRESH0_VALUE[13] == "0" ?
89
                                        (iextendC_THRESH0_VALUE[14] == "0" ? (iextendC_THRESH0_VALUE[15] == "0" ?
90
                                        (iextendC_THRESH0_VALUE[16] == "0" ? (iextendC_THRESH0_VALUE[17] == "0" ?
91
                                        (iextendC_THRESH0_VALUE[18] == "0" ? (iextendC_THRESH0_VALUE[19] == "0" ?
92
                                        (iextendC_THRESH0_VALUE[20] == "0" ? (iextendC_THRESH0_VALUE[21] == "0" ?
93
                                        (iextendC_THRESH0_VALUE[22] == "0" ? (iextendC_THRESH0_VALUE[23] == "0" ?
94
                                        (iextendC_THRESH0_VALUE[24] == "0" ? (iextendC_THRESH0_VALUE[25] == "0" ?
95
                                        (iextendC_THRESH0_VALUE[26] == "0" ? (iextendC_THRESH0_VALUE[27] == "0" ?
96
                                        (iextendC_THRESH0_VALUE[28] == "0" ? (iextendC_THRESH0_VALUE[29] == "0" ?
97
                                        (iextendC_THRESH0_VALUE[30] == "0" ? (iextendC_THRESH0_VALUE[31] == "0" ?
98
                                        (iextendC_THRESH0_VALUE[32] == "0" ? (iextendC_THRESH0_VALUE[33] == "0" ?
99
                                        (iextendC_THRESH0_VALUE[34] == "0" ? (iextendC_THRESH0_VALUE[35] == "0" ?
100
                                        (iextendC_THRESH0_VALUE[36] == "0" ? (iextendC_THRESH0_VALUE[37] == "0" ?
101
                                        (iextendC_THRESH0_VALUE[38] == "0" ? (iextendC_THRESH0_VALUE[39] == "0" ?
102
                                        (iextendC_THRESH0_VALUE[40] == "0" ? (iextendC_THRESH0_VALUE[41] == "0" ?
103
                                        (iextendC_THRESH0_VALUE[42] == "0" ? (iextendC_THRESH0_VALUE[43] == "0" ?
104
                                        (iextendC_THRESH0_VALUE[44] == "0" ? (iextendC_THRESH0_VALUE[45] == "0" ?
105
                                        (iextendC_THRESH0_VALUE[46] == "0" ? (iextendC_THRESH0_VALUE[47] == "0" ?
106
                                        (iextendC_THRESH0_VALUE[48] == "0" ? (iextendC_THRESH0_VALUE[49] == "0" ?
107
                                        (iextendC_THRESH0_VALUE[50] == "0" ? (iextendC_THRESH0_VALUE[51] == "0" ?
108
                                        (iextendC_THRESH0_VALUE[52] == "0" ? (iextendC_THRESH0_VALUE[53] == "0" ?
109
                                        (iextendC_THRESH0_VALUE[54] == "0" ? (iextendC_THRESH0_VALUE[55] == "0" ?
110
                                        (iextendC_THRESH0_VALUE[56] == "0" ? (iextendC_THRESH0_VALUE[57] == "0" ?
111
                                        (iextendC_THRESH0_VALUE[58] == "0" ? (iextendC_THRESH0_VALUE[59] == "0" ?
112
                                        (iextendC_THRESH0_VALUE[60] == "0" ? (iextendC_THRESH0_VALUE[61] == "0" ?
113
                                        (iextendC_THRESH0_VALUE[62] == "0" ? (iextendC_THRESH0_VALUE[63] == "0" ? 0
114
                                        : (C_HAS_SCLR == 1 ? 1 : 0)) : (C_HAS_SCLR == 1 ? 1 : 0)) : (C_HAS_SCLR == 1 ? 1 : 0))
115
                                        : (C_HAS_SCLR == 1 ? 1 : 0)) : (C_HAS_SCLR == 1 ? 1 : 0)) : (C_HAS_SCLR == 1 ? 1 : 0))
116
                                        : (C_HAS_SCLR == 1 ? 1 : 0)) : (C_HAS_SCLR == 1 ? 1 : 0)) : (C_HAS_SCLR == 1 ? 1 : 0))
117
                                        : (C_HAS_SCLR == 1 ? 1 : 0)) : (C_HAS_SCLR == 1 ? 1 : 0)) : (C_HAS_SCLR == 1 ? 1 : 0))
118
                                        : (C_HAS_SCLR == 1 ? 1 : 0)) : (C_HAS_SCLR == 1 ? 1 : 0)) : (C_HAS_SCLR == 1 ? 1 : 0))
119
                                        : (C_HAS_SCLR == 1 ? 1 : 0)) : (C_HAS_SCLR == 1 ? 1 : 0)) : (C_HAS_SCLR == 1 ? 1 : 0))
120
                                        : (C_HAS_SCLR == 1 ? 1 : 0)) : (C_HAS_SCLR == 1 ? 1 : 0)) : (C_HAS_SCLR == 1 ? 1 : 0))
121
                                        : (C_HAS_SCLR == 1 ? 1 : 0)) : (C_HAS_SCLR == 1 ? 1 : 0)) : (C_HAS_SCLR == 1 ? 1 : 0))
122
                                        : (C_HAS_SCLR == 1 ? 1 : 0)) : (C_HAS_SCLR == 1 ? 1 : 0)) : (C_HAS_SCLR == 1 ? 1 : 0))
123
                                        : (C_HAS_SCLR == 1 ? 1 : 0)) : (C_HAS_SCLR == 1 ? 1 : 0)) : (C_HAS_SCLR == 1 ? 1 : 0))
124
                                        : (C_HAS_SCLR == 1 ? 1 : 0)) : (C_HAS_SCLR == 1 ? 1 : 0)) : (C_HAS_SCLR == 1 ? 1 : 0))
125
                                        : (C_HAS_SCLR == 1 ? 1 : 0)) : (C_HAS_SCLR == 1 ? 1 : 0)) : (C_HAS_SCLR == 1 ? 1 : 0))
126
                                        : (C_HAS_SCLR == 1 ? 1 : 0)) : (C_HAS_SCLR == 1 ? 1 : 0)) : (C_HAS_SCLR == 1 ? 1 : 0))
127
                                        : (C_HAS_SCLR == 1 ? 1 : 0)) : (C_HAS_SCLR == 1 ? 1 : 0)) : (C_HAS_SCLR == 1 ? 1 : 0))
128
                                        : (C_HAS_SCLR == 1 ? 1 : 0)) : (C_HAS_SCLR == 1 ? 1 : 0)) : (C_HAS_SCLR == 1 ? 1 : 0))
129
                                        : (C_HAS_SCLR == 1 ? 1 : 0)) : (C_HAS_SCLR == 1 ? 1 : 0)) : (C_HAS_SCLR == 1 ? 1 : 0))
130
                                        : (C_HAS_SCLR == 1 ? 1 : 0)) : (C_HAS_SCLR == 1 ? 1 : 0)) : (C_HAS_SCLR == 1 ? 1 : 0))
131
                                        : (C_HAS_SCLR == 1 ? 1 : 0)) : (C_HAS_SCLR == 1 ? 1 : 0)) : (C_HAS_SCLR == 1 ? 1 : 0))
132
                                        : (C_HAS_SCLR == 1 ? 1 : 0)) : (C_HAS_SCLR == 1 ? 1 : 0)) : (C_HAS_SCLR == 1 ? 1 : 0))
133
                                        : (C_HAS_SCLR == 1 ? 1 : 0)) : (C_HAS_SCLR == 1 ? 1 : 0)) : (C_HAS_SCLR == 1 ? 1 : 0))
134
                                        : (C_HAS_SCLR == 1 ? 1 : 0)) : (C_HAS_SCLR == 1 ? 1 : 0)) : (C_HAS_SCLR == 1 ? 1 : 0))
135
                                        : (C_HAS_SCLR == 1 ? 1 : 0));
136
        parameter intC_HAS_SCLR1 = (iextendC_THRESH1_VALUE[0] == "0" ? (iextendC_THRESH1_VALUE[1] == "0" ?
137
                                        (iextendC_THRESH1_VALUE[2] == "0" ? (iextendC_THRESH1_VALUE[3] == "0" ?
138
                                        (iextendC_THRESH1_VALUE[4] == "0" ? (iextendC_THRESH1_VALUE[5] == "0" ?
139
                                        (iextendC_THRESH1_VALUE[6] == "0" ? (iextendC_THRESH1_VALUE[7] == "0" ?
140
                                        (iextendC_THRESH1_VALUE[8] == "0" ? (iextendC_THRESH1_VALUE[9] == "0" ?
141
                                        (iextendC_THRESH1_VALUE[10] == "0" ? (iextendC_THRESH1_VALUE[11] == "0" ?
142
                                        (iextendC_THRESH1_VALUE[12] == "0" ? (iextendC_THRESH1_VALUE[13] == "0" ?
143
                                        (iextendC_THRESH1_VALUE[14] == "0" ? (iextendC_THRESH1_VALUE[15] == "0" ?
144
                                        (iextendC_THRESH1_VALUE[16] == "0" ? (iextendC_THRESH1_VALUE[17] == "0" ?
145
                                        (iextendC_THRESH1_VALUE[18] == "0" ? (iextendC_THRESH1_VALUE[19] == "0" ?
146
                                        (iextendC_THRESH1_VALUE[20] == "0" ? (iextendC_THRESH1_VALUE[21] == "0" ?
147
                                        (iextendC_THRESH1_VALUE[22] == "0" ? (iextendC_THRESH1_VALUE[23] == "0" ?
148
                                        (iextendC_THRESH1_VALUE[24] == "0" ? (iextendC_THRESH1_VALUE[25] == "0" ?
149
                                        (iextendC_THRESH1_VALUE[26] == "0" ? (iextendC_THRESH1_VALUE[27] == "0" ?
150
                                        (iextendC_THRESH1_VALUE[28] == "0" ? (iextendC_THRESH1_VALUE[29] == "0" ?
151
                                        (iextendC_THRESH1_VALUE[30] == "0" ? (iextendC_THRESH1_VALUE[31] == "0" ?
152
                                        (iextendC_THRESH1_VALUE[32] == "0" ? (iextendC_THRESH1_VALUE[33] == "0" ?
153
                                        (iextendC_THRESH1_VALUE[34] == "0" ? (iextendC_THRESH1_VALUE[35] == "0" ?
154
                                        (iextendC_THRESH1_VALUE[36] == "0" ? (iextendC_THRESH1_VALUE[37] == "0" ?
155
                                        (iextendC_THRESH1_VALUE[38] == "0" ? (iextendC_THRESH1_VALUE[39] == "0" ?
156
                                        (iextendC_THRESH1_VALUE[40] == "0" ? (iextendC_THRESH1_VALUE[41] == "0" ?
157
                                        (iextendC_THRESH1_VALUE[42] == "0" ? (iextendC_THRESH1_VALUE[43] == "0" ?
158
                                        (iextendC_THRESH1_VALUE[44] == "0" ? (iextendC_THRESH1_VALUE[45] == "0" ?
159
                                        (iextendC_THRESH1_VALUE[46] == "0" ? (iextendC_THRESH1_VALUE[47] == "0" ?
160
                                        (iextendC_THRESH1_VALUE[48] == "0" ? (iextendC_THRESH1_VALUE[49] == "0" ?
161
                                        (iextendC_THRESH1_VALUE[50] == "0" ? (iextendC_THRESH1_VALUE[51] == "0" ?
162
                                        (iextendC_THRESH1_VALUE[52] == "0" ? (iextendC_THRESH1_VALUE[53] == "0" ?
163
                                        (iextendC_THRESH1_VALUE[54] == "0" ? (iextendC_THRESH1_VALUE[55] == "0" ?
164
                                        (iextendC_THRESH1_VALUE[56] == "0" ? (iextendC_THRESH1_VALUE[57] == "0" ?
165
                                        (iextendC_THRESH1_VALUE[58] == "0" ? (iextendC_THRESH1_VALUE[59] == "0" ?
166
                                        (iextendC_THRESH1_VALUE[60] == "0" ? (iextendC_THRESH1_VALUE[61] == "0" ?
167
                                        (iextendC_THRESH1_VALUE[62] == "0" ? (iextendC_THRESH1_VALUE[63] == "0" ? 0
168
                                        : (C_HAS_SCLR == 1 ? 1 : 0)) : (C_HAS_SCLR == 1 ? 1 : 0)) : (C_HAS_SCLR == 1 ? 1 : 0))
169
                                        : (C_HAS_SCLR == 1 ? 1 : 0)) : (C_HAS_SCLR == 1 ? 1 : 0)) : (C_HAS_SCLR == 1 ? 1 : 0))
170
                                        : (C_HAS_SCLR == 1 ? 1 : 0)) : (C_HAS_SCLR == 1 ? 1 : 0)) : (C_HAS_SCLR == 1 ? 1 : 0))
171
                                        : (C_HAS_SCLR == 1 ? 1 : 0)) : (C_HAS_SCLR == 1 ? 1 : 0)) : (C_HAS_SCLR == 1 ? 1 : 0))
172
                                        : (C_HAS_SCLR == 1 ? 1 : 0)) : (C_HAS_SCLR == 1 ? 1 : 0)) : (C_HAS_SCLR == 1 ? 1 : 0))
173
                                        : (C_HAS_SCLR == 1 ? 1 : 0)) : (C_HAS_SCLR == 1 ? 1 : 0)) : (C_HAS_SCLR == 1 ? 1 : 0))
174
                                        : (C_HAS_SCLR == 1 ? 1 : 0)) : (C_HAS_SCLR == 1 ? 1 : 0)) : (C_HAS_SCLR == 1 ? 1 : 0))
175
                                        : (C_HAS_SCLR == 1 ? 1 : 0)) : (C_HAS_SCLR == 1 ? 1 : 0)) : (C_HAS_SCLR == 1 ? 1 : 0))
176
                                        : (C_HAS_SCLR == 1 ? 1 : 0)) : (C_HAS_SCLR == 1 ? 1 : 0)) : (C_HAS_SCLR == 1 ? 1 : 0))
177
                                        : (C_HAS_SCLR == 1 ? 1 : 0)) : (C_HAS_SCLR == 1 ? 1 : 0)) : (C_HAS_SCLR == 1 ? 1 : 0))
178
                                        : (C_HAS_SCLR == 1 ? 1 : 0)) : (C_HAS_SCLR == 1 ? 1 : 0)) : (C_HAS_SCLR == 1 ? 1 : 0))
179
                                        : (C_HAS_SCLR == 1 ? 1 : 0)) : (C_HAS_SCLR == 1 ? 1 : 0)) : (C_HAS_SCLR == 1 ? 1 : 0))
180
                                        : (C_HAS_SCLR == 1 ? 1 : 0)) : (C_HAS_SCLR == 1 ? 1 : 0)) : (C_HAS_SCLR == 1 ? 1 : 0))
181
                                        : (C_HAS_SCLR == 1 ? 1 : 0)) : (C_HAS_SCLR == 1 ? 1 : 0)) : (C_HAS_SCLR == 1 ? 1 : 0))
182
                                        : (C_HAS_SCLR == 1 ? 1 : 0)) : (C_HAS_SCLR == 1 ? 1 : 0)) : (C_HAS_SCLR == 1 ? 1 : 0))
183
                                        : (C_HAS_SCLR == 1 ? 1 : 0)) : (C_HAS_SCLR == 1 ? 1 : 0)) : (C_HAS_SCLR == 1 ? 1 : 0))
184
                                        : (C_HAS_SCLR == 1 ? 1 : 0)) : (C_HAS_SCLR == 1 ? 1 : 0)) : (C_HAS_SCLR == 1 ? 1 : 0))
185
                                        : (C_HAS_SCLR == 1 ? 1 : 0)) : (C_HAS_SCLR == 1 ? 1 : 0)) : (C_HAS_SCLR == 1 ? 1 : 0))
186
                                        : (C_HAS_SCLR == 1 ? 1 : 0)) : (C_HAS_SCLR == 1 ? 1 : 0)) : (C_HAS_SCLR == 1 ? 1 : 0))
187
                                        : (C_HAS_SCLR == 1 ? 1 : 0)) : (C_HAS_SCLR == 1 ? 1 : 0)) : (C_HAS_SCLR == 1 ? 1 : 0))
188
                                        : (C_HAS_SCLR == 1 ? 1 : 0)) : (C_HAS_SCLR == 1 ? 1 : 0)) : (C_HAS_SCLR == 1 ? 1 : 0))
189
                                        : (C_HAS_SCLR == 1 ? 1 : 0));
190
 
191
 
192
 
193
 
194
 
195
        input CLK;
196
        input UP;
197
        input CE;
198
        input LOAD;
199
        input [C_WIDTH-1 : 0] L;
200
        input [C_WIDTH-1 : 0] IV;
201
        input ACLR;
202
        input ASET;
203
        input AINIT;
204
        input SCLR;
205
        input SSET;
206
        input SINIT;
207
        output THRESH0;
208
        output Q_THRESH0;
209
        output THRESH1;
210
        output Q_THRESH1;
211
        output [C_WIDTH-1 : 0] Q;
212
 
213
        // Internal values to drive signals when input is missing
214
        wire intUP;
215
        wire intUPbar = ~intUP;
216
        wire intCE;
217
        wire intLOAD;
218
        wire [C_WIDTH-1 : 0] intL;
219
        wire [C_WIDTH-1 : 0] intB;
220
        wire [C_WIDTH-1 : 0] all_zeros = {C_WIDTH{1'b0}};
221
        wire intSCLR;
222
        wire intCount_to_reached;
223
        reg intTHRESH0;
224
        reg intTHRESH1;
225
        wire intQ_THRESH0;
226
        wire intQ_THRESH1;
227
        wire [C_WIDTH-1 : 0] intFBq;
228
        wire [C_WIDTH-1 : 0] intFBs;
229
        wire [C_WIDTH-1 : 0] intQ = intFBq;
230
        wire [C_WIDTH-1 : 0] intFBq_or_zero;
231
        wire [C_WIDTH-1 : 0] intFBs_or_q;
232
        wire [C_WIDTH-1 : 0] intCount_by = to_bits(C_COUNT_BY);
233
        wire [C_WIDTH-1 : 0] intB_or_load;
234
        wire [C_WIDTH-1 : 0] tmpintB_or_load;
235
 
236
        wire Q_THRESH0 = (C_HAS_Q_THRESH0 == 1 ? intQ_THRESH0 : 1'bx);
237
        wire Q_THRESH1 = (C_HAS_Q_THRESH1 == 1 ? intQ_THRESH1 : 1'bx);
238
        wire [C_WIDTH-1 : 0] Q = intQ;
239
 
240
        wire [C_WIDTH-1 : 0] intXLOADMUX;
241
        wire [C_WIDTH-1 : 0] intSINITVAL = to_bits(C_SINIT_VAL);
242
        wire [C_WIDTH-1 : 0] intXL;
243
        wire intXLOAD;
244
        wire intXXLOAD;
245
        wire #5 intSCLR_RESET = (intSCLR || (intCount_to_reached && intCE && C_RESTRICT_COUNT == 1)) && ~intXXLOAD;
246
 
247
        // Sort out default values for missing ports
248
 
249
        assign intUP = (C_HAS_UP == 1 ? UP : (C_COUNT_MODE == `c_up ? 1'b1 : 1'b0));
250
        assign intCE = defval(CE, C_HAS_CE, 1);
251
        assign intL = (C_HAS_L == 1 ? L : {C_WIDTH{1'b0}});
252
        assign intB = (C_HAS_IV == 1 ? IV : intCount_by);
253
        assign intXL = (C_RESTRICT_COUNT == 1 ? (C_HAS_SINIT == 1 ? (C_HAS_LOAD == 1 ? intXLOADMUX : intSINITVAL) : intL) : intL);
254
        assign intLOAD = (C_LOAD_LOW == 1 ? ~LOAD : LOAD );
255
        assign intXLOAD = (C_RESTRICT_COUNT == 1 ? (C_HAS_SINIT == 1 ? (C_HAS_LOAD == 1 ? (C_HAS_CE == 1 ? (C_SYNC_ENABLE != C_LOAD_ENABLE ? (C_SYNC_ENABLE == 0 ? (C_LOAD_LOW == 1 ? (((~SINIT) && (~CE)) || ((~SINIT) && LOAD && CE)) : (SINIT || (LOAD && CE))) : (C_LOAD_LOW == 1 ? ((LOAD && (~CE)) || ((~SINIT) && LOAD && CE)) : (LOAD || (SINIT && CE)))) : (C_LOAD_LOW == 1 ? LOAD && ~SINIT : LOAD || SINIT)) : (C_LOAD_LOW == 1 ? LOAD && ~SINIT : LOAD || SINIT)) : (C_LOAD_LOW ? ~SINIT : SINIT)) : (C_HAS_LOAD == 1 ? LOAD : 1'b0)) : (C_HAS_LOAD == 1 ? LOAD : 1'b0));
256
        assign intXXLOAD = (C_RESTRICT_COUNT == 1 ? (C_HAS_SINIT == 1 ? (C_HAS_LOAD == 1 ? (C_LOAD_LOW == 1 ? ~intXLOAD : intXLOAD) : (C_LOAD_LOW == 1 ? ~intXLOAD : intXLOAD)) : (C_HAS_LOAD == 1 ? intLOAD : 1'b0)) : (C_HAS_LOAD == 1 ? intLOAD : 1'b0));
257
        assign intSCLR = defval(SCLR, C_HAS_SCLR, 0);
258
        assign intB_or_load = (C_HAS_LOAD == 1 ? tmpintB_or_load : (C_RESTRICT_COUNT == 1 ? (C_HAS_SINIT == 1 ? tmpintB_or_load : intB) : intB));
259
        assign intFBs_or_q = (C_THRESH_EARLY == 1 ? intFBs : intFBq);
260
 
261
 
262
        // The addsub on which this is based...
263
 
264
        C_ADDSUB_V3_0 #(C_COUNT_MODE,
265
                                        C_AINIT_VAL,
266
                                        C_OUT_TYPE,
267
                                        C_WIDTH,
268
                                        (((~(C_HAS_LOAD===1)) || C_LOAD_ENABLE) && (C_SYNC_ENABLE || ~(C_RESTRICT_COUNT && C_HAS_SINIT))),
269
                                        C_LOAD_LOW,     // DLUNN CHANGED FROM 0, 
270
                                        0,
271
                                        C_OUT_TYPE,
272
                                        "",
273
                                        C_WIDTH,
274
                                        C_ENABLE_RLOCS,
275
                                        C_HAS_ACLR,
276
                                        C_HAS_UP,
277
                                        C_HAS_AINIT,
278
                                        C_HAS_ASET,
279
                                        0,
280
                                        C_HAS_LOAD || (C_RESTRICT_COUNT == 1 && C_HAS_SINIT == 1),      // DLUNN CHANGED FROM 1, 
281
                                        0,
282
                                        0,
283
                                        0,
284
                                        C_HAS_CE,
285
                                        1,
286
                                        0,
287
                                        0,
288
                                        1,
289
                                        0,
290
                                        0,
291
                                        0,
292
                                        1,
293
                                        adder_HAS_SCLR,
294
                                        C_HAS_SINIT && ~(C_RESTRICT_COUNT === 1),
295
                                        C_HAS_SSET,
296
                                        C_WIDTH-1,
297
                                        1,
298
                                        0,
299
                                        C_WIDTH,
300
                                        C_PIPE_STAGES,
301
                                        C_SINIT_VAL,
302
                                        C_SYNC_ENABLE,
303
                                        C_SYNC_PRIORITY)
304
                the_addsub (.A(intFBq_or_zero), .B(intB_or_load), .CLK(CLK), .ADD(intUP),
305
                                        .CE(CE), .C_IN(intUPbar), .ACLR(ACLR), .ASET(ASET),
306
                                        .AINIT(AINIT), .SCLR(intSCLR_RESET), .SSET(SSET),
307
                                        .SINIT(SINIT), .BYPASS(intXLOAD), .S(intFBs), .Q(intFBq));
308
 
309
        // The Restrict Count/Sinit LOAD mux
310
 
311
        C_MUX_BUS_V3_0 #("", C_ENABLE_RLOCS, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 2,
312
                                         0, 0, 1, "", 0, 0, C_WIDTH)
313
                        mxRCSL(.MA(intSINITVAL), .MB(intL), .S(intLOAD), .O(intXLOADMUX));
314
 
315
        // The feedback mux
316
 
317
        C_MUX_BUS_V3_0 #("", C_ENABLE_RLOCS, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 2,
318
                                         0, 0, 1, "", 0, 0, C_WIDTH)
319
                        mxfb(.MA(intFBq), .MB(all_zeros), .S(intXXLOAD), .O(intFBq_or_zero));
320
 
321
        // The LOAD mux
322
 
323
        C_MUX_BUS_V3_0 #("", C_ENABLE_RLOCS, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 2,
324
                                         0, 0, 1, "", 0, 0, C_WIDTH)
325
                        mx1(.MA(intB), .MB(intXL), .S(intXXLOAD), .O(tmpintB_or_load));
326
 
327
        // The Threshhold comparators
328
 
329
        C_COMPARE_V3_0 #("0", 1, C_THRESH0_VALUE, C_OUT_TYPE, C_ENABLE_RLOCS, C_HAS_ACLR, 0,
330
                                         C_HAS_THRESH0, 0, 0, 0, 0, 0, C_HAS_CE, C_HAS_Q_THRESH0,
331
                                         0, 0, 0, 0, 0, intC_HAS_SCLR0, 0, 0, 0, 0, C_WIDTH)
332
                        th0(.A(intFBs_or_q), .CLK(CLK), .CE(CE), .ACLR(ACLR), .SCLR(intSCLR_RESET), .A_EQ_B(THRESH0), .QA_EQ_B(Q_THRESH0));
333
 
334
        C_COMPARE_V3_0 #("0", 1, C_THRESH1_VALUE, C_OUT_TYPE, C_ENABLE_RLOCS, C_HAS_ACLR, 0,
335
                                         C_HAS_THRESH1, 0, 0, 0, 0, 0, C_HAS_CE, C_HAS_Q_THRESH1,
336
                                         0, 0, 0, 0, 0, intC_HAS_SCLR1, 0, 0, 0, 0, C_WIDTH)
337
                        th1(.A(intFBs_or_q), .CLK(CLK), .CE(CE), .ACLR(ACLR), .SCLR(intSCLR_RESET), .A_EQ_B(THRESH1), .QA_EQ_B(Q_THRESH1));
338
 
339
        C_COMPARE_V3_0 #("0", 1, C_COUNT_TO, C_OUT_TYPE, C_ENABLE_RLOCS, C_HAS_ACLR, 0,
340
                                         0, 0, 0, 0, 0, 0, C_HAS_CE, 1,
341
                                         0, 0, 0, 0, 0, C_HAS_SCLR, 0, 0, 0, 0, C_WIDTH)
342
                        th_to(.A(intFBs), .CLK(CLK), .CE(CE), .ACLR(ACLR), .SCLR(SCLR), .QA_EQ_B(intCount_to_reached));
343
 
344
        initial
345
        begin
346
 
347
                #1;
348
 
349
 
350
        end
351
 
352
        function defval;
353
        input i;
354
        input hassig;
355
        input val;
356
                begin
357
                        if(hassig == 1)
358
                                defval = i;
359
                        else
360
                                defval = val;
361
                end
362
        endfunction
363
 
364
        function [C_WIDTH - 1 : 0] to_bits;
365
        input [C_WIDTH*8 : 1] instring;
366
        integer i;
367
        begin
368
                for(i = C_WIDTH; i > 0; i = i - 1)
369
                begin // Is this character a '0'? (ASCII = 48 = 00110000)
370
                        if(instring[(i*8)] == 0 &&
371
                                instring[(i*8)-1] == 0 &&
372
                                instring[(i*8)-2] == 1 &&
373
                                instring[(i*8)-3] == 1 &&
374
                                instring[(i*8)-4] == 0 &&
375
                                instring[(i*8)-5] == 0 &&
376
                                instring[(i*8)-6] == 0 &&
377
                                instring[(i*8)-7] == 0)
378
                                        to_bits[i-1] = 0;
379
                          // Or is it a '1'? 
380
                        else if(instring[(i*8)] == 0 &&
381
                                instring[(i*8)-1] == 0 &&
382
                                instring[(i*8)-2] == 1 &&
383
                                instring[(i*8)-3] == 1 &&
384
                                instring[(i*8)-4] == 0 &&
385
                                instring[(i*8)-5] == 0 &&
386
                                instring[(i*8)-6] == 0 &&
387
                                instring[(i*8)-7] == 1)
388
 
389
                                        to_bits[i-1] = 1;
390
                                  // Or is it a ' '? (a null char - in which case insert a '0')
391
                                else if(instring[(i*8)] == 0 &&
392
                                        instring[(i*8)-1] == 0 &&
393
                                        instring[(i*8)-2] == 0 &&
394
                                        instring[(i*8)-3] == 0 &&
395
                                        instring[(i*8)-4] == 0 &&
396
                                        instring[(i*8)-5] == 0 &&
397
                                        instring[(i*8)-6] == 0 &&
398
                                        instring[(i*8)-7] == 0)
399
                                                to_bits[i-1] = 0;
400
                        else
401
                        begin
402
                                $display("Error: non-binary digit in string \"%s\"\nExiting simulation...", instring);
403
                                $finish;
404
                        end
405
                end
406
        end
407
        endfunction
408
 
409
 
410
 
411
endmodule
412
 
413
`undef c_set
414
`undef c_clear
415
`undef c_override
416
`undef c_no_override
417
`undef c_signed
418
`undef c_unsigned
419
`undef c_pin
420
`undef c_up
421
`undef c_down
422
`undef c_updown
423
`undef allXs
424
 
425
`endif

powered by: WebSVN 2.1.0

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