Created
April 8, 2020 21:54
-
-
Save mwkmwkmwk/5c7a840e65e9282dd5d741e802296d83 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module \$dffes (CLK, RST, EN, D, Q); | |
parameter WIDTH = 0; | |
parameter CLK_POLARITY = 1'b1; | |
parameter EN_POLARITY = 1'b1; | |
parameter RST_POLARITY = 1'b1; | |
parameter RST_VALUE = 0; | |
input CLK, RST, EN; | |
input [WIDTH-1:0] D; | |
output reg [WIDTH-1:0] Q; | |
wire pos_clk = CLK == CLK_POLARITY; | |
wire pos_rst = RST == RST_POLARITY; | |
always @(posedge pos_clk) begin | |
if (EN == EN_POLARITY) begin | |
if (pos_rst) | |
Q <= RST_VALUE; | |
else | |
Q <= D; | |
end | |
end | |
endmodule |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment