用Verilog來實現d觸發器2分頻的Verilog hdl程序:
module dff_2(clk,rst,clk_out);
input clk,rst;
output clk_out;
wire clk,rst;
reg clk_out;
always @(posedge clk or negedge rst)
if(!rst)
begin
clk_out<=0;
end
else
begin
clk_out<=~clk_out;
end
endmodule
通過RTL viewer 得到的原理圖;
仿真圖如圖示: