Add (* abc_flop_q *) to brams_bb.v
[yosys.git] / techlibs / common / simcells.v
1 /*
2 * yosys -- Yosys Open SYnthesis Suite
3 *
4 * Copyright (C) 2012 Clifford Wolf <clifford@clifford.at>
5 *
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.
9 *
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.
17 *
18 * ---
19 *
20 * The internal logic cell simulation library.
21 *
22 * This Verilog library contains simple simulation models for the internal
23 * logic cells ($_NOT_ , $_AND_ , ...) that are generated by the default technology
24 * mapper (see "techmap.v" in this directory) and expected by the "abc" pass.
25 *
26 */
27
28 // |---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|
29 //-
30 //- $_BUF_ (A, Y)
31 //-
32 //- A buffer. This cell type is always optimized away by the opt_clean pass.
33 //-
34 //- Truth table: A | Y
35 //- ---+---
36 //- 0 | 0
37 //- 1 | 1
38 //-
39 module \$_BUF_ (A, Y);
40 input A;
41 output Y;
42 assign Y = A;
43 endmodule
44
45 // |---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|
46 //-
47 //- $_NOT_ (A, Y)
48 //-
49 //- An inverter gate.
50 //-
51 //- Truth table: A | Y
52 //- ---+---
53 //- 0 | 1
54 //- 1 | 0
55 //-
56 module \$_NOT_ (A, Y);
57 input A;
58 output Y;
59 assign Y = ~A;
60 endmodule
61
62 // |---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|
63 //-
64 //- $_AND_ (A, B, Y)
65 //-
66 //- A 2-input AND gate.
67 //-
68 //- Truth table: A B | Y
69 //- -----+---
70 //- 0 0 | 0
71 //- 0 1 | 0
72 //- 1 0 | 0
73 //- 1 1 | 1
74 //-
75 module \$_AND_ (A, B, Y);
76 input A, B;
77 output Y;
78 assign Y = A & B;
79 endmodule
80
81 // |---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|
82 //-
83 //- $_NAND_ (A, B, Y)
84 //-
85 //- A 2-input NAND gate.
86 //-
87 //- Truth table: A B | Y
88 //- -----+---
89 //- 0 0 | 1
90 //- 0 1 | 1
91 //- 1 0 | 1
92 //- 1 1 | 0
93 //-
94 module \$_NAND_ (A, B, Y);
95 input A, B;
96 output Y;
97 assign Y = ~(A & B);
98 endmodule
99
100 // |---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|
101 //-
102 //- $_OR_ (A, B, Y)
103 //-
104 //- A 2-input OR gate.
105 //-
106 //- Truth table: A B | Y
107 //- -----+---
108 //- 0 0 | 0
109 //- 0 1 | 1
110 //- 1 0 | 1
111 //- 1 1 | 1
112 //-
113 module \$_OR_ (A, B, Y);
114 input A, B;
115 output Y;
116 assign Y = A | B;
117 endmodule
118
119 // |---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|
120 //-
121 //- $_NOR_ (A, B, Y)
122 //-
123 //- A 2-input NOR gate.
124 //-
125 //- Truth table: A B | Y
126 //- -----+---
127 //- 0 0 | 1
128 //- 0 1 | 0
129 //- 1 0 | 0
130 //- 1 1 | 0
131 //-
132 module \$_NOR_ (A, B, Y);
133 input A, B;
134 output Y;
135 assign Y = ~(A | B);
136 endmodule
137
138 // |---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|
139 //-
140 //- $_XOR_ (A, B, Y)
141 //-
142 //- A 2-input XOR gate.
143 //-
144 //- Truth table: A B | Y
145 //- -----+---
146 //- 0 0 | 0
147 //- 0 1 | 1
148 //- 1 0 | 1
149 //- 1 1 | 0
150 //-
151 module \$_XOR_ (A, B, Y);
152 input A, B;
153 output Y;
154 assign Y = A ^ B;
155 endmodule
156
157 // |---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|
158 //-
159 //- $_XNOR_ (A, B, Y)
160 //-
161 //- A 2-input XNOR gate.
162 //-
163 //- Truth table: A B | Y
164 //- -----+---
165 //- 0 0 | 1
166 //- 0 1 | 0
167 //- 1 0 | 0
168 //- 1 1 | 1
169 //-
170 module \$_XNOR_ (A, B, Y);
171 input A, B;
172 output Y;
173 assign Y = ~(A ^ B);
174 endmodule
175
176 // |---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|
177 //-
178 //- $_ANDNOT_ (A, B, Y)
179 //-
180 //- A 2-input AND-NOT gate.
181 //-
182 //- Truth table: A B | Y
183 //- -----+---
184 //- 0 0 | 0
185 //- 0 1 | 0
186 //- 1 0 | 1
187 //- 1 1 | 0
188 //-
189 module \$_ANDNOT_ (A, B, Y);
190 input A, B;
191 output Y;
192 assign Y = A & (~B);
193 endmodule
194
195 // |---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|
196 //-
197 //- $_ORNOT_ (A, B, Y)
198 //-
199 //- A 2-input OR-NOT gate.
200 //-
201 //- Truth table: A B | Y
202 //- -----+---
203 //- 0 0 | 1
204 //- 0 1 | 0
205 //- 1 0 | 1
206 //- 1 1 | 1
207 //-
208 module \$_ORNOT_ (A, B, Y);
209 input A, B;
210 output Y;
211 assign Y = A | (~B);
212 endmodule
213
214 // |---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|
215 //-
216 //- $_MUX_ (A, B, S, Y)
217 //-
218 //- A 2-input MUX gate.
219 //-
220 //- Truth table: A B S | Y
221 //- -------+---
222 //- a - 0 | a
223 //- - b 1 | b
224 //-
225 module \$_MUX_ (A, B, S, Y);
226 input A, B, S;
227 output Y;
228 assign Y = S ? B : A;
229 endmodule
230
231 // |---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|
232 //-
233 //- $_MUX4_ (A, B, C, D, S, T, Y)
234 //-
235 //- A 4-input MUX gate.
236 //-
237 //- Truth table: A B C D S T | Y
238 //- -------------+---
239 //- a - - - 0 0 | a
240 //- - b - - 1 0 | b
241 //- - - c - 0 1 | c
242 //- - - - d 1 1 | d
243 //-
244 module \$_MUX4_ (A, B, C, D, S, T, Y);
245 input A, B, C, D, S, T;
246 output Y;
247 assign Y = T ? (S ? D : C) :
248 (S ? B : A);
249 endmodule
250
251 // |---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|
252 //-
253 //- $_MUX8_ (A, B, C, D, E, F, G, H, S, T, U, Y)
254 //-
255 //- An 8-input MUX gate.
256 //-
257 //- Truth table: A B C D E F G H S T U | Y
258 //- -----------------------+---
259 //- a - - - - - - - 0 0 0 | a
260 //- - b - - - - - - 1 0 0 | b
261 //- - - c - - - - - 0 1 0 | c
262 //- - - - d - - - - 1 1 0 | d
263 //- - - - - e - - - 0 0 1 | e
264 //- - - - - - f - - 1 0 1 | f
265 //- - - - - - - g - 0 1 1 | g
266 //- - - - - - - - h 1 1 1 | h
267 //-
268 module \$_MUX8_ (A, B, C, D, E, F, G, H, S, T, U, Y);
269 input A, B, C, D, E, F, G, H, S, T, U;
270 output Y;
271 assign Y = U ? T ? (S ? H : G) :
272 (S ? F : E) :
273 T ? (S ? D : C) :
274 (S ? B : A);
275 endmodule
276
277 // |---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|
278 //-
279 //- $_MUX16_ (A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, S, T, U, V, Y)
280 //-
281 //- A 16-input MUX gate.
282 //-
283 //- Truth table: A B C D E F G H I J K L M N O P S T U V | Y
284 //- -----------------------------------------+---
285 //- a - - - - - - - - - - - - - - - 0 0 0 0 | a
286 //- - b - - - - - - - - - - - - - - 1 0 0 0 | b
287 //- - - c - - - - - - - - - - - - - 0 1 0 0 | c
288 //- - - - d - - - - - - - - - - - - 1 1 0 0 | d
289 //- - - - - e - - - - - - - - - - - 0 0 1 0 | e
290 //- - - - - - f - - - - - - - - - - 1 0 1 0 | f
291 //- - - - - - - g - - - - - - - - - 0 1 1 0 | g
292 //- - - - - - - - h - - - - - - - - 1 1 1 0 | h
293 //- - - - - - - - - i - - - - - - - 0 0 0 1 | i
294 //- - - - - - - - - - j - - - - - - 1 0 0 1 | j
295 //- - - - - - - - - - - k - - - - - 0 1 0 1 | k
296 //- - - - - - - - - - - - l - - - - 1 1 0 1 | l
297 //- - - - - - - - - - - - - m - - - 0 0 1 1 | m
298 //- - - - - - - - - - - - - - n - - 1 0 1 1 | n
299 //- - - - - - - - - - - - - - - o - 0 1 1 1 | o
300 //- - - - - - - - - - - - - - - - p 1 1 1 1 | p
301 //-
302 module \$_MUX16_ (A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, S, T, U, V, Y);
303 input A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, S, T, U, V;
304 output Y;
305 assign Y = V ? U ? T ? (S ? P : O) :
306 (S ? N : M) :
307 T ? (S ? L : K) :
308 (S ? J : I) :
309 U ? T ? (S ? H : G) :
310 (S ? F : E) :
311 T ? (S ? D : C) :
312 (S ? B : A);
313 endmodule
314
315 // |---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|
316 //-
317 //- $_AOI3_ (A, B, C, Y)
318 //-
319 //- A 3-input And-Or-Invert gate.
320 //-
321 //- Truth table: A B C | Y
322 //- -------+---
323 //- 0 0 0 | 1
324 //- 0 0 1 | 0
325 //- 0 1 0 | 1
326 //- 0 1 1 | 0
327 //- 1 0 0 | 1
328 //- 1 0 1 | 0
329 //- 1 1 0 | 0
330 //- 1 1 1 | 0
331 //-
332 module \$_AOI3_ (A, B, C, Y);
333 input A, B, C;
334 output Y;
335 assign Y = ~((A & B) | C);
336 endmodule
337
338 // |---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|
339 //-
340 //- $_OAI3_ (A, B, C, Y)
341 //-
342 //- A 3-input Or-And-Invert gate.
343 //-
344 //- Truth table: A B C | Y
345 //- -------+---
346 //- 0 0 0 | 1
347 //- 0 0 1 | 1
348 //- 0 1 0 | 1
349 //- 0 1 1 | 0
350 //- 1 0 0 | 1
351 //- 1 0 1 | 0
352 //- 1 1 0 | 1
353 //- 1 1 1 | 0
354 //-
355 module \$_OAI3_ (A, B, C, Y);
356 input A, B, C;
357 output Y;
358 assign Y = ~((A | B) & C);
359 endmodule
360
361 // |---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|
362 //-
363 //- $_AOI4_ (A, B, C, Y)
364 //-
365 //- A 4-input And-Or-Invert gate.
366 //-
367 //- Truth table: A B C D | Y
368 //- ---------+---
369 //- 0 0 0 0 | 1
370 //- 0 0 0 1 | 1
371 //- 0 0 1 0 | 1
372 //- 0 0 1 1 | 0
373 //- 0 1 0 0 | 1
374 //- 0 1 0 1 | 1
375 //- 0 1 1 0 | 1
376 //- 0 1 1 1 | 0
377 //- 1 0 0 0 | 1
378 //- 1 0 0 1 | 1
379 //- 1 0 1 0 | 1
380 //- 1 0 1 1 | 0
381 //- 1 1 0 0 | 0
382 //- 1 1 0 1 | 0
383 //- 1 1 1 0 | 0
384 //- 1 1 1 1 | 0
385 //-
386 module \$_AOI4_ (A, B, C, D, Y);
387 input A, B, C, D;
388 output Y;
389 assign Y = ~((A & B) | (C & D));
390 endmodule
391
392 // |---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|
393 //-
394 //- $_OAI4_ (A, B, C, Y)
395 //-
396 //- A 4-input Or-And-Invert gate.
397 //-
398 //- Truth table: A B C D | Y
399 //- ---------+---
400 //- 0 0 0 0 | 1
401 //- 0 0 0 1 | 1
402 //- 0 0 1 0 | 1
403 //- 0 0 1 1 | 1
404 //- 0 1 0 0 | 1
405 //- 0 1 0 1 | 0
406 //- 0 1 1 0 | 0
407 //- 0 1 1 1 | 0
408 //- 1 0 0 0 | 1
409 //- 1 0 0 1 | 0
410 //- 1 0 1 0 | 0
411 //- 1 0 1 1 | 0
412 //- 1 1 0 0 | 1
413 //- 1 1 0 1 | 0
414 //- 1 1 1 0 | 0
415 //- 1 1 1 1 | 0
416 //-
417 module \$_OAI4_ (A, B, C, D, Y);
418 input A, B, C, D;
419 output Y;
420 assign Y = ~((A | B) & (C | D));
421 endmodule
422
423 // |---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|
424 //-
425 //- $_TBUF_ (A, E, Y)
426 //-
427 //- A tri-state buffer.
428 //-
429 //- Truth table: A E | Y
430 //- -----+---
431 //- a 1 | a
432 //- - 0 | z
433 //-
434 module \$_TBUF_ (A, E, Y);
435 input A, E;
436 output Y;
437 assign Y = E ? A : 1'bz;
438 endmodule
439
440 // |---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|
441 //-
442 //- $_SR_NN_ (S, R, Q)
443 //-
444 //- A set-reset latch with negative polarity SET and RESET.
445 //-
446 //- Truth table: S R | Q
447 //- -----+---
448 //- 0 0 | x
449 //- 0 1 | 1
450 //- 1 0 | 0
451 //- 1 1 | y
452 //-
453 module \$_SR_NN_ (S, R, Q);
454 input S, R;
455 output reg Q;
456 always @(negedge S, negedge R) begin
457 if (R == 0)
458 Q <= 0;
459 else if (S == 0)
460 Q <= 1;
461 end
462 endmodule
463
464 // |---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|
465 //-
466 //- $_SR_NP_ (S, R, Q)
467 //-
468 //- A set-reset latch with negative polarity SET and positive polarity RESET.
469 //-
470 //- Truth table: S R | Q
471 //- -----+---
472 //- 0 1 | x
473 //- 0 0 | 1
474 //- 1 1 | 0
475 //- 1 0 | y
476 //-
477 module \$_SR_NP_ (S, R, Q);
478 input S, R;
479 output reg Q;
480 always @(negedge S, posedge R) begin
481 if (R == 1)
482 Q <= 0;
483 else if (S == 0)
484 Q <= 1;
485 end
486 endmodule
487
488 // |---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|
489 //-
490 //- $_SR_PN_ (S, R, Q)
491 //-
492 //- A set-reset latch with positive polarity SET and negative polarity RESET.
493 //-
494 //- Truth table: S R | Q
495 //- -----+---
496 //- 1 0 | x
497 //- 1 1 | 1
498 //- 0 0 | 0
499 //- 0 1 | y
500 //-
501 module \$_SR_PN_ (S, R, Q);
502 input S, R;
503 output reg Q;
504 always @(posedge S, negedge R) begin
505 if (R == 0)
506 Q <= 0;
507 else if (S == 1)
508 Q <= 1;
509 end
510 endmodule
511
512 // |---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|
513 //-
514 //- $_SR_PP_ (S, R, Q)
515 //-
516 //- A set-reset latch with positive polarity SET and RESET.
517 //-
518 //- Truth table: S R | Q
519 //- -----+---
520 //- 1 1 | x
521 //- 1 0 | 1
522 //- 0 1 | 0
523 //- 0 0 | y
524 //-
525 module \$_SR_PP_ (S, R, Q);
526 input S, R;
527 output reg Q;
528 always @(posedge S, posedge R) begin
529 if (R == 1)
530 Q <= 0;
531 else if (S == 1)
532 Q <= 1;
533 end
534 endmodule
535
536 `ifdef SIMCELLS_FF
537 // |---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|
538 //-
539 //- $_FF_ (D, Q)
540 //-
541 //- A D-type flip-flop that is clocked from the implicit global clock. (This cell
542 //- type is usually only used in netlists for formal verification.)
543 //-
544 module \$_FF_ (D, Q);
545 input D;
546 output reg Q;
547 always @($global_clock) begin
548 Q <= D;
549 end
550 endmodule
551 `endif
552
553 // |---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|
554 //-
555 //- $_DFF_N_ (D, C, Q)
556 //-
557 //- A negative edge D-type flip-flop.
558 //-
559 //- Truth table: D C | Q
560 //- -----+---
561 //- d \ | d
562 //- - - | q
563 //-
564 module \$_DFF_N_ (D, C, Q);
565 input D, C;
566 output reg Q;
567 always @(negedge C) begin
568 Q <= D;
569 end
570 endmodule
571
572 // |---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|
573 //-
574 //- $_DFF_P_ (D, C, Q)
575 //-
576 //- A positive edge D-type flip-flop.
577 //-
578 //- Truth table: D C | Q
579 //- -----+---
580 //- d / | d
581 //- - - | q
582 //-
583 module \$_DFF_P_ (D, C, Q);
584 input D, C;
585 output reg Q;
586 always @(posedge C) begin
587 Q <= D;
588 end
589 endmodule
590
591 // |---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|
592 //-
593 //- $_DFFE_NN_ (D, C, E, Q)
594 //-
595 //- A negative edge D-type flip-flop with negative polarity enable.
596 //-
597 //- Truth table: D C E | Q
598 //- -------+---
599 //- d \ 0 | d
600 //- - - - | q
601 //-
602 module \$_DFFE_NN_ (D, C, E, Q);
603 input D, C, E;
604 output reg Q;
605 always @(negedge C) begin
606 if (!E) Q <= D;
607 end
608 endmodule
609
610 // |---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|
611 //-
612 //- $_DFFE_NP_ (D, C, E, Q)
613 //-
614 //- A negative edge D-type flip-flop with positive polarity enable.
615 //-
616 //- Truth table: D C E | Q
617 //- -------+---
618 //- d \ 1 | d
619 //- - - - | q
620 //-
621 module \$_DFFE_NP_ (D, C, E, Q);
622 input D, C, E;
623 output reg Q;
624 always @(negedge C) begin
625 if (E) Q <= D;
626 end
627 endmodule
628
629 // |---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|
630 //-
631 //- $_DFFE_PN_ (D, C, E, Q)
632 //-
633 //- A positive edge D-type flip-flop with negative polarity enable.
634 //-
635 //- Truth table: D C E | Q
636 //- -------+---
637 //- d / 0 | d
638 //- - - - | q
639 //-
640 module \$_DFFE_PN_ (D, C, E, Q);
641 input D, C, E;
642 output reg Q;
643 always @(posedge C) begin
644 if (!E) Q <= D;
645 end
646 endmodule
647
648 // |---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|
649 //-
650 //- $_DFFE_PP_ (D, C, E, Q)
651 //-
652 //- A positive edge D-type flip-flop with positive polarity enable.
653 //-
654 //- Truth table: D C E | Q
655 //- -------+---
656 //- d / 1 | d
657 //- - - - | q
658 //-
659 module \$_DFFE_PP_ (D, C, E, Q);
660 input D, C, E;
661 output reg Q;
662 always @(posedge C) begin
663 if (E) Q <= D;
664 end
665 endmodule
666
667 // |---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|
668 //-
669 //- $_DFF_NN0_ (D, C, R, Q)
670 //-
671 //- A negative edge D-type flip-flop with negative polarity reset.
672 //-
673 //- Truth table: D C R | Q
674 //- -------+---
675 //- - - 0 | 0
676 //- d \ - | d
677 //- - - - | q
678 //-
679 module \$_DFF_NN0_ (D, C, R, Q);
680 input D, C, R;
681 output reg Q;
682 always @(negedge C or negedge R) begin
683 if (R == 0)
684 Q <= 0;
685 else
686 Q <= D;
687 end
688 endmodule
689
690 // |---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|
691 //-
692 //- $_DFF_NN1_ (D, C, R, Q)
693 //-
694 //- A negative edge D-type flip-flop with negative polarity set.
695 //-
696 //- Truth table: D C R | Q
697 //- -------+---
698 //- - - 0 | 1
699 //- d \ - | d
700 //- - - - | q
701 //-
702 module \$_DFF_NN1_ (D, C, R, Q);
703 input D, C, R;
704 output reg Q;
705 always @(negedge C or negedge R) begin
706 if (R == 0)
707 Q <= 1;
708 else
709 Q <= D;
710 end
711 endmodule
712
713 // |---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|
714 //-
715 //- $_DFF_NP0_ (D, C, R, Q)
716 //-
717 //- A negative edge D-type flip-flop with positive polarity reset.
718 //-
719 //- Truth table: D C R | Q
720 //- -------+---
721 //- - - 1 | 0
722 //- d \ - | d
723 //- - - - | q
724 //-
725 module \$_DFF_NP0_ (D, C, R, Q);
726 input D, C, R;
727 output reg Q;
728 always @(negedge C or posedge R) begin
729 if (R == 1)
730 Q <= 0;
731 else
732 Q <= D;
733 end
734 endmodule
735
736 // |---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|
737 //-
738 //- $_DFF_NP1_ (D, C, R, Q)
739 //-
740 //- A negative edge D-type flip-flop with positive polarity set.
741 //-
742 //- Truth table: D C R | Q
743 //- -------+---
744 //- - - 1 | 1
745 //- d \ - | d
746 //- - - - | q
747 //-
748 module \$_DFF_NP1_ (D, C, R, Q);
749 input D, C, R;
750 output reg Q;
751 always @(negedge C or posedge R) begin
752 if (R == 1)
753 Q <= 1;
754 else
755 Q <= D;
756 end
757 endmodule
758
759 // |---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|
760 //-
761 //- $_DFF_PN0_ (D, C, R, Q)
762 //-
763 //- A positive edge D-type flip-flop with negative polarity reset.
764 //-
765 //- Truth table: D C R | Q
766 //- -------+---
767 //- - - 0 | 0
768 //- d / - | d
769 //- - - - | q
770 //-
771 module \$_DFF_PN0_ (D, C, R, Q);
772 input D, C, R;
773 output reg Q;
774 always @(posedge C or negedge R) begin
775 if (R == 0)
776 Q <= 0;
777 else
778 Q <= D;
779 end
780 endmodule
781
782 // |---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|
783 //-
784 //- $_DFF_PN1_ (D, C, R, Q)
785 //-
786 //- A positive edge D-type flip-flop with negative polarity set.
787 //-
788 //- Truth table: D C R | Q
789 //- -------+---
790 //- - - 0 | 1
791 //- d / - | d
792 //- - - - | q
793 //-
794 module \$_DFF_PN1_ (D, C, R, Q);
795 input D, C, R;
796 output reg Q;
797 always @(posedge C or negedge R) begin
798 if (R == 0)
799 Q <= 1;
800 else
801 Q <= D;
802 end
803 endmodule
804
805 // |---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|
806 //-
807 //- $_DFF_PP0_ (D, C, R, Q)
808 //-
809 //- A positive edge D-type flip-flop with positive polarity reset.
810 //-
811 //- Truth table: D C R | Q
812 //- -------+---
813 //- - - 1 | 0
814 //- d / - | d
815 //- - - - | q
816 //-
817 module \$_DFF_PP0_ (D, C, R, Q);
818 input D, C, R;
819 output reg Q;
820 always @(posedge C or posedge R) begin
821 if (R == 1)
822 Q <= 0;
823 else
824 Q <= D;
825 end
826 endmodule
827
828 // |---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|
829 //-
830 //- $_DFF_PP1_ (D, C, R, Q)
831 //-
832 //- A positive edge D-type flip-flop with positive polarity set.
833 //-
834 //- Truth table: D C R | Q
835 //- -------+---
836 //- - - 1 | 1
837 //- d / - | d
838 //- - - - | q
839 //-
840 module \$_DFF_PP1_ (D, C, R, Q);
841 input D, C, R;
842 output reg Q;
843 always @(posedge C or posedge R) begin
844 if (R == 1)
845 Q <= 1;
846 else
847 Q <= D;
848 end
849 endmodule
850
851 // |---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|
852 //-
853 //- $_DFFSR_NNN_ (C, S, R, D, Q)
854 //-
855 //- A negative edge D-type flip-flop with negative polarity set and reset.
856 //-
857 //- Truth table: C S R D | Q
858 //- ---------+---
859 //- - - 0 - | 0
860 //- - 0 - - | 1
861 //- \ - - d | d
862 //- - - - - | q
863 //-
864 module \$_DFFSR_NNN_ (C, S, R, D, Q);
865 input C, S, R, D;
866 output reg Q;
867 always @(negedge C, negedge S, negedge R) begin
868 if (R == 0)
869 Q <= 0;
870 else if (S == 0)
871 Q <= 1;
872 else
873 Q <= D;
874 end
875 endmodule
876
877 // |---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|
878 //-
879 //- $_DFFSR_NNP_ (C, S, R, D, Q)
880 //-
881 //- A negative edge D-type flip-flop with negative polarity set and positive
882 //- polarity reset.
883 //-
884 //- Truth table: C S R D | Q
885 //- ---------+---
886 //- - - 1 - | 0
887 //- - 0 - - | 1
888 //- \ - - d | d
889 //- - - - - | q
890 //-
891 module \$_DFFSR_NNP_ (C, S, R, D, Q);
892 input C, S, R, D;
893 output reg Q;
894 always @(negedge C, negedge S, posedge R) begin
895 if (R == 1)
896 Q <= 0;
897 else if (S == 0)
898 Q <= 1;
899 else
900 Q <= D;
901 end
902 endmodule
903
904 // |---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|
905 //-
906 //- $_DFFSR_NPN_ (C, S, R, D, Q)
907 //-
908 //- A negative edge D-type flip-flop with positive polarity set and negative
909 //- polarity reset.
910 //-
911 //- Truth table: C S R D | Q
912 //- ---------+---
913 //- - - 0 - | 0
914 //- - 1 - - | 1
915 //- \ - - d | d
916 //- - - - - | q
917 //-
918 module \$_DFFSR_NPN_ (C, S, R, D, Q);
919 input C, S, R, D;
920 output reg Q;
921 always @(negedge C, posedge S, negedge R) begin
922 if (R == 0)
923 Q <= 0;
924 else if (S == 1)
925 Q <= 1;
926 else
927 Q <= D;
928 end
929 endmodule
930
931 // |---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|
932 //-
933 //- $_DFFSR_NPP_ (C, S, R, D, Q)
934 //-
935 //- A negative edge D-type flip-flop with positive polarity set and reset.
936 //-
937 //- Truth table: C S R D | Q
938 //- ---------+---
939 //- - - 1 - | 0
940 //- - 1 - - | 1
941 //- \ - - d | d
942 //- - - - - | q
943 //-
944 module \$_DFFSR_NPP_ (C, S, R, D, Q);
945 input C, S, R, D;
946 output reg Q;
947 always @(negedge C, posedge S, posedge R) begin
948 if (R == 1)
949 Q <= 0;
950 else if (S == 1)
951 Q <= 1;
952 else
953 Q <= D;
954 end
955 endmodule
956
957 // |---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|
958 //-
959 //- $_DFFSR_PNN_ (C, S, R, D, Q)
960 //-
961 //- A positive edge D-type flip-flop with negative polarity set and reset.
962 //-
963 //- Truth table: C S R D | Q
964 //- ---------+---
965 //- - - 0 - | 0
966 //- - 0 - - | 1
967 //- / - - d | d
968 //- - - - - | q
969 //-
970 module \$_DFFSR_PNN_ (C, S, R, D, Q);
971 input C, S, R, D;
972 output reg Q;
973 always @(posedge C, negedge S, negedge R) begin
974 if (R == 0)
975 Q <= 0;
976 else if (S == 0)
977 Q <= 1;
978 else
979 Q <= D;
980 end
981 endmodule
982
983 // |---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|
984 //-
985 //- $_DFFSR_PNP_ (C, S, R, D, Q)
986 //-
987 //- A positive edge D-type flip-flop with negative polarity set and positive
988 //- polarity reset.
989 //-
990 //- Truth table: C S R D | Q
991 //- ---------+---
992 //- - - 1 - | 0
993 //- - 0 - - | 1
994 //- / - - d | d
995 //- - - - - | q
996 //-
997 module \$_DFFSR_PNP_ (C, S, R, D, Q);
998 input C, S, R, D;
999 output reg Q;
1000 always @(posedge C, negedge S, posedge R) begin
1001 if (R == 1)
1002 Q <= 0;
1003 else if (S == 0)
1004 Q <= 1;
1005 else
1006 Q <= D;
1007 end
1008 endmodule
1009
1010 // |---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|
1011 //-
1012 //- $_DFFSR_PPN_ (C, S, R, D, Q)
1013 //-
1014 //- A positive edge D-type flip-flop with positive polarity set and negative
1015 //- polarity reset.
1016 //-
1017 //- Truth table: C S R D | Q
1018 //- ---------+---
1019 //- - - 0 - | 0
1020 //- - 1 - - | 1
1021 //- / - - d | d
1022 //- - - - - | q
1023 //-
1024 module \$_DFFSR_PPN_ (C, S, R, D, Q);
1025 input C, S, R, D;
1026 output reg Q;
1027 always @(posedge C, posedge S, negedge R) begin
1028 if (R == 0)
1029 Q <= 0;
1030 else if (S == 1)
1031 Q <= 1;
1032 else
1033 Q <= D;
1034 end
1035 endmodule
1036
1037 // |---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|
1038 //-
1039 //- $_DFFSR_PPP_ (C, S, R, D, Q)
1040 //-
1041 //- A positive edge D-type flip-flop with positive polarity set and reset.
1042 //-
1043 //- Truth table: C S R D | Q
1044 //- ---------+---
1045 //- - - 1 - | 0
1046 //- - 1 - - | 1
1047 //- / - - d | d
1048 //- - - - - | q
1049 //-
1050 module \$_DFFSR_PPP_ (C, S, R, D, Q);
1051 input C, S, R, D;
1052 output reg Q;
1053 always @(posedge C, posedge S, posedge R) begin
1054 if (R == 1)
1055 Q <= 0;
1056 else if (S == 1)
1057 Q <= 1;
1058 else
1059 Q <= D;
1060 end
1061 endmodule
1062
1063 // |---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|
1064 //-
1065 //- $_DLATCH_N_ (E, D, Q)
1066 //-
1067 //- A negative enable D-type latch.
1068 //-
1069 //- Truth table: E D | Q
1070 //- -----+---
1071 //- 0 d | d
1072 //- - - | q
1073 //-
1074 module \$_DLATCH_N_ (E, D, Q);
1075 input E, D;
1076 output reg Q;
1077 always @* begin
1078 if (E == 0)
1079 Q <= D;
1080 end
1081 endmodule
1082
1083 // |---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|
1084 //-
1085 //- $_DLATCH_P_ (E, D, Q)
1086 //-
1087 //- A positive enable D-type latch.
1088 //-
1089 //- Truth table: E D | Q
1090 //- -----+---
1091 //- 1 d | d
1092 //- - - | q
1093 //-
1094 module \$_DLATCH_P_ (E, D, Q);
1095 input E, D;
1096 output reg Q;
1097 always @* begin
1098 if (E == 1)
1099 Q <= D;
1100 end
1101 endmodule
1102
1103 // |---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|
1104 //-
1105 //- $_DLATCHSR_NNN_ (E, S, R, D, Q)
1106 //-
1107 //- A negative enable D-type latch with negative polarity set and reset.
1108 //-
1109 //- Truth table: E S R D | Q
1110 //- ---------+---
1111 //- - - 0 - | 0
1112 //- - 0 - - | 1
1113 //- 0 - - d | d
1114 //- - - - - | q
1115 //-
1116 module \$_DLATCHSR_NNN_ (E, S, R, D, Q);
1117 input E, S, R, D;
1118 output reg Q;
1119 always @* begin
1120 if (R == 0)
1121 Q <= 0;
1122 else if (S == 0)
1123 Q <= 1;
1124 else if (E == 0)
1125 Q <= D;
1126 end
1127 endmodule
1128
1129 // |---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|
1130 //-
1131 //- $_DLATCHSR_NNP_ (E, S, R, D, Q)
1132 //-
1133 //- A negative enable D-type latch with negative polarity set and positive polarity
1134 //- reset.
1135 //-
1136 //- Truth table: E S R D | Q
1137 //- ---------+---
1138 //- - - 1 - | 0
1139 //- - 0 - - | 1
1140 //- 0 - - d | d
1141 //- - - - - | q
1142 //-
1143 module \$_DLATCHSR_NNP_ (E, S, R, D, Q);
1144 input E, S, R, D;
1145 output reg Q;
1146 always @* begin
1147 if (R == 1)
1148 Q <= 0;
1149 else if (S == 0)
1150 Q <= 1;
1151 else if (E == 0)
1152 Q <= D;
1153 end
1154 endmodule
1155
1156 // |---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|
1157 //-
1158 //- $_DLATCHSR_NPN_ (E, S, R, D, Q)
1159 //-
1160 //- A negative enable D-type latch with positive polarity set and negative polarity
1161 //- reset.
1162 //-
1163 //- Truth table: E S R D | Q
1164 //- ---------+---
1165 //- - - 0 - | 0
1166 //- - 1 - - | 1
1167 //- 0 - - d | d
1168 //- - - - - | q
1169 //-
1170 module \$_DLATCHSR_NPN_ (E, S, R, D, Q);
1171 input E, S, R, D;
1172 output reg Q;
1173 always @* begin
1174 if (R == 0)
1175 Q <= 0;
1176 else if (S == 1)
1177 Q <= 1;
1178 else if (E == 0)
1179 Q <= D;
1180 end
1181 endmodule
1182
1183 // |---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|
1184 //-
1185 //- $_DLATCHSR_NPP_ (E, S, R, D, Q)
1186 //-
1187 //- A negative enable D-type latch with positive polarity set and reset.
1188 //-
1189 //- Truth table: E S R D | Q
1190 //- ---------+---
1191 //- - - 1 - | 0
1192 //- - 1 - - | 1
1193 //- 0 - - d | d
1194 //- - - - - | q
1195 //-
1196 module \$_DLATCHSR_NPP_ (E, S, R, D, Q);
1197 input E, S, R, D;
1198 output reg Q;
1199 always @* begin
1200 if (R == 1)
1201 Q <= 0;
1202 else if (S == 1)
1203 Q <= 1;
1204 else if (E == 0)
1205 Q <= D;
1206 end
1207 endmodule
1208
1209 // |---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|
1210 //-
1211 //- $_DLATCHSR_PNN_ (E, S, R, D, Q)
1212 //-
1213 //- A positive enable D-type latch with negative polarity set and reset.
1214 //-
1215 //- Truth table: E S R D | Q
1216 //- ---------+---
1217 //- - - 0 - | 0
1218 //- - 0 - - | 1
1219 //- 1 - - d | d
1220 //- - - - - | q
1221 //-
1222 module \$_DLATCHSR_PNN_ (E, S, R, D, Q);
1223 input E, S, R, D;
1224 output reg Q;
1225 always @* begin
1226 if (R == 0)
1227 Q <= 0;
1228 else if (S == 0)
1229 Q <= 1;
1230 else if (E == 1)
1231 Q <= D;
1232 end
1233 endmodule
1234
1235 // |---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|
1236 //-
1237 //- $_DLATCHSR_PNP_ (E, S, R, D, Q)
1238 //-
1239 //- A positive enable D-type latch with negative polarity set and positive polarity
1240 //- reset.
1241 //-
1242 //- Truth table: E S R D | Q
1243 //- ---------+---
1244 //- - - 1 - | 0
1245 //- - 0 - - | 1
1246 //- 1 - - d | d
1247 //- - - - - | q
1248 //-
1249 module \$_DLATCHSR_PNP_ (E, S, R, D, Q);
1250 input E, S, R, D;
1251 output reg Q;
1252 always @* begin
1253 if (R == 1)
1254 Q <= 0;
1255 else if (S == 0)
1256 Q <= 1;
1257 else if (E == 1)
1258 Q <= D;
1259 end
1260 endmodule
1261
1262 // |---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|
1263 //-
1264 //- $_DLATCHSR_PPN_ (E, S, R, D, Q)
1265 //-
1266 //- A positive enable D-type latch with positive polarity set and negative polarity
1267 //- reset.
1268 //-
1269 //- Truth table: E S R D | Q
1270 //- ---------+---
1271 //- - - 0 - | 0
1272 //- - 1 - - | 1
1273 //- 1 - - d | d
1274 //- - - - - | q
1275 //-
1276 module \$_DLATCHSR_PPN_ (E, S, R, D, Q);
1277 input E, S, R, D;
1278 output reg Q;
1279 always @* begin
1280 if (R == 0)
1281 Q <= 0;
1282 else if (S == 1)
1283 Q <= 1;
1284 else if (E == 1)
1285 Q <= D;
1286 end
1287 endmodule
1288
1289 // |---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|
1290 //-
1291 //- $_DLATCHSR_PPP_ (E, S, R, D, Q)
1292 //-
1293 //- A positive enable D-type latch with positive polarity set and reset.
1294 //-
1295 //- Truth table: E S R D | Q
1296 //- ---------+---
1297 //- - - 1 - | 0
1298 //- - 1 - - | 1
1299 //- 1 - - d | d
1300 //- - - - - | q
1301 //-
1302 module \$_DLATCHSR_PPP_ (E, S, R, D, Q);
1303 input E, S, R, D;
1304 output reg Q;
1305 always @* begin
1306 if (R == 1)
1307 Q <= 0;
1308 else if (S == 1)
1309 Q <= 1;
1310 else if (E == 1)
1311 Q <= D;
1312 end
1313 endmodule
1314