1315 lines
30 KiB
Verilog
1315 lines
30 KiB
Verilog
/*
|
|
* yosys -- Yosys Open SYnthesis Suite
|
|
*
|
|
* Copyright (C) 2012 Clifford Wolf <clifford@clifford.at>
|
|
*
|
|
* Permission to use, copy, modify, and/or distribute this software for any
|
|
* purpose with or without fee is hereby granted, provided that the above
|
|
* copyright notice and this permission notice appear in all copies.
|
|
*
|
|
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
*
|
|
* ---
|
|
*
|
|
* The internal logic cell simulation library.
|
|
*
|
|
* This Verilog library contains simple simulation models for the internal
|
|
* logic cells ($_NOT , $_AND , ...) that are generated by the default technology
|
|
* mapper (see "techmap.v" in this directory) and expected by the "abc" pass.
|
|
*
|
|
*/
|
|
|
|
// |---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|
|
|
//-
|
|
//- $_BUF (A, Y)
|
|
//-
|
|
//- A buffer. This cell type is always optimized away by the opt_clean pass.
|
|
//-
|
|
//- Truth table: A | Y
|
|
//- ---+---
|
|
//- 0 | 0
|
|
//- 1 | 1
|
|
//-
|
|
module BUF (A, Y);
|
|
input A;
|
|
output Y;
|
|
assign Y = A;
|
|
endmodule
|
|
|
|
// |---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|
|
|
//-
|
|
//- $_NOT (A, Y)
|
|
//-
|
|
//- An inverter gate.
|
|
//-
|
|
//- Truth table: A | Y
|
|
//- ---+---
|
|
//- 0 | 1
|
|
//- 1 | 0
|
|
//-
|
|
module NOT (A, Y);
|
|
input A;
|
|
output Y;
|
|
assign Y = ~A;
|
|
endmodule
|
|
|
|
// |---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|
|
|
//-
|
|
//- $_AND (A, B, Y)
|
|
//-
|
|
//- A 2-input AND gate.
|
|
//-
|
|
//- Truth table: A B | Y
|
|
//- -----+---
|
|
//- 0 0 | 0
|
|
//- 0 1 | 0
|
|
//- 1 0 | 0
|
|
//- 1 1 | 1
|
|
//-
|
|
module AND (A, B, Y);
|
|
input A, B;
|
|
output Y;
|
|
assign Y = A & B;
|
|
endmodule
|
|
|
|
// |---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|
|
|
//-
|
|
//- $_NAND (A, B, Y)
|
|
//-
|
|
//- A 2-input NAND gate.
|
|
//-
|
|
//- Truth table: A B | Y
|
|
//- -----+---
|
|
//- 0 0 | 1
|
|
//- 0 1 | 1
|
|
//- 1 0 | 1
|
|
//- 1 1 | 0
|
|
//-
|
|
module NAND (A, B, Y);
|
|
input A, B;
|
|
output Y;
|
|
assign Y = ~(A & B);
|
|
endmodule
|
|
|
|
// |---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|
|
|
//-
|
|
//- $_OR (A, B, Y)
|
|
//-
|
|
//- A 2-input OR gate.
|
|
//-
|
|
//- Truth table: A B | Y
|
|
//- -----+---
|
|
//- 0 0 | 0
|
|
//- 0 1 | 1
|
|
//- 1 0 | 1
|
|
//- 1 1 | 1
|
|
//-
|
|
module OR (A, B, Y);
|
|
input A, B;
|
|
output Y;
|
|
assign Y = A | B;
|
|
endmodule
|
|
|
|
// |---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|
|
|
//-
|
|
//- $_NOR (A, B, Y)
|
|
//-
|
|
//- A 2-input NOR gate.
|
|
//-
|
|
//- Truth table: A B | Y
|
|
//- -----+---
|
|
//- 0 0 | 1
|
|
//- 0 1 | 0
|
|
//- 1 0 | 0
|
|
//- 1 1 | 0
|
|
//-
|
|
module NOR (A, B, Y);
|
|
input A, B;
|
|
output Y;
|
|
assign Y = ~(A | B);
|
|
endmodule
|
|
|
|
// |---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|
|
|
//-
|
|
//- $_XOR (A, B, Y)
|
|
//-
|
|
//- A 2-input XOR gate.
|
|
//-
|
|
//- Truth table: A B | Y
|
|
//- -----+---
|
|
//- 0 0 | 0
|
|
//- 0 1 | 1
|
|
//- 1 0 | 1
|
|
//- 1 1 | 0
|
|
//-
|
|
module XOR (A, B, Y);
|
|
input A, B;
|
|
output Y;
|
|
assign Y = A ^ B;
|
|
endmodule
|
|
|
|
// |---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|
|
|
//-
|
|
//- $_XNOR (A, B, Y)
|
|
//-
|
|
//- A 2-input XNOR gate.
|
|
//-
|
|
//- Truth table: A B | Y
|
|
//- -----+---
|
|
//- 0 0 | 1
|
|
//- 0 1 | 0
|
|
//- 1 0 | 0
|
|
//- 1 1 | 1
|
|
//-
|
|
module XNOR (A, B, Y);
|
|
input A, B;
|
|
output Y;
|
|
assign Y = ~(A ^ B);
|
|
endmodule
|
|
|
|
// |---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|
|
|
//-
|
|
//- $_ANDNOT (A, B, Y)
|
|
//-
|
|
//- A 2-input AND-NOT gate.
|
|
//-
|
|
//- Truth table: A B | Y
|
|
//- -----+---
|
|
//- 0 0 | 0
|
|
//- 0 1 | 0
|
|
//- 1 0 | 1
|
|
//- 1 1 | 0
|
|
//-
|
|
module ANDNOT (A, B, Y);
|
|
input A, B;
|
|
output Y;
|
|
assign Y = A & (~B);
|
|
endmodule
|
|
|
|
// |---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|
|
|
//-
|
|
//- $_ORNOT (A, B, Y)
|
|
//-
|
|
//- A 2-input OR-NOT gate.
|
|
//-
|
|
//- Truth table: A B | Y
|
|
//- -----+---
|
|
//- 0 0 | 1
|
|
//- 0 1 | 0
|
|
//- 1 0 | 1
|
|
//- 1 1 | 1
|
|
//-
|
|
module ORNOT (A, B, Y);
|
|
input A, B;
|
|
output Y;
|
|
assign Y = A | (~B);
|
|
endmodule
|
|
|
|
// |---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|
|
|
//-
|
|
//- $_MUX (A, B, S, Y)
|
|
//-
|
|
//- A 2-input MUX gate.
|
|
//-
|
|
//- Truth table: A B S | Y
|
|
//- -------+---
|
|
//- a - 0 | a
|
|
//- - b 1 | b
|
|
//-
|
|
module MUX (A, B, S, Y);
|
|
input A, B, S;
|
|
output Y;
|
|
assign Y = S ? B : A;
|
|
endmodule
|
|
|
|
// |---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|
|
|
//-
|
|
//- $_MUX4 (A, B, C, D, S, T, Y)
|
|
//-
|
|
//- A 4-input MUX gate.
|
|
//-
|
|
//- Truth table: A B C D S T | Y
|
|
//- -------------+---
|
|
//- a - - - 0 0 | a
|
|
//- - b - - 1 0 | b
|
|
//- - - c - 0 1 | c
|
|
//- - - - d 1 1 | d
|
|
//-
|
|
module MUX4 (A, B, C, D, S, T, Y);
|
|
input A, B, C, D, S, T;
|
|
output Y;
|
|
assign Y = T ? (S ? D : C) :
|
|
(S ? B : A);
|
|
endmodule
|
|
|
|
// |---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|
|
|
//-
|
|
//- $_MUX8 (A, B, C, D, E, F, G, H, S, T, U, Y)
|
|
//-
|
|
//- An 8-input MUX gate.
|
|
//-
|
|
//- Truth table: A B C D E F G H S T U | Y
|
|
//- -----------------------+---
|
|
//- a - - - - - - - 0 0 0 | a
|
|
//- - b - - - - - - 1 0 0 | b
|
|
//- - - c - - - - - 0 1 0 | c
|
|
//- - - - d - - - - 1 1 0 | d
|
|
//- - - - - e - - - 0 0 1 | e
|
|
//- - - - - - f - - 1 0 1 | f
|
|
//- - - - - - - g - 0 1 1 | g
|
|
//- - - - - - - - h 1 1 1 | h
|
|
//-
|
|
module MUX8 (A, B, C, D, E, F, G, H, S, T, U, Y);
|
|
input A, B, C, D, E, F, G, H, S, T, U;
|
|
output Y;
|
|
assign Y = U ? T ? (S ? H : G) :
|
|
(S ? F : E) :
|
|
T ? (S ? D : C) :
|
|
(S ? B : A);
|
|
endmodule
|
|
|
|
// |---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|
|
|
//-
|
|
//- $_MUX16 (A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, S, T, U, V, Y)
|
|
//-
|
|
//- A 16-input MUX gate.
|
|
//-
|
|
//- Truth table: A B C D E F G H I J K L M N O P S T U V | Y
|
|
//- -----------------------------------------+---
|
|
//- a - - - - - - - - - - - - - - - 0 0 0 0 | a
|
|
//- - b - - - - - - - - - - - - - - 1 0 0 0 | b
|
|
//- - - c - - - - - - - - - - - - - 0 1 0 0 | c
|
|
//- - - - d - - - - - - - - - - - - 1 1 0 0 | d
|
|
//- - - - - e - - - - - - - - - - - 0 0 1 0 | e
|
|
//- - - - - - f - - - - - - - - - - 1 0 1 0 | f
|
|
//- - - - - - - g - - - - - - - - - 0 1 1 0 | g
|
|
//- - - - - - - - h - - - - - - - - 1 1 1 0 | h
|
|
//- - - - - - - - - i - - - - - - - 0 0 0 1 | i
|
|
//- - - - - - - - - - j - - - - - - 1 0 0 1 | j
|
|
//- - - - - - - - - - - k - - - - - 0 1 0 1 | k
|
|
//- - - - - - - - - - - - l - - - - 1 1 0 1 | l
|
|
//- - - - - - - - - - - - - m - - - 0 0 1 1 | m
|
|
//- - - - - - - - - - - - - - n - - 1 0 1 1 | n
|
|
//- - - - - - - - - - - - - - - o - 0 1 1 1 | o
|
|
//- - - - - - - - - - - - - - - - p 1 1 1 1 | p
|
|
//-
|
|
module MUX16 (A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, S, T, U, V, Y);
|
|
input A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, S, T, U, V;
|
|
output Y;
|
|
assign Y = V ? U ? T ? (S ? P : O) :
|
|
(S ? N : M) :
|
|
T ? (S ? L : K) :
|
|
(S ? J : I) :
|
|
U ? T ? (S ? H : G) :
|
|
(S ? F : E) :
|
|
T ? (S ? D : C) :
|
|
(S ? B : A);
|
|
endmodule
|
|
|
|
// |---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|
|
|
//-
|
|
//- $_AOI3 (A, B, C, Y)
|
|
//-
|
|
//- A 3-input And-Or-Invert gate.
|
|
//-
|
|
//- Truth table: A B C | Y
|
|
//- -------+---
|
|
//- 0 0 0 | 1
|
|
//- 0 0 1 | 0
|
|
//- 0 1 0 | 1
|
|
//- 0 1 1 | 0
|
|
//- 1 0 0 | 1
|
|
//- 1 0 1 | 0
|
|
//- 1 1 0 | 0
|
|
//- 1 1 1 | 0
|
|
//-
|
|
module AOI3 (A, B, C, Y);
|
|
input A, B, C;
|
|
output Y;
|
|
assign Y = ~((A & B) | C);
|
|
endmodule
|
|
|
|
// |---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|
|
|
//-
|
|
//- $_OAI3 (A, B, C, Y)
|
|
//-
|
|
//- A 3-input Or-And-Invert gate.
|
|
//-
|
|
//- Truth table: A B C | Y
|
|
//- -------+---
|
|
//- 0 0 0 | 1
|
|
//- 0 0 1 | 1
|
|
//- 0 1 0 | 1
|
|
//- 0 1 1 | 0
|
|
//- 1 0 0 | 1
|
|
//- 1 0 1 | 0
|
|
//- 1 1 0 | 1
|
|
//- 1 1 1 | 0
|
|
//-
|
|
module OAI3 (A, B, C, Y);
|
|
input A, B, C;
|
|
output Y;
|
|
assign Y = ~((A | B) & C);
|
|
endmodule
|
|
|
|
// |---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|
|
|
//-
|
|
//- $_AOI4 (A, B, C, Y)
|
|
//-
|
|
//- A 4-input And-Or-Invert gate.
|
|
//-
|
|
//- Truth table: A B C D | Y
|
|
//- ---------+---
|
|
//- 0 0 0 0 | 1
|
|
//- 0 0 0 1 | 1
|
|
//- 0 0 1 0 | 1
|
|
//- 0 0 1 1 | 0
|
|
//- 0 1 0 0 | 1
|
|
//- 0 1 0 1 | 1
|
|
//- 0 1 1 0 | 1
|
|
//- 0 1 1 1 | 0
|
|
//- 1 0 0 0 | 1
|
|
//- 1 0 0 1 | 1
|
|
//- 1 0 1 0 | 1
|
|
//- 1 0 1 1 | 0
|
|
//- 1 1 0 0 | 0
|
|
//- 1 1 0 1 | 0
|
|
//- 1 1 1 0 | 0
|
|
//- 1 1 1 1 | 0
|
|
//-
|
|
module AOI4 (A, B, C, D, Y);
|
|
input A, B, C, D;
|
|
output Y;
|
|
assign Y = ~((A & B) | (C & D));
|
|
endmodule
|
|
|
|
// |---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|
|
|
//-
|
|
//- $_OAI4 (A, B, C, Y)
|
|
//-
|
|
//- A 4-input Or-And-Invert gate.
|
|
//-
|
|
//- Truth table: A B C D | Y
|
|
//- ---------+---
|
|
//- 0 0 0 0 | 1
|
|
//- 0 0 0 1 | 1
|
|
//- 0 0 1 0 | 1
|
|
//- 0 0 1 1 | 1
|
|
//- 0 1 0 0 | 1
|
|
//- 0 1 0 1 | 0
|
|
//- 0 1 1 0 | 0
|
|
//- 0 1 1 1 | 0
|
|
//- 1 0 0 0 | 1
|
|
//- 1 0 0 1 | 0
|
|
//- 1 0 1 0 | 0
|
|
//- 1 0 1 1 | 0
|
|
//- 1 1 0 0 | 1
|
|
//- 1 1 0 1 | 0
|
|
//- 1 1 1 0 | 0
|
|
//- 1 1 1 1 | 0
|
|
//-
|
|
module OAI4 (A, B, C, D, Y);
|
|
input A, B, C, D;
|
|
output Y;
|
|
assign Y = ~((A | B) & (C | D));
|
|
endmodule
|
|
|
|
// |---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|
|
|
//-
|
|
//- $_TBUF (A, E, Y)
|
|
//-
|
|
//- A tri-state buffer.
|
|
//-
|
|
//- Truth table: A E | Y
|
|
//- -----+---
|
|
//- a 1 | a
|
|
//- - 0 | z
|
|
//-
|
|
module TBUF (A, E, Y);
|
|
input A, E;
|
|
output Y;
|
|
assign Y = E ? A : 1'bz;
|
|
endmodule
|
|
|
|
// |---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|
|
|
//-
|
|
//- $_SR_NN (S, R, Q)
|
|
//-
|
|
//- A set-reset latch with negative polarity SET and RESET.
|
|
//-
|
|
//- Truth table: S R | Q
|
|
//- -----+---
|
|
//- 0 0 | x
|
|
//- 0 1 | 1
|
|
//- 1 0 | 0
|
|
//- 1 1 | y
|
|
//-
|
|
module SR_NN (S, R, Q);
|
|
input S, R;
|
|
output reg Q;
|
|
always @(negedge S, negedge R) begin
|
|
if (R == 0)
|
|
Q <= 0;
|
|
else if (S == 0)
|
|
Q <= 1;
|
|
end
|
|
endmodule
|
|
|
|
// |---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|
|
|
//-
|
|
//- $_SR_NP (S, R, Q)
|
|
//-
|
|
//- A set-reset latch with negative polarity SET and positive polarity RESET.
|
|
//-
|
|
//- Truth table: S R | Q
|
|
//- -----+---
|
|
//- 0 1 | x
|
|
//- 0 0 | 1
|
|
//- 1 1 | 0
|
|
//- 1 0 | y
|
|
//-
|
|
module SR_NP (S, R, Q);
|
|
input S, R;
|
|
output reg Q;
|
|
always @(negedge S, posedge R) begin
|
|
if (R == 1)
|
|
Q <= 0;
|
|
else if (S == 0)
|
|
Q <= 1;
|
|
end
|
|
endmodule
|
|
|
|
// |---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|
|
|
//-
|
|
//- $_SR_PN (S, R, Q)
|
|
//-
|
|
//- A set-reset latch with positive polarity SET and negative polarity RESET.
|
|
//-
|
|
//- Truth table: S R | Q
|
|
//- -----+---
|
|
//- 1 0 | x
|
|
//- 1 1 | 1
|
|
//- 0 0 | 0
|
|
//- 0 1 | y
|
|
//-
|
|
module SR_PN (S, R, Q);
|
|
input S, R;
|
|
output reg Q;
|
|
always @(posedge S, negedge R) begin
|
|
if (R == 0)
|
|
Q <= 0;
|
|
else if (S == 1)
|
|
Q <= 1;
|
|
end
|
|
endmodule
|
|
|
|
// |---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|
|
|
//-
|
|
//- $_SR_PP (S, R, Q)
|
|
//-
|
|
//- A set-reset latch with positive polarity SET and RESET.
|
|
//-
|
|
//- Truth table: S R | Q
|
|
//- -----+---
|
|
//- 1 1 | x
|
|
//- 1 0 | 1
|
|
//- 0 1 | 0
|
|
//- 0 0 | y
|
|
//-
|
|
module SR_PP (S, R, Q);
|
|
input S, R;
|
|
output reg Q;
|
|
always @(posedge S, posedge R) begin
|
|
if (R == 1)
|
|
Q <= 0;
|
|
else if (S == 1)
|
|
Q <= 1;
|
|
end
|
|
endmodule
|
|
|
|
`ifdef SIMCELLS_FF
|
|
// |---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|
|
|
//-
|
|
//- $_FF (D, Q)
|
|
//-
|
|
//- A D-type flip-flop that is clocked from the implicit global clock. (This cell
|
|
//- type is usually only used in netlists for formal verification.)
|
|
//-
|
|
module FF (D, Q);
|
|
input D;
|
|
output reg Q;
|
|
always @($global_clock) begin
|
|
Q <= D;
|
|
end
|
|
endmodule
|
|
`endif
|
|
|
|
// |---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|
|
|
//-
|
|
//- $_DFF_N (D, C, Q)
|
|
//-
|
|
//- A negative edge D-type flip-flop.
|
|
//-
|
|
//- Truth table: D C | Q
|
|
//- -----+---
|
|
//- d \ | d
|
|
//- - - | q
|
|
//-
|
|
module DFF_N (D, C, Q);
|
|
input D, C;
|
|
output reg Q;
|
|
always @(negedge C) begin
|
|
Q <= D;
|
|
end
|
|
endmodule
|
|
|
|
// |---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|
|
|
//-
|
|
//- $_DFF_P (D, C, Q)
|
|
//-
|
|
//- A positive edge D-type flip-flop.
|
|
//-
|
|
//- Truth table: D C | Q
|
|
//- -----+---
|
|
//- d / | d
|
|
//- - - | q
|
|
//-
|
|
module DFF (D, C, Q);
|
|
input D, C;
|
|
output reg Q;
|
|
always @(posedge C) begin
|
|
Q <= D;
|
|
end
|
|
endmodule
|
|
|
|
// |---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|
|
|
//-
|
|
//- $_DFFE_NN (D, C, E, Q)
|
|
//-
|
|
//- A negative edge D-type flip-flop with negative polarity enable.
|
|
//-
|
|
//- Truth table: D C E | Q
|
|
//- -------+---
|
|
//- d \ 0 | d
|
|
//- - - - | q
|
|
//-
|
|
module DFFE_NN (D, C, E, Q);
|
|
input D, C, E;
|
|
output reg Q;
|
|
always @(negedge C) begin
|
|
if (!E) Q <= D;
|
|
end
|
|
endmodule
|
|
|
|
// |---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|
|
|
//-
|
|
//- $_DFFE_NP (D, C, E, Q)
|
|
//-
|
|
//- A negative edge D-type flip-flop with positive polarity enable.
|
|
//-
|
|
//- Truth table: D C E | Q
|
|
//- -------+---
|
|
//- d \ 1 | d
|
|
//- - - - | q
|
|
//-
|
|
module DFFE_NP (D, C, E, Q);
|
|
input D, C, E;
|
|
output reg Q;
|
|
always @(negedge C) begin
|
|
if (E) Q <= D;
|
|
end
|
|
endmodule
|
|
|
|
// |---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|
|
|
//-
|
|
//- $_DFFE_PN (D, C, E, Q)
|
|
//-
|
|
//- A positive edge D-type flip-flop with negative polarity enable.
|
|
//-
|
|
//- Truth table: D C E | Q
|
|
//- -------+---
|
|
//- d / 0 | d
|
|
//- - - - | q
|
|
//-
|
|
module DFFE_PN (D, C, E, Q);
|
|
input D, C, E;
|
|
output reg Q;
|
|
always @(posedge C) begin
|
|
if (!E) Q <= D;
|
|
end
|
|
endmodule
|
|
|
|
// |---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|
|
|
//-
|
|
//- $_DFFE_PP (D, C, E, Q)
|
|
//-
|
|
//- A positive edge D-type flip-flop with positive polarity enable.
|
|
//-
|
|
//- Truth table: D C E | Q
|
|
//- -------+---
|
|
//- d / 1 | d
|
|
//- - - - | q
|
|
//-
|
|
module DFFE_PP (D, C, E, Q);
|
|
input D, C, E;
|
|
output reg Q;
|
|
always @(posedge C) begin
|
|
if (E) Q <= D;
|
|
end
|
|
endmodule
|
|
|
|
// |---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|
|
|
//-
|
|
//- $_DFF_NN0 (D, C, R, Q)
|
|
//-
|
|
//- A negative edge D-type flip-flop with negative polarity reset.
|
|
//-
|
|
//- Truth table: D C R | Q
|
|
//- -------+---
|
|
//- - - 0 | 0
|
|
//- d \ - | d
|
|
//- - - - | q
|
|
//-
|
|
module DFF_NN0 (D, C, R, Q);
|
|
input D, C, R;
|
|
output reg Q;
|
|
always @(negedge C or negedge R) begin
|
|
if (R == 0)
|
|
Q <= 0;
|
|
else
|
|
Q <= D;
|
|
end
|
|
endmodule
|
|
|
|
// |---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|
|
|
//-
|
|
//- $_DFF_NN1 (D, C, R, Q)
|
|
//-
|
|
//- A negative edge D-type flip-flop with negative polarity set.
|
|
//-
|
|
//- Truth table: D C R | Q
|
|
//- -------+---
|
|
//- - - 0 | 1
|
|
//- d \ - | d
|
|
//- - - - | q
|
|
//-
|
|
module DFF_NN1 (D, C, R, Q);
|
|
input D, C, R;
|
|
output reg Q;
|
|
always @(negedge C or negedge R) begin
|
|
if (R == 0)
|
|
Q <= 1;
|
|
else
|
|
Q <= D;
|
|
end
|
|
endmodule
|
|
|
|
// |---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|
|
|
//-
|
|
//- $_DFF_NP0 (D, C, R, Q)
|
|
//-
|
|
//- A negative edge D-type flip-flop with positive polarity reset.
|
|
//-
|
|
//- Truth table: D C R | Q
|
|
//- -------+---
|
|
//- - - 1 | 0
|
|
//- d \ - | d
|
|
//- - - - | q
|
|
//-
|
|
module DFF_NP0 (D, C, R, Q);
|
|
input D, C, R;
|
|
output reg Q;
|
|
always @(negedge C or posedge R) begin
|
|
if (R == 1)
|
|
Q <= 0;
|
|
else
|
|
Q <= D;
|
|
end
|
|
endmodule
|
|
|
|
// |---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|
|
|
//-
|
|
//- $_DFF_NP1 (D, C, R, Q)
|
|
//-
|
|
//- A negative edge D-type flip-flop with positive polarity set.
|
|
//-
|
|
//- Truth table: D C R | Q
|
|
//- -------+---
|
|
//- - - 1 | 1
|
|
//- d \ - | d
|
|
//- - - - | q
|
|
//-
|
|
module DFF_NP1 (D, C, R, Q);
|
|
input D, C, R;
|
|
output reg Q;
|
|
always @(negedge C or posedge R) begin
|
|
if (R == 1)
|
|
Q <= 1;
|
|
else
|
|
Q <= D;
|
|
end
|
|
endmodule
|
|
|
|
// |---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|
|
|
//-
|
|
//- $_DFF_PN0 (D, C, R, Q)
|
|
//-
|
|
//- A positive edge D-type flip-flop with negative polarity reset.
|
|
//-
|
|
//- Truth table: D C R | Q
|
|
//- -------+---
|
|
//- - - 0 | 0
|
|
//- d / - | d
|
|
//- - - - | q
|
|
//-
|
|
module DFF_PN0 (D, C, R, Q);
|
|
input D, C, R;
|
|
output reg Q;
|
|
always @(posedge C or negedge R) begin
|
|
if (R == 0)
|
|
Q <= 0;
|
|
else
|
|
Q <= D;
|
|
end
|
|
endmodule
|
|
|
|
// |---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|
|
|
//-
|
|
//- $_DFF_PN1 (D, C, R, Q)
|
|
//-
|
|
//- A positive edge D-type flip-flop with negative polarity set.
|
|
//-
|
|
//- Truth table: D C R | Q
|
|
//- -------+---
|
|
//- - - 0 | 1
|
|
//- d / - | d
|
|
//- - - - | q
|
|
//-
|
|
module DFF_PN1 (D, C, R, Q);
|
|
input D, C, R;
|
|
output reg Q;
|
|
always @(posedge C or negedge R) begin
|
|
if (R == 0)
|
|
Q <= 1;
|
|
else
|
|
Q <= D;
|
|
end
|
|
endmodule
|
|
|
|
// |---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|
|
|
//-
|
|
//- $_DFF_PP0 (D, C, R, Q)
|
|
//-
|
|
//- A positive edge D-type flip-flop with positive polarity reset.
|
|
//-
|
|
//- Truth table: D C R | Q
|
|
//- -------+---
|
|
//- - - 1 | 0
|
|
//- d / - | d
|
|
//- - - - | q
|
|
//-
|
|
module DFF_PP0 (D, C, R, Q);
|
|
input D, C, R;
|
|
output reg Q;
|
|
always @(posedge C or posedge R) begin
|
|
if (R == 1)
|
|
Q <= 0;
|
|
else
|
|
Q <= D;
|
|
end
|
|
endmodule
|
|
|
|
// |---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|
|
|
//-
|
|
//- $_DFF_PP1 (D, C, R, Q)
|
|
//-
|
|
//- A positive edge D-type flip-flop with positive polarity set.
|
|
//-
|
|
//- Truth table: D C R | Q
|
|
//- -------+---
|
|
//- - - 1 | 1
|
|
//- d / - | d
|
|
//- - - - | q
|
|
//-
|
|
module DFF_PP1 (D, C, R, Q);
|
|
input D, C, R;
|
|
output reg Q;
|
|
always @(posedge C or posedge R) begin
|
|
if (R == 1)
|
|
Q <= 1;
|
|
else
|
|
Q <= D;
|
|
end
|
|
endmodule
|
|
|
|
// |---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|
|
|
//-
|
|
//- $_DFFSR_NNN (C, S, R, D, Q)
|
|
//-
|
|
//- A negative edge D-type flip-flop with negative polarity set and reset.
|
|
//-
|
|
//- Truth table: C S R D | Q
|
|
//- ---------+---
|
|
//- - - 0 - | 0
|
|
//- - 0 - - | 1
|
|
//- \ - - d | d
|
|
//- - - - - | q
|
|
//-
|
|
module DFFSR_NNN (C, S, R, D, Q);
|
|
input C, S, R, D;
|
|
output reg Q;
|
|
always @(negedge C, negedge S, negedge R) begin
|
|
if (R == 0)
|
|
Q <= 0;
|
|
else if (S == 0)
|
|
Q <= 1;
|
|
else
|
|
Q <= D;
|
|
end
|
|
endmodule
|
|
|
|
// |---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|
|
|
//-
|
|
//- $_DFFSR_NNP (C, S, R, D, Q)
|
|
//-
|
|
//- A negative edge D-type flip-flop with negative polarity set and positive
|
|
//- polarity reset.
|
|
//-
|
|
//- Truth table: C S R D | Q
|
|
//- ---------+---
|
|
//- - - 1 - | 0
|
|
//- - 0 - - | 1
|
|
//- \ - - d | d
|
|
//- - - - - | q
|
|
//-
|
|
module DFFSR_NNP (C, S, R, D, Q);
|
|
input C, S, R, D;
|
|
output reg Q;
|
|
always @(negedge C, negedge S, posedge R) begin
|
|
if (R == 1)
|
|
Q <= 0;
|
|
else if (S == 0)
|
|
Q <= 1;
|
|
else
|
|
Q <= D;
|
|
end
|
|
endmodule
|
|
|
|
// |---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|
|
|
//-
|
|
//- $_DFFSR_NPN (C, S, R, D, Q)
|
|
//-
|
|
//- A negative edge D-type flip-flop with positive polarity set and negative
|
|
//- polarity reset.
|
|
//-
|
|
//- Truth table: C S R D | Q
|
|
//- ---------+---
|
|
//- - - 0 - | 0
|
|
//- - 1 - - | 1
|
|
//- \ - - d | d
|
|
//- - - - - | q
|
|
//-
|
|
module DFFSR_NPN (C, S, R, D, Q);
|
|
input C, S, R, D;
|
|
output reg Q;
|
|
always @(negedge C, posedge S, negedge R) begin
|
|
if (R == 0)
|
|
Q <= 0;
|
|
else if (S == 1)
|
|
Q <= 1;
|
|
else
|
|
Q <= D;
|
|
end
|
|
endmodule
|
|
|
|
// |---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|
|
|
//-
|
|
//- $_DFFSR_NPP (C, S, R, D, Q)
|
|
//-
|
|
//- A negative edge D-type flip-flop with positive polarity set and reset.
|
|
//-
|
|
//- Truth table: C S R D | Q
|
|
//- ---------+---
|
|
//- - - 1 - | 0
|
|
//- - 1 - - | 1
|
|
//- \ - - d | d
|
|
//- - - - - | q
|
|
//-
|
|
module DFFSR_NPP (C, S, R, D, Q);
|
|
input C, S, R, D;
|
|
output reg Q;
|
|
always @(negedge C, posedge S, posedge R) begin
|
|
if (R == 1)
|
|
Q <= 0;
|
|
else if (S == 1)
|
|
Q <= 1;
|
|
else
|
|
Q <= D;
|
|
end
|
|
endmodule
|
|
|
|
// |---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|
|
|
//-
|
|
//- $_DFFSR_PNN (C, S, R, D, Q)
|
|
//-
|
|
//- A positive edge D-type flip-flop with negative polarity set and reset.
|
|
//-
|
|
//- Truth table: C S R D | Q
|
|
//- ---------+---
|
|
//- - - 0 - | 0
|
|
//- - 0 - - | 1
|
|
//- / - - d | d
|
|
//- - - - - | q
|
|
//-
|
|
module DFFSR_PNN (C, S, R, D, Q);
|
|
input C, S, R, D;
|
|
output reg Q;
|
|
always @(posedge C, negedge S, negedge R) begin
|
|
if (R == 0)
|
|
Q <= 0;
|
|
else if (S == 0)
|
|
Q <= 1;
|
|
else
|
|
Q <= D;
|
|
end
|
|
endmodule
|
|
|
|
// |---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|
|
|
//-
|
|
//- $_DFFSR_PNP (C, S, R, D, Q)
|
|
//-
|
|
//- A positive edge D-type flip-flop with negative polarity set and positive
|
|
//- polarity reset.
|
|
//-
|
|
//- Truth table: C S R D | Q
|
|
//- ---------+---
|
|
//- - - 1 - | 0
|
|
//- - 0 - - | 1
|
|
//- / - - d | d
|
|
//- - - - - | q
|
|
//-
|
|
module DFFSR_PNP (C, S, R, D, Q);
|
|
input C, S, R, D;
|
|
output reg Q;
|
|
always @(posedge C, negedge S, posedge R) begin
|
|
if (R == 1)
|
|
Q <= 0;
|
|
else if (S == 0)
|
|
Q <= 1;
|
|
else
|
|
Q <= D;
|
|
end
|
|
endmodule
|
|
|
|
// |---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|
|
|
//-
|
|
//- $_DFFSR_PPN (C, S, R, D, Q)
|
|
//-
|
|
//- A positive edge D-type flip-flop with positive polarity set and negative
|
|
//- polarity reset.
|
|
//-
|
|
//- Truth table: C S R D | Q
|
|
//- ---------+---
|
|
//- - - 0 - | 0
|
|
//- - 1 - - | 1
|
|
//- / - - d | d
|
|
//- - - - - | q
|
|
//-
|
|
module DFFSR_PPN (C, S, R, D, Q);
|
|
input C, S, R, D;
|
|
output reg Q;
|
|
always @(posedge C, posedge S, negedge R) begin
|
|
if (R == 0)
|
|
Q <= 0;
|
|
else if (S == 1)
|
|
Q <= 1;
|
|
else
|
|
Q <= D;
|
|
end
|
|
endmodule
|
|
|
|
// |---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|
|
|
//-
|
|
//- $_DFFSR_PPP (C, S, R, D, Q)
|
|
//-
|
|
//- A positive edge D-type flip-flop with positive polarity set and reset.
|
|
//-
|
|
//- Truth table: C S R D | Q
|
|
//- ---------+---
|
|
//- - - 1 - | 0
|
|
//- - 1 - - | 1
|
|
//- / - - d | d
|
|
//- - - - - | q
|
|
//-
|
|
module DFFSR_PPP (C, S, R, D, Q);
|
|
input C, S, R, D;
|
|
output reg Q;
|
|
always @(posedge C, posedge S, posedge R) begin
|
|
if (R == 1)
|
|
Q <= 0;
|
|
else if (S == 1)
|
|
Q <= 1;
|
|
else
|
|
Q <= D;
|
|
end
|
|
endmodule
|
|
|
|
// |---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|
|
|
//-
|
|
//- $_DLATCH_N (E, D, Q)
|
|
//-
|
|
//- A negative enable D-type latch.
|
|
//-
|
|
//- Truth table: E D | Q
|
|
//- -----+---
|
|
//- 0 d | d
|
|
//- - - | q
|
|
//-
|
|
module DLATCH_N (E, D, Q);
|
|
input E, D;
|
|
output reg Q;
|
|
always @* begin
|
|
if (E == 0)
|
|
Q <= D;
|
|
end
|
|
endmodule
|
|
|
|
// |---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|
|
|
//-
|
|
//- $_DLATCH_P (E, D, Q)
|
|
//-
|
|
//- A positive enable D-type latch.
|
|
//-
|
|
//- Truth table: E D | Q
|
|
//- -----+---
|
|
//- 1 d | d
|
|
//- - - | q
|
|
//-
|
|
module DLATCH_P (E, D, Q);
|
|
input E, D;
|
|
output reg Q;
|
|
always @* begin
|
|
if (E == 1)
|
|
Q <= D;
|
|
end
|
|
endmodule
|
|
|
|
// |---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|
|
|
//-
|
|
//- $_DLATCHSR_NNN (E, S, R, D, Q)
|
|
//-
|
|
//- A negative enable D-type latch with negative polarity set and reset.
|
|
//-
|
|
//- Truth table: E S R D | Q
|
|
//- ---------+---
|
|
//- - - 0 - | 0
|
|
//- - 0 - - | 1
|
|
//- 0 - - d | d
|
|
//- - - - - | q
|
|
//-
|
|
module DLATCHSR_NNN (E, S, R, D, Q);
|
|
input E, S, R, D;
|
|
output reg Q;
|
|
always @* begin
|
|
if (R == 0)
|
|
Q <= 0;
|
|
else if (S == 0)
|
|
Q <= 1;
|
|
else if (E == 0)
|
|
Q <= D;
|
|
end
|
|
endmodule
|
|
|
|
// |---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|
|
|
//-
|
|
//- $_DLATCHSR_NNP (E, S, R, D, Q)
|
|
//-
|
|
//- A negative enable D-type latch with negative polarity set and positive polarity
|
|
//- reset.
|
|
//-
|
|
//- Truth table: E S R D | Q
|
|
//- ---------+---
|
|
//- - - 1 - | 0
|
|
//- - 0 - - | 1
|
|
//- 0 - - d | d
|
|
//- - - - - | q
|
|
//-
|
|
module DLATCHSR_NNP (E, S, R, D, Q);
|
|
input E, S, R, D;
|
|
output reg Q;
|
|
always @* begin
|
|
if (R == 1)
|
|
Q <= 0;
|
|
else if (S == 0)
|
|
Q <= 1;
|
|
else if (E == 0)
|
|
Q <= D;
|
|
end
|
|
endmodule
|
|
|
|
// |---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|
|
|
//-
|
|
//- $_DLATCHSR_NPN (E, S, R, D, Q)
|
|
//-
|
|
//- A negative enable D-type latch with positive polarity set and negative polarity
|
|
//- reset.
|
|
//-
|
|
//- Truth table: E S R D | Q
|
|
//- ---------+---
|
|
//- - - 0 - | 0
|
|
//- - 1 - - | 1
|
|
//- 0 - - d | d
|
|
//- - - - - | q
|
|
//-
|
|
module DLATCHSR_NPN (E, S, R, D, Q);
|
|
input E, S, R, D;
|
|
output reg Q;
|
|
always @* begin
|
|
if (R == 0)
|
|
Q <= 0;
|
|
else if (S == 1)
|
|
Q <= 1;
|
|
else if (E == 0)
|
|
Q <= D;
|
|
end
|
|
endmodule
|
|
|
|
// |---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|
|
|
//-
|
|
//- $_DLATCHSR_NPP (E, S, R, D, Q)
|
|
//-
|
|
//- A negative enable D-type latch with positive polarity set and reset.
|
|
//-
|
|
//- Truth table: E S R D | Q
|
|
//- ---------+---
|
|
//- - - 1 - | 0
|
|
//- - 1 - - | 1
|
|
//- 0 - - d | d
|
|
//- - - - - | q
|
|
//-
|
|
module DLATCHSR_NPP (E, S, R, D, Q);
|
|
input E, S, R, D;
|
|
output reg Q;
|
|
always @* begin
|
|
if (R == 1)
|
|
Q <= 0;
|
|
else if (S == 1)
|
|
Q <= 1;
|
|
else if (E == 0)
|
|
Q <= D;
|
|
end
|
|
endmodule
|
|
|
|
// |---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|
|
|
//-
|
|
//- $_DLATCHSR_PNN (E, S, R, D, Q)
|
|
//-
|
|
//- A positive enable D-type latch with negative polarity set and reset.
|
|
//-
|
|
//- Truth table: E S R D | Q
|
|
//- ---------+---
|
|
//- - - 0 - | 0
|
|
//- - 0 - - | 1
|
|
//- 1 - - d | d
|
|
//- - - - - | q
|
|
//-
|
|
module DLATCHSR_PNN (E, S, R, D, Q);
|
|
input E, S, R, D;
|
|
output reg Q;
|
|
always @* begin
|
|
if (R == 0)
|
|
Q <= 0;
|
|
else if (S == 0)
|
|
Q <= 1;
|
|
else if (E == 1)
|
|
Q <= D;
|
|
end
|
|
endmodule
|
|
|
|
// |---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|
|
|
//-
|
|
//- $_DLATCHSR_PNP (E, S, R, D, Q)
|
|
//-
|
|
//- A positive enable D-type latch with negative polarity set and positive polarity
|
|
//- reset.
|
|
//-
|
|
//- Truth table: E S R D | Q
|
|
//- ---------+---
|
|
//- - - 1 - | 0
|
|
//- - 0 - - | 1
|
|
//- 1 - - d | d
|
|
//- - - - - | q
|
|
//-
|
|
module DLATCHSR_PNP (E, S, R, D, Q);
|
|
input E, S, R, D;
|
|
output reg Q;
|
|
always @* begin
|
|
if (R == 1)
|
|
Q <= 0;
|
|
else if (S == 0)
|
|
Q <= 1;
|
|
else if (E == 1)
|
|
Q <= D;
|
|
end
|
|
endmodule
|
|
|
|
// |---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|
|
|
//-
|
|
//- $_DLATCHSR_PPN (E, S, R, D, Q)
|
|
//-
|
|
//- A positive enable D-type latch with positive polarity set and negative polarity
|
|
//- reset.
|
|
//-
|
|
//- Truth table: E S R D | Q
|
|
//- ---------+---
|
|
//- - - 0 - | 0
|
|
//- - 1 - - | 1
|
|
//- 1 - - d | d
|
|
//- - - - - | q
|
|
//-
|
|
module DLATCHSR_PPN (E, S, R, D, Q);
|
|
input E, S, R, D;
|
|
output reg Q;
|
|
always @* begin
|
|
if (R == 0)
|
|
Q <= 0;
|
|
else if (S == 1)
|
|
Q <= 1;
|
|
else if (E == 1)
|
|
Q <= D;
|
|
end
|
|
endmodule
|
|
|
|
// |---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|
|
|
//-
|
|
//- $_DLATCHSR_PPP (E, S, R, D, Q)
|
|
//-
|
|
//- A positive enable D-type latch with positive polarity set and reset.
|
|
//-
|
|
//- Truth table: E S R D | Q
|
|
//- ---------+---
|
|
//- - - 1 - | 0
|
|
//- - 1 - - | 1
|
|
//- 1 - - d | d
|
|
//- - - - - | q
|
|
//-
|
|
module DLATCHSR_PPP (E, S, R, D, Q);
|
|
input E, S, R, D;
|
|
output reg Q;
|
|
always @* begin
|
|
if (R == 1)
|
|
Q <= 0;
|
|
else if (S == 1)
|
|
Q <= 1;
|
|
else if (E == 1)
|
|
Q <= D;
|
|
end
|
|
endmodule
|
|
|