Created
February 6, 2021 22:23
-
-
Save mmalinin/cb005416752e9cc110f17b4c1d24a9e3 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 sync_counter_1bit_pn (input up,dn,clk,rst,output reg q,output wire next_up,next_dn); | |
wire nq,prev; | |
not(nq,q); | |
or(prev,up,dn); | |
and(next_up,up,q); | |
and(next_dn,dn,nq); | |
initial q <= 1'b0; | |
always @(posedge clk or negedge rst) begin | |
if(!rst) begin | |
q <= 1'b0; | |
end else begin | |
if(prev) begin | |
q <= nq; | |
end | |
end | |
end | |
endmodule |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment