Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- module blinker(CLK, RST, LED);
- input CLK;
- input RST;
- output LED;
- reg[31:0] counter;
- reg LEDR;
- always@(posedge CLK, posedge RST)
- begin
- if( RST )
- begin
- counter <= 32'b0;
- LEDR <= 0;
- end
- else
- begin
- if( counter == 12499999 )
- begin
- LEDR <= 1'b1;
- counter <= 0;
- end
- else
- begin
- counter <= counter + 1;
- if ( counter > 6249999 )
- LEDR <= 1'b0;
- end
- end
- end
- assign LED = LEDR;
- endmodule
- module tb;
- reg clk, rst;
- wire out;
- initial
- begin
- clk = 1'b0;
- rst = 1'b1;
- #5
- rst = 1'b0;
- end
- always
- #5 clk = !clk;
- initial
- $monitor("[%d] LED = %b", $time, out);
- blinker inst0(.CLK(clk), .RST (rst), .LED(out));
- endmodule
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement