2 * yosys -- Yosys Open SYnthesis Suite
4 * Copyright (C) 2012 Clifford Wolf <clifford@clifford.at>
6 * Permission to use, copy, modify, and/or distribute this software for any
7 * purpose with or without fee is hereby granted, provided that the above
8 * copyright notice and this permission notice appear in all copies.
10 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
20 * The internal logic cell technology mapper.
22 * This verilog library contains the mapping of internal cells (e.g. $not with
23 * variable bit width) to the internal logic cells (such as the single bit $_INV_
24 * gate). Usually this logic network is then mapped to the actual technology
25 * using e.g. the "abc" pass.
27 * Note that this library does not map $mem cells. They must be mapped to logic
28 * and $dff cells using the "memory_map" pass first. (Or map it to custom cells,
29 * which is of course highly recommended for larger memories.)
33 `define MIN(_a, _b) ((_a) < (_b) ? (_a) : (_b))
34 `define MAX(_a, _b) ((_a) > (_b) ? (_a) : (_b))
37 // --------------------------------------------------------
38 // Use simplemap for trivial cell types
39 // --------------------------------------------------------
41 (* techmap_simplemap *)
42 (* techmap_celltype = "$pos $bu0" *)
43 module simplemap_buffers;
46 (* techmap_simplemap *)
47 (* techmap_celltype = "$not $and $or $xor $xnor" *)
48 module simplemap_bool_ops;
51 (* techmap_simplemap *)
52 (* techmap_celltype = "$reduce_and $reduce_or $reduce_xor $reduce_xnor $reduce_bool" *)
53 module simplemap_reduce_ops;
56 (* techmap_simplemap *)
57 (* techmap_celltype = "$logic_not $logic_and $logic_or" *)
58 module simplemap_logic_ops;
61 (* techmap_simplemap *)
62 (* techmap_celltype = "$slice $concat $mux" *)
63 module simplemap_various;
66 (* techmap_simplemap *)
67 (* techmap_celltype = "$sr $dff $adff $dffsr $dlatch" *)
68 module simplemap_registers;
72 // --------------------------------------------------------
73 // Trivial substitutions
74 // --------------------------------------------------------
77 parameter A_SIGNED = 0;
78 parameter A_WIDTH = 1;
79 parameter Y_WIDTH = 1;
81 input [A_WIDTH-1:0] A;
82 output [Y_WIDTH-1:0] Y;
97 module \$ge (A, B, Y);
98 parameter A_SIGNED = 0;
99 parameter B_SIGNED = 0;
100 parameter A_WIDTH = 1;
101 parameter B_WIDTH = 1;
102 parameter Y_WIDTH = 1;
104 input [A_WIDTH-1:0] A;
105 input [B_WIDTH-1:0] B;
106 output [Y_WIDTH-1:0] Y;
114 ) _TECHMAP_REPLACE_ (
121 module \$gt (A, B, Y);
122 parameter A_SIGNED = 0;
123 parameter B_SIGNED = 0;
124 parameter A_WIDTH = 1;
125 parameter B_WIDTH = 1;
126 parameter Y_WIDTH = 1;
128 input [A_WIDTH-1:0] A;
129 input [B_WIDTH-1:0] B;
130 output [Y_WIDTH-1:0] Y;
138 ) _TECHMAP_REPLACE_ (
146 // --------------------------------------------------------
148 // --------------------------------------------------------
150 (* techmap_celltype = "$shr $shl $sshl $sshr" *)
151 module shift_ops_shr_shl_sshl_sshr (A, B, Y);
152 parameter A_SIGNED = 0;
153 parameter B_SIGNED = 0;
154 parameter A_WIDTH = 1;
155 parameter B_WIDTH = 1;
156 parameter Y_WIDTH = 1;
158 parameter _TECHMAP_CELLTYPE_ = "";
159 localparam shift_left = _TECHMAP_CELLTYPE_ == "$shl" || _TECHMAP_CELLTYPE_ == "$sshl";
160 localparam sign_extend = A_SIGNED && _TECHMAP_CELLTYPE_ == "$sshr";
162 input [A_WIDTH-1:0] A;
163 input [B_WIDTH-1:0] B;
164 output [Y_WIDTH-1:0] Y;
166 localparam WIDTH = `MAX(A_WIDTH, Y_WIDTH);
167 localparam BB_WIDTH = `MIN($clog2(shift_left ? Y_WIDTH : A_SIGNED ? WIDTH : A_WIDTH) + 1, B_WIDTH);
169 wire [1023:0] _TECHMAP_DO_00_ = "proc;;";
170 wire [1023:0] _TECHMAP_DO_01_ = "CONSTMAP; opt_muxtree; opt_const -mux_undef -mux_bool -fine;;;";
173 reg [WIDTH-1:0] buffer;
177 overflow = B_WIDTH > BB_WIDTH ? |B[B_WIDTH-1:BB_WIDTH] : 1'b0;
178 buffer = overflow ? {WIDTH{sign_extend ? A[A_WIDTH-1] : 1'b0}} : {{WIDTH-A_WIDTH{A_SIGNED ? A[A_WIDTH-1] : 1'b0}}, A};
180 for (i = 0; i < BB_WIDTH; i = i+1)
183 buffer = {buffer, (2**i)'b0};
184 else if (2**i < WIDTH)
185 buffer = {{2**i{sign_extend ? buffer[WIDTH-1] : 1'b0}}, buffer[WIDTH-1 : 2**i]};
187 buffer = {WIDTH{sign_extend ? buffer[WIDTH-1] : 1'b0}};
194 (* techmap_celltype = "$shift $shiftx" *)
195 module shift_shiftx (A, B, Y);
196 parameter A_SIGNED = 0;
197 parameter B_SIGNED = 0;
198 parameter A_WIDTH = 1;
199 parameter B_WIDTH = 1;
200 parameter Y_WIDTH = 1;
202 input [A_WIDTH-1:0] A;
203 input [B_WIDTH-1:0] B;
204 output [Y_WIDTH-1:0] Y;
206 localparam BB_WIDTH = `MIN($clog2(`MAX(A_WIDTH, Y_WIDTH)) + (B_SIGNED ? 2 : 1), B_WIDTH);
207 localparam WIDTH = `MAX(A_WIDTH, Y_WIDTH) + (B_SIGNED ? 2**(BB_WIDTH-1) : 0);
209 parameter _TECHMAP_CELLTYPE_ = "";
210 localparam extbit = _TECHMAP_CELLTYPE_ == "$shift" ? 1'b0 : 1'bx;
212 wire [1023:0] _TECHMAP_DO_00_ = "proc;;";
213 wire [1023:0] _TECHMAP_DO_01_ = "CONSTMAP; opt_muxtree; opt_const -mux_undef -mux_bool -fine;;;";
216 reg [WIDTH-1:0] buffer;
221 buffer = {WIDTH{extbit}};
222 buffer[`MAX(A_WIDTH, Y_WIDTH)-1:0] = A;
224 if (B_WIDTH > BB_WIDTH) begin
226 for (i = BB_WIDTH; i < B_WIDTH; i = i+1)
227 if (B[i] != B[BB_WIDTH-1])
230 overflow = |B[B_WIDTH-1:BB_WIDTH];
232 buffer = {WIDTH{extbit}};
235 for (i = BB_WIDTH-1; i >= 0; i = i-1)
237 if (B_SIGNED && i == BB_WIDTH-1)
238 buffer = {buffer, {2**i{extbit}}};
239 else if (2**i < WIDTH)
240 buffer = {{2**i{extbit}}, buffer[WIDTH-1 : 2**i]};
242 buffer = {WIDTH{extbit}};
250 // --------------------------------------------------------
251 // ALU Infrastructure
252 // --------------------------------------------------------
254 module \$__fulladd (A, B, C, X, Y);
255 // {X, Y} = A + B + C
262 \$_AND_ gate1 ( .A(A), .B(B), .Y(t1) );
263 \$_XOR_ gate2 ( .A(A), .B(B), .Y(t2) );
264 \$_AND_ gate3 ( .A(t2), .B(C), .Y(t3) );
265 \$_XOR_ gate4 ( .A(t2), .B(C), .Y(Y) );
266 \$_OR_ gate5 ( .A(t1), .B(t3), .Y(X) );
269 module \$__alu (A, B, Cin, Y, Cout, Csign);
272 input [WIDTH-1:0] A, B;
275 output [WIDTH-1:0] Y;
278 wire [WIDTH:0] carry;
279 assign carry[0] = Cin;
280 assign Cout = carry[WIDTH];
281 assign Csign = carry[WIDTH-1];
285 for (i = 0; i < WIDTH; i = i + 1) begin:V
298 // --------------------------------------------------------
300 // --------------------------------------------------------
302 module \$lt (A, B, Y);
303 parameter A_SIGNED = 0;
304 parameter B_SIGNED = 0;
305 parameter A_WIDTH = 1;
306 parameter B_WIDTH = 1;
307 parameter Y_WIDTH = 1;
309 localparam WIDTH = A_WIDTH > B_WIDTH ? A_WIDTH : B_WIDTH;
311 input [A_WIDTH-1:0] A;
312 input [B_WIDTH-1:0] B;
313 output [Y_WIDTH-1:0] Y;
315 wire carry, carry_sign;
316 wire [WIDTH-1:0] A_buf, B_buf, Y_buf;
317 \$pos #(.A_SIGNED(A_SIGNED), .A_WIDTH(A_WIDTH), .Y_WIDTH(WIDTH)) A_conv (.A(A), .Y(A_buf));
318 \$pos #(.A_SIGNED(B_SIGNED), .A_WIDTH(B_WIDTH), .Y_WIDTH(WIDTH)) B_conv (.A(B), .Y(B_buf));
334 assign of = carry ^ carry_sign;
336 assign sf = Y_buf[WIDTH-1];
339 if (A_SIGNED && B_SIGNED) begin
347 module \$le (A, B, Y);
348 parameter A_SIGNED = 0;
349 parameter B_SIGNED = 0;
350 parameter A_WIDTH = 1;
351 parameter B_WIDTH = 1;
352 parameter Y_WIDTH = 1;
354 localparam WIDTH = A_WIDTH > B_WIDTH ? A_WIDTH : B_WIDTH;
356 input [A_WIDTH-1:0] A;
357 input [B_WIDTH-1:0] B;
358 output [Y_WIDTH-1:0] Y;
360 wire carry, carry_sign;
361 wire [WIDTH-1:0] A_buf, B_buf, Y_buf;
362 \$pos #(.A_SIGNED(A_SIGNED), .A_WIDTH(A_WIDTH), .Y_WIDTH(WIDTH)) A_conv (.A(A), .Y(A_buf));
363 \$pos #(.A_SIGNED(B_SIGNED), .A_WIDTH(B_WIDTH), .Y_WIDTH(WIDTH)) B_conv (.A(B), .Y(B_buf));
379 assign of = carry ^ carry_sign;
381 assign sf = Y_buf[WIDTH-1];
384 if (A_SIGNED && B_SIGNED) begin
385 assign Y = zf || (of != sf);
393 // --------------------------------------------------------
395 // --------------------------------------------------------
397 module \$add (A, B, Y);
398 parameter A_SIGNED = 0;
399 parameter B_SIGNED = 0;
400 parameter A_WIDTH = 1;
401 parameter B_WIDTH = 1;
402 parameter Y_WIDTH = 1;
404 input [A_WIDTH-1:0] A;
405 input [B_WIDTH-1:0] B;
406 output [Y_WIDTH-1:0] Y;
408 wire [Y_WIDTH-1:0] A_buf, B_buf;
409 \$pos #(.A_SIGNED(A_SIGNED), .A_WIDTH(A_WIDTH), .Y_WIDTH(Y_WIDTH)) A_conv (.A(A), .Y(A_buf));
410 \$pos #(.A_SIGNED(B_SIGNED), .A_WIDTH(B_WIDTH), .Y_WIDTH(Y_WIDTH)) B_conv (.A(B), .Y(B_buf));
422 module \$sub (A, B, Y);
423 parameter A_SIGNED = 0;
424 parameter B_SIGNED = 0;
425 parameter A_WIDTH = 1;
426 parameter B_WIDTH = 1;
427 parameter Y_WIDTH = 1;
429 input [A_WIDTH-1:0] A;
430 input [B_WIDTH-1:0] B;
431 output [Y_WIDTH-1:0] Y;
433 wire [Y_WIDTH-1:0] A_buf, B_buf;
434 \$pos #(.A_SIGNED(A_SIGNED), .A_WIDTH(A_WIDTH), .Y_WIDTH(Y_WIDTH)) A_conv (.A(A), .Y(A_buf));
435 \$pos #(.A_SIGNED(B_SIGNED), .A_WIDTH(B_WIDTH), .Y_WIDTH(Y_WIDTH)) B_conv (.A(B), .Y(B_buf));
448 // --------------------------------------------------------
450 // --------------------------------------------------------
452 module \$__arraymul (A, B, Y);
454 input [WIDTH-1:0] A, B;
455 output [WIDTH-1:0] Y;
457 wire [WIDTH*WIDTH-1:0] partials;
460 assign partials[WIDTH-1 : 0] = A[0] ? B : 0;
461 generate for (i = 1; i < WIDTH; i = i+1) begin:gen
462 assign partials[WIDTH*(i+1)-1 : WIDTH*i] = (A[i] ? B << i : 0) + partials[WIDTH*i-1 : WIDTH*(i-1)];
465 assign Y = partials[WIDTH*WIDTH-1 : WIDTH*(WIDTH-1)];
468 module \$mul (A, B, Y);
469 parameter A_SIGNED = 0;
470 parameter B_SIGNED = 0;
471 parameter A_WIDTH = 1;
472 parameter B_WIDTH = 1;
473 parameter Y_WIDTH = 1;
475 input [A_WIDTH-1:0] A;
476 input [B_WIDTH-1:0] B;
477 output [Y_WIDTH-1:0] Y;
479 wire [Y_WIDTH-1:0] A_buf, B_buf;
480 \$pos #(.A_SIGNED(A_SIGNED), .A_WIDTH(A_WIDTH), .Y_WIDTH(Y_WIDTH)) A_conv (.A(A), .Y(A_buf));
481 \$pos #(.A_SIGNED(B_SIGNED), .A_WIDTH(B_WIDTH), .Y_WIDTH(Y_WIDTH)) B_conv (.A(B), .Y(B_buf));
493 // --------------------------------------------------------
495 // --------------------------------------------------------
497 module \$__div_mod_u (A, B, Y, R);
500 input [WIDTH-1:0] A, B;
501 output [WIDTH-1:0] Y, R;
503 wire [WIDTH*WIDTH-1:0] chaindata;
504 assign R = chaindata[WIDTH*WIDTH-1:WIDTH*(WIDTH-1)];
508 for (i = 0; i < WIDTH; i=i+1) begin:stage
509 wire [WIDTH-1:0] stage_in;
514 assign stage_in = chaindata[i*WIDTH-1:(i-1)*WIDTH];
517 assign Y[WIDTH-(i+1)] = stage_in >= {B, {WIDTH-(i+1){1'b0}}};
518 assign chaindata[(i+1)*WIDTH-1:i*WIDTH] = Y[WIDTH-(i+1)] ? stage_in - {B, {WIDTH-(i+1){1'b0}}} : stage_in;
523 module \$__div_mod (A, B, Y, R);
524 parameter A_SIGNED = 0;
525 parameter B_SIGNED = 0;
526 parameter A_WIDTH = 1;
527 parameter B_WIDTH = 1;
528 parameter Y_WIDTH = 1;
531 A_WIDTH >= B_WIDTH && A_WIDTH >= Y_WIDTH ? A_WIDTH :
532 B_WIDTH >= A_WIDTH && B_WIDTH >= Y_WIDTH ? B_WIDTH : Y_WIDTH;
534 input [A_WIDTH-1:0] A;
535 input [B_WIDTH-1:0] B;
536 output [Y_WIDTH-1:0] Y, R;
538 wire [WIDTH-1:0] A_buf, B_buf;
539 \$pos #(.A_SIGNED(A_SIGNED), .A_WIDTH(A_WIDTH), .Y_WIDTH(WIDTH)) A_conv (.A(A), .Y(A_buf));
540 \$pos #(.A_SIGNED(B_SIGNED), .A_WIDTH(B_WIDTH), .Y_WIDTH(WIDTH)) B_conv (.A(B), .Y(B_buf));
542 wire [WIDTH-1:0] A_buf_u, B_buf_u, Y_u, R_u;
543 assign A_buf_u = A_SIGNED && A_buf[WIDTH-1] ? -A_buf : A_buf;
544 assign B_buf_u = B_SIGNED && B_buf[WIDTH-1] ? -B_buf : B_buf;
555 assign Y = A_SIGNED && B_SIGNED && (A_buf[WIDTH-1] != B_buf[WIDTH-1]) ? -Y_u : Y_u;
556 assign R = A_SIGNED && B_SIGNED && A_buf[WIDTH-1] ? -R_u : R_u;
559 module \$div (A, B, Y);
560 parameter A_SIGNED = 0;
561 parameter B_SIGNED = 0;
562 parameter A_WIDTH = 1;
563 parameter B_WIDTH = 1;
564 parameter Y_WIDTH = 1;
566 input [A_WIDTH-1:0] A;
567 input [B_WIDTH-1:0] B;
568 output [Y_WIDTH-1:0] Y;
583 module \$mod (A, B, Y);
584 parameter A_SIGNED = 0;
585 parameter B_SIGNED = 0;
586 parameter A_WIDTH = 1;
587 parameter B_WIDTH = 1;
588 parameter Y_WIDTH = 1;
590 input [A_WIDTH-1:0] A;
591 input [B_WIDTH-1:0] B;
592 output [Y_WIDTH-1:0] Y;
608 // --------------------------------------------------------
610 // --------------------------------------------------------
612 module \$pow (A, B, Y);
613 parameter A_SIGNED = 0;
614 parameter B_SIGNED = 0;
615 parameter A_WIDTH = 1;
616 parameter B_WIDTH = 1;
617 parameter Y_WIDTH = 1;
619 input [A_WIDTH-1:0] A;
620 input [B_WIDTH-1:0] B;
621 output [Y_WIDTH-1:0] Y;
623 wire _TECHMAP_FAIL_ = 1;
627 // --------------------------------------------------------
628 // Equal and Not-Equal
629 // --------------------------------------------------------
631 module \$eq (A, B, Y);
632 parameter A_SIGNED = 0;
633 parameter B_SIGNED = 0;
634 parameter A_WIDTH = 1;
635 parameter B_WIDTH = 1;
636 parameter Y_WIDTH = 1;
638 localparam WIDTH = A_WIDTH > B_WIDTH ? A_WIDTH : B_WIDTH;
640 input [A_WIDTH-1:0] A;
641 input [B_WIDTH-1:0] B;
642 output [Y_WIDTH-1:0] Y;
644 wire carry, carry_sign;
645 wire [WIDTH-1:0] A_buf, B_buf;
646 \$bu0 #(.A_SIGNED(A_SIGNED), .A_WIDTH(A_WIDTH), .Y_WIDTH(WIDTH)) A_conv (.A(A), .Y(A_buf));
647 \$bu0 #(.A_SIGNED(B_SIGNED), .A_WIDTH(B_WIDTH), .Y_WIDTH(WIDTH)) B_conv (.A(B), .Y(B_buf));
649 assign Y = ~|(A_buf ^ B_buf);
652 module \$ne (A, B, Y);
653 parameter A_SIGNED = 0;
654 parameter B_SIGNED = 0;
655 parameter A_WIDTH = 1;
656 parameter B_WIDTH = 1;
657 parameter Y_WIDTH = 1;
659 localparam WIDTH = A_WIDTH > B_WIDTH ? A_WIDTH : B_WIDTH;
661 input [A_WIDTH-1:0] A;
662 input [B_WIDTH-1:0] B;
663 output [Y_WIDTH-1:0] Y;
665 wire carry, carry_sign;
666 wire [WIDTH-1:0] A_buf, B_buf;
667 \$bu0 #(.A_SIGNED(A_SIGNED), .A_WIDTH(A_WIDTH), .Y_WIDTH(WIDTH)) A_conv (.A(A), .Y(A_buf));
668 \$bu0 #(.A_SIGNED(B_SIGNED), .A_WIDTH(B_WIDTH), .Y_WIDTH(WIDTH)) B_conv (.A(B), .Y(B_buf));
670 assign Y = |(A_buf ^ B_buf);
673 module \$eqx (A, B, Y);
674 parameter A_SIGNED = 0;
675 parameter B_SIGNED = 0;
676 parameter A_WIDTH = 1;
677 parameter B_WIDTH = 1;
678 parameter Y_WIDTH = 1;
680 localparam WIDTH = A_WIDTH > B_WIDTH ? A_WIDTH : B_WIDTH;
682 input [A_WIDTH-1:0] A;
683 input [B_WIDTH-1:0] B;
684 output [Y_WIDTH-1:0] Y;
686 wire carry, carry_sign;
687 wire [WIDTH-1:0] A_buf, B_buf;
688 \$pos #(.A_SIGNED(A_SIGNED), .A_WIDTH(A_WIDTH), .Y_WIDTH(WIDTH)) A_conv (.A(A), .Y(A_buf));
689 \$pos #(.A_SIGNED(B_SIGNED), .A_WIDTH(B_WIDTH), .Y_WIDTH(WIDTH)) B_conv (.A(B), .Y(B_buf));
691 assign Y = ~|(A_buf ^ B_buf);
694 module \$nex (A, B, Y);
695 parameter A_SIGNED = 0;
696 parameter B_SIGNED = 0;
697 parameter A_WIDTH = 1;
698 parameter B_WIDTH = 1;
699 parameter Y_WIDTH = 1;
701 localparam WIDTH = A_WIDTH > B_WIDTH ? A_WIDTH : B_WIDTH;
703 input [A_WIDTH-1:0] A;
704 input [B_WIDTH-1:0] B;
705 output [Y_WIDTH-1:0] Y;
707 wire carry, carry_sign;
708 wire [WIDTH-1:0] A_buf, B_buf;
709 \$pos #(.A_SIGNED(A_SIGNED), .A_WIDTH(A_WIDTH), .Y_WIDTH(WIDTH)) A_conv (.A(A), .Y(A_buf));
710 \$pos #(.A_SIGNED(B_SIGNED), .A_WIDTH(B_WIDTH), .Y_WIDTH(WIDTH)) B_conv (.A(B), .Y(B_buf));
712 assign Y = |(A_buf ^ B_buf);
716 // --------------------------------------------------------
717 // Parallel Multiplexers
718 // --------------------------------------------------------
720 module \$pmux (A, B, S, Y);
722 parameter S_WIDTH = 1;
725 input [WIDTH*S_WIDTH-1:0] B;
726 input [S_WIDTH-1:0] S;
727 output [WIDTH-1:0] Y;
729 wire [WIDTH-1:0] Y_B;
733 wire [WIDTH*S_WIDTH-1:0] B_AND_S;
734 for (i = 0; i < S_WIDTH; i = i + 1) begin:B_AND
735 assign B_AND_S[WIDTH*(i+1)-1:WIDTH*i] = B[WIDTH*(i+1)-1:WIDTH*i] & {WIDTH{S[i]}};
737 for (i = 0; i < WIDTH; i = i + 1) begin:B_OR
738 wire [S_WIDTH-1:0] B_AND_BITS;
739 for (j = 0; j < S_WIDTH; j = j + 1) begin:B_AND_BITS_COLLECT
740 assign B_AND_BITS[j] = B_AND_S[WIDTH*j+i];
741 end:B_AND_BITS_COLLECT
742 assign Y_B[i] = |B_AND_BITS;
746 assign Y = |S ? Y_B : A;
749 module \$safe_pmux (A, B, S, Y);
751 parameter S_WIDTH = 1;
754 input [WIDTH*S_WIDTH-1:0] B;
755 input [S_WIDTH-1:0] S;
756 output [WIDTH-1:0] Y;
758 wire [S_WIDTH-1:0] status_found_first;
759 wire [S_WIDTH-1:0] status_found_second;
763 for (i = 0; i < S_WIDTH; i = i + 1) begin:GEN1
765 if (i > 0) begin:GEN2
766 assign pre_first = status_found_first[i-1];
767 end:GEN2 else begin:GEN3
768 assign pre_first = 0;
770 assign status_found_first[i] = pre_first | S[i];
771 assign status_found_second[i] = pre_first & S[i];
781 .S(S & {S_WIDTH{~|status_found_second}}),