1 | module CondSet(comparand_a,out);
|
2 | input [31:0] comparand_a;
|
3 | output [31:0] out;
|
4 | wire [31:0] comparand_b;
|
5 | wire [31:0] thenset;
|
6 | wire [31:0] elseset;
|
7 | // computes: if(comparand_a > comparand_b) then out = thenset else out = elseset
|
8 |
|
9 | assign comparand_b = 0;
|
10 | assign thenset = 0;
|
11 | assign elseset = 1;
|
12 |
|
13 | CondSetInt cs0( .comparand_a( comparand_a ), .comparand_b( comparand_b ), .thenset( thenset ), .elseset( elseset ), .out( out ) );
|
14 |
|
15 | endmodule
|
16 |
|
17 | module CondSetInt(comparand_a,comparand_b,thenset,elseset,out);
|
18 | input [31:0] comparand_a;
|
19 | input [31:0] comparand_b;
|
20 | input [31:0] thenset;
|
21 | input [31:0] elseset;
|
22 | output [31:0] out;
|
23 | // computes: if(comparand_a > comparand_b) then out = thenset else out = elseset
|
24 |
|
25 | wire sign_a;
|
26 | wire sign_b;
|
27 | assign sign_a = comparand_a[31];
|
28 | assign sign_b = comparand_b[31];
|
29 |
|
30 | wire [30:0] a;
|
31 | wire [30:0] b;
|
32 | assign a = comparand_a[30:0];
|
33 | assign b = comparand_b[30:0];
|
34 |
|
35 | wire takethen;
|
36 | wire takeelse;
|
37 | assign takethen = a_gt_b;
|
38 | assign takeelse = ~takethen;
|
39 |
|
40 | wire a_gt_b;
|
41 | assign a_gt_b = (~sign_a & sign_b) | ~(sign_a ^ sign_b) & abits_gt_bbits;
|
42 |
|
43 | wire abits_gt_bbits;
|
44 | assign abits_gt_bbits =
|
45 | a_gt_b_at_30 |
|
46 | a_gt_b_at_29 |
|
47 | a_gt_b_at_28 |
|
48 | a_gt_b_at_27 |
|
49 | a_gt_b_at_26 |
|
50 | a_gt_b_at_25 |
|
51 | a_gt_b_at_24 |
|
52 | a_gt_b_at_23 |
|
53 | a_gt_b_at_22 |
|
54 | a_gt_b_at_21 |
|
55 | a_gt_b_at_20 |
|
56 | a_gt_b_at_19 |
|
57 | a_gt_b_at_18 |
|
58 | a_gt_b_at_17 |
|
59 | a_gt_b_at_16 |
|
60 | a_gt_b_at_15 |
|
61 | a_gt_b_at_14 |
|
62 | a_gt_b_at_13 |
|
63 | a_gt_b_at_12 |
|
64 | a_gt_b_at_11 |
|
65 | a_gt_b_at_10 |
|
66 | a_gt_b_at_9 |
|
67 | a_gt_b_at_8 |
|
68 | a_gt_b_at_7 |
|
69 | a_gt_b_at_6 |
|
70 | a_gt_b_at_5 |
|
71 | a_gt_b_at_4 |
|
72 | a_gt_b_at_3 |
|
73 | a_gt_b_at_2 |
|
74 | a_gt_b_at_1 |
|
75 | a_gt_b_at_0 ;
|
76 |
|
77 | wire a_eq_b_down_to_30;
|
78 | assign a_eq_b_down_to_30 = ~(a[30] ^ b[30]);
|
79 | wire a_eq_b_down_to_29;
|
80 | assign a_eq_b_down_to_29 = a_eq_b_down_to_30 & ~(a[29] ^ b[29]);
|
81 | wire a_eq_b_down_to_28;
|
82 | assign a_eq_b_down_to_28 = a_eq_b_down_to_29 & ~(a[28] ^ b[28]);
|
83 | wire a_eq_b_down_to_27;
|
84 | assign a_eq_b_down_to_27 = a_eq_b_down_to_28 & ~(a[27] ^ b[27]);
|
85 | wire a_eq_b_down_to_26;
|
86 | assign a_eq_b_down_to_26 = a_eq_b_down_to_27 & ~(a[26] ^ b[26]);
|
87 | wire a_eq_b_down_to_25;
|
88 | assign a_eq_b_down_to_25 = a_eq_b_down_to_26 & ~(a[25] ^ b[25]);
|
89 | wire a_eq_b_down_to_24;
|
90 | assign a_eq_b_down_to_24 = a_eq_b_down_to_25 & ~(a[24] ^ b[24]);
|
91 | wire a_eq_b_down_to_23;
|
92 | assign a_eq_b_down_to_23 = a_eq_b_down_to_24 & ~(a[23] ^ b[23]);
|
93 | wire a_eq_b_down_to_22;
|
94 | assign a_eq_b_down_to_22 = a_eq_b_down_to_23 & ~(a[22] ^ b[22]);
|
95 | wire a_eq_b_down_to_21;
|
96 | assign a_eq_b_down_to_21 = a_eq_b_down_to_22 & ~(a[21] ^ b[21]);
|
97 | wire a_eq_b_down_to_20;
|
98 | assign a_eq_b_down_to_20 = a_eq_b_down_to_21 & ~(a[20] ^ b[20]);
|
99 | wire a_eq_b_down_to_19;
|
100 | assign a_eq_b_down_to_19 = a_eq_b_down_to_20 & ~(a[19] ^ b[19]);
|
101 | wire a_eq_b_down_to_18;
|
102 | assign a_eq_b_down_to_18 = a_eq_b_down_to_19 & ~(a[18] ^ b[18]);
|
103 | wire a_eq_b_down_to_17;
|
104 | assign a_eq_b_down_to_17 = a_eq_b_down_to_18 & ~(a[17] ^ b[17]);
|
105 | wire a_eq_b_down_to_16;
|
106 | assign a_eq_b_down_to_16 = a_eq_b_down_to_17 & ~(a[16] ^ b[16]);
|
107 | wire a_eq_b_down_to_15;
|
108 | assign a_eq_b_down_to_15 = a_eq_b_down_to_16 & ~(a[15] ^ b[15]);
|
109 | wire a_eq_b_down_to_14;
|
110 | assign a_eq_b_down_to_14 = a_eq_b_down_to_15 & ~(a[14] ^ b[14]);
|
111 | wire a_eq_b_down_to_13;
|
112 | assign a_eq_b_down_to_13 = a_eq_b_down_to_14 & ~(a[13] ^ b[13]);
|
113 | wire a_eq_b_down_to_12;
|
114 | assign a_eq_b_down_to_12 = a_eq_b_down_to_13 & ~(a[12] ^ b[12]);
|
115 | wire a_eq_b_down_to_11;
|
116 | assign a_eq_b_down_to_11 = a_eq_b_down_to_12 & ~(a[11] ^ b[11]);
|
117 | wire a_eq_b_down_to_10;
|
118 | assign a_eq_b_down_to_10 = a_eq_b_down_to_11 & ~(a[10] ^ b[10]);
|
119 | wire a_eq_b_down_to_9;
|
120 | assign a_eq_b_down_to_9 = a_eq_b_down_to_10 & ~(a[9] ^ b[9]);
|
121 | wire a_eq_b_down_to_8;
|
122 | assign a_eq_b_down_to_8 = a_eq_b_down_to_9 & ~(a[8] ^ b[8]);
|
123 | wire a_eq_b_down_to_7;
|
124 | assign a_eq_b_down_to_7 = a_eq_b_down_to_8 & ~(a[7] ^ b[7]);
|
125 | wire a_eq_b_down_to_6;
|
126 | assign a_eq_b_down_to_6 = a_eq_b_down_to_7 & ~(a[6] ^ b[6]);
|
127 | wire a_eq_b_down_to_5;
|
128 | assign a_eq_b_down_to_5 = a_eq_b_down_to_6 & ~(a[5] ^ b[5]);
|
129 | wire a_eq_b_down_to_4;
|
130 | assign a_eq_b_down_to_4 = a_eq_b_down_to_5 & ~(a[4] ^ b[4]);
|
131 | wire a_eq_b_down_to_3;
|
132 | assign a_eq_b_down_to_3 = a_eq_b_down_to_4 & ~(a[3] ^ b[3]);
|
133 | wire a_eq_b_down_to_2;
|
134 | assign a_eq_b_down_to_2 = a_eq_b_down_to_3 & ~(a[2] ^ b[2]);
|
135 | wire a_eq_b_down_to_1;
|
136 | assign a_eq_b_down_to_1 = a_eq_b_down_to_2 & ~(a[1] ^ b[1]);
|
137 | wire a_eq_b_down_to_0;
|
138 | assign a_eq_b_down_to_0 = a_eq_b_down_to_1 & ~(a[0] ^ b[0]);
|
139 |
|
140 | wire a_gt_b_at_30;
|
141 | assign a_gt_b_at_30 = a[30] & ~b[30];
|
142 | wire a_gt_b_at_29;
|
143 | assign a_gt_b_at_29 = a_eq_b_down_to_30 & (a[29] & ~b[29]);
|
144 | wire a_gt_b_at_28;
|
145 | assign a_gt_b_at_28 = a_eq_b_down_to_29 & (a[28] & ~b[28]);
|
146 | wire a_gt_b_at_27;
|
147 | assign a_gt_b_at_27 = a_eq_b_down_to_28 & (a[27] & ~b[27]);
|
148 | wire a_gt_b_at_26;
|
149 | assign a_gt_b_at_26 = a_eq_b_down_to_27 & (a[26] & ~b[26]);
|
150 | wire a_gt_b_at_25;
|
151 | assign a_gt_b_at_25 = a_eq_b_down_to_26 & (a[25] & ~b[25]);
|
152 | wire a_gt_b_at_24;
|
153 | assign a_gt_b_at_24 = a_eq_b_down_to_25 & (a[24] & ~b[24]);
|
154 | wire a_gt_b_at_23;
|
155 | assign a_gt_b_at_23 = a_eq_b_down_to_24 & (a[23] & ~b[23]);
|
156 | wire a_gt_b_at_22;
|
157 | assign a_gt_b_at_22 = a_eq_b_down_to_23 & (a[22] & ~b[22]);
|
158 | wire a_gt_b_at_21;
|
159 | assign a_gt_b_at_21 = a_eq_b_down_to_22 & (a[21] & ~b[21]);
|
160 | wire a_gt_b_at_20;
|
161 | assign a_gt_b_at_20 = a_eq_b_down_to_21 & (a[20] & ~b[20]);
|
162 | wire a_gt_b_at_19;
|
163 | assign a_gt_b_at_19 = a_eq_b_down_to_20 & (a[19] & ~b[19]);
|
164 | wire a_gt_b_at_18;
|
165 | assign a_gt_b_at_18 = a_eq_b_down_to_19 & (a[18] & ~b[18]);
|
166 | wire a_gt_b_at_17;
|
167 | assign a_gt_b_at_17 = a_eq_b_down_to_18 & (a[17] & ~b[17]);
|
168 | wire a_gt_b_at_16;
|
169 | assign a_gt_b_at_16 = a_eq_b_down_to_17 & (a[16] & ~b[16]);
|
170 | wire a_gt_b_at_15;
|
171 | assign a_gt_b_at_15 = a_eq_b_down_to_16 & (a[15] & ~b[15]);
|
172 | wire a_gt_b_at_14;
|
173 | assign a_gt_b_at_14 = a_eq_b_down_to_15 & (a[14] & ~b[14]);
|
174 | wire a_gt_b_at_13;
|
175 | assign a_gt_b_at_13 = a_eq_b_down_to_14 & (a[13] & ~b[13]);
|
176 | wire a_gt_b_at_12;
|
177 | assign a_gt_b_at_12 = a_eq_b_down_to_13 & (a[12] & ~b[12]);
|
178 | wire a_gt_b_at_11;
|
179 | assign a_gt_b_at_11 = a_eq_b_down_to_12 & (a[11] & ~b[11]);
|
180 | wire a_gt_b_at_10;
|
181 | assign a_gt_b_at_10 = a_eq_b_down_to_11 & (a[10] & ~b[10]);
|
182 | wire a_gt_b_at_9;
|
183 | assign a_gt_b_at_9 = a_eq_b_down_to_10 & (a[9] & ~b[9]);
|
184 | wire a_gt_b_at_8;
|
185 | assign a_gt_b_at_8 = a_eq_b_down_to_9 & (a[8] & ~b[8]);
|
186 | wire a_gt_b_at_7;
|
187 | assign a_gt_b_at_7 = a_eq_b_down_to_8 & (a[7] & ~b[7]);
|
188 | wire a_gt_b_at_6;
|
189 | assign a_gt_b_at_6 = a_eq_b_down_to_7 & (a[6] & ~b[6]);
|
190 | wire a_gt_b_at_5;
|
191 | assign a_gt_b_at_5 = a_eq_b_down_to_6 & (a[5] & ~b[5]);
|
192 | wire a_gt_b_at_4;
|
193 | assign a_gt_b_at_4 = a_eq_b_down_to_5 & (a[4] & ~b[4]);
|
194 | wire a_gt_b_at_3;
|
195 | assign a_gt_b_at_3 = a_eq_b_down_to_4 & (a[3] & ~b[3]);
|
196 | wire a_gt_b_at_2;
|
197 | assign a_gt_b_at_2 = a_eq_b_down_to_3 & (a[2] & ~b[2]);
|
198 | wire a_gt_b_at_1;
|
199 | assign a_gt_b_at_1 = a_eq_b_down_to_2 & (a[1] & ~b[1]);
|
200 | wire a_gt_b_at_0;
|
201 | assign a_gt_b_at_0 = a_eq_b_down_to_1 & (a[0] & ~b[0]);
|
202 |
|
203 |
|
204 | assign out[0] = (thenset[0] & takethen) | (elseset[0] & takeelse);
|
205 | assign out[1] = (thenset[1] & takethen) | (elseset[1] & takeelse);
|
206 | assign out[2] = (thenset[2] & takethen) | (elseset[2] & takeelse);
|
207 | assign out[3] = (thenset[3] & takethen) | (elseset[3] & takeelse);
|
208 | assign out[4] = (thenset[4] & takethen) | (elseset[4] & takeelse);
|
209 | assign out[5] = (thenset[5] & takethen) | (elseset[5] & takeelse);
|
210 | assign out[6] = (thenset[6] & takethen) | (elseset[6] & takeelse);
|
211 | assign out[7] = (thenset[7] & takethen) | (elseset[7] & takeelse);
|
212 | assign out[8] = (thenset[8] & takethen) | (elseset[8] & takeelse);
|
213 | assign out[9] = (thenset[9] & takethen) | (elseset[9] & takeelse);
|
214 | assign out[10] = (thenset[10] & takethen) | (elseset[10] & takeelse);
|
215 | assign out[11] = (thenset[11] & takethen) | (elseset[11] & takeelse);
|
216 | assign out[12] = (thenset[12] & takethen) | (elseset[12] & takeelse);
|
217 | assign out[13] = (thenset[13] & takethen) | (elseset[13] & takeelse);
|
218 | assign out[14] = (thenset[14] & takethen) | (elseset[14] & takeelse);
|
219 | assign out[15] = (thenset[15] & takethen) | (elseset[15] & takeelse);
|
220 | assign out[16] = (thenset[16] & takethen) | (elseset[16] & takeelse);
|
221 | assign out[17] = (thenset[17] & takethen) | (elseset[17] & takeelse);
|
222 | assign out[18] = (thenset[18] & takethen) | (elseset[18] & takeelse);
|
223 | assign out[19] = (thenset[19] & takethen) | (elseset[19] & takeelse);
|
224 | assign out[20] = (thenset[20] & takethen) | (elseset[20] & takeelse);
|
225 | assign out[21] = (thenset[21] & takethen) | (elseset[21] & takeelse);
|
226 | assign out[22] = (thenset[22] & takethen) | (elseset[22] & takeelse);
|
227 | assign out[23] = (thenset[23] & takethen) | (elseset[23] & takeelse);
|
228 | assign out[24] = (thenset[24] & takethen) | (elseset[24] & takeelse);
|
229 | assign out[25] = (thenset[25] & takethen) | (elseset[25] & takeelse);
|
230 | assign out[26] = (thenset[26] & takethen) | (elseset[26] & takeelse);
|
231 | assign out[27] = (thenset[27] & takethen) | (elseset[27] & takeelse);
|
232 | assign out[28] = (thenset[28] & takethen) | (elseset[28] & takeelse);
|
233 | assign out[29] = (thenset[29] & takethen) | (elseset[29] & takeelse);
|
234 | assign out[30] = (thenset[30] & takethen) | (elseset[30] & takeelse);
|
235 | assign out[31] = (thenset[31] & takethen) | (elseset[31] & takeelse);
|
236 |
|
237 | endmodule
|
238 |
|