//让LED按照量0.25秒,灭0.75秒的循环亮灭。 原代码 module counter_led_1( clk, reset_n, led ); input clk; input reset_n; output reg led; parameter MCNT=50000000; reg [25:0] counter; always@(posedge clk or negedge reset_n) if(!reset_n) counter<=0; else if(counter==MCNT-1) counter<=0; else counter<=counter+1'b1; always@(posedge clk or negedge reset_n) if(!reset_n) led<=0; else if(counter==(MCNT/2+MCNT/4)-1) led<=1; else if(counter==MCNT-1) led<=0; endmodule 仿真代码 `timescale 1ns/1ns module counter_led_1_tb(); reg clk; reg reset_n; wire led; defparam counter_led_1_inst0.MCNT=50000; counter_led_1 counter_led_1_inst0( .clk(clk), .reset_n(reset_n), .led(led) ); initial clk=1; always #10 clk=!clk; initial begin reset_n=0; #201; reset_n=1; #2000000000; $stop; end endmodule
标签:reset,led,clk,器到,counter,LED,小梅哥 From: https://www.cnblogs.com/wangwin4/p/17113381.html