题解 | #时钟分频(偶数)#
时钟分频(偶数)
https://www.nowcoder.com/practice/49a7277c203a4ddd956fa385e687a72e
`timescale 1ns/1ns module even_div ( input wire rst , input wire clk_in, output wire clk_out2, output wire clk_out4, output wire clk_out8 ); //*************code***********// reg [2:0] cnt; always @(posedge clk_in or negedge rst) begin if (~rst) begin cnt <= 0; end else begin cnt <= cnt - 1; end end assign clk_out2 = cnt[0]; assign clk_out4 = cnt[1]; assign clk_out8 = cnt[2]; //*************code***********// endmodule
计数器分频,三个时钟可分别用同一个计数器的不同位数。