Created
January 5, 2020 14:34
-
-
Save bit-hack/74bcdb7ed8e9c73f4f7805822f1cfc62 to your computer and use it in GitHub Desktop.
verilog power on reset
This file contains hidden or 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
`timescale 1 ns / 1 ps | |
module power_on_reset(input in_clk, output out_rst); | |
reg [5:0] reset_cnt = 0; | |
wire resetn = &reset_cnt; | |
assign out_rst = !resetn; | |
always @(posedge in_clk) begin | |
reset_cnt <= reset_cnt + !resetn; | |
end | |
endmodule | |
module test_bench(); | |
reg clk; | |
wire rst; | |
power_on_reset por(clk, rst); | |
initial begin | |
$dumpfile("dump.vcd"); | |
$dumpvars; | |
clk <= 0; | |
#1000 $finish; | |
end | |
always @(*) begin | |
#1 clk <= ~clk; | |
end | |
reg [7:0] counter; | |
always @(posedge clk) begin | |
if (rst) begin | |
counter <= 0; | |
end else begin | |
counter <= counter + 8'd1; | |
end | |
end | |
endmodule |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment