file:///C:/Documents%20and%20Set
tings/大爷常来玩/Application%20Data/Tencent/Users/364246468/QQ/WinTemp/RichOle/7TTVM%6006965J0WP_QHL9S01.jpg
程序如下:
module jishufp(div5,clk);
output div5;
input clk;
reg[2:0]cnt1,cnt2;
reg clk_temp1,clk_temp2;
always @(posedge clk)
begin
if(cnt1==3'b100)
cnt1<='b000;
else cnt1<=cnt1+1;
if(cnt1==3'b000)
clk_temp1=1;
if(cnt1==3'b010)
clk_temp1=0;
end
always @(negedge clk)
begin
if(cnt2==3'b100)
cnt2<='b000;
else cnt2<=cnt2+1;
if(cnt2==3'b000)
clk_temp2=1;
if(cnt2==3'b010)
clk_temp2=0;
end
assign div5=clk_temp1|clk_temp2;
endmodule
测试脚本如下:
`timescale 1 ns/ 1 ns
module jishufp_vlg_tst();
// constants
// general purpose registers
reg eachvec;
// test vector input registers
reg clk;
// wires
wire div5;
// assign statements (if any)
jishufp i1 (
// port map - connection between master ports and signals/registers
.clk(clk),
.div5(div5)
);
initial
begin
clk=0;
#10
forever
clk=~clk;
#5000
$stop;
end
endmodule
一周热门 更多>