module single_pulse(pulse_out1,pulse_out2,width1,delay,clk,rst,start);
output pulse_out1;
output pulse_out2;
input clk,rst,start;
input [7:0] width1;
input [7:0] width2;
input [15:0] delay;
reg load;
reg pulse_out1;
reg [7:0] count1;
reg [7:0] count2;
reg [15:0] count3;
reg [3:0] cnt;
always@(posedge clk or negedge rst)
begin
if(~rst)
begin
cnt<=4'd10;
load<=1'd0;
end
else
begin
cnt<=cnt-1'd1;
if(cnt==1'd0)
begin
cnt<=3'd5;
load<=1'd1;
end
end
end
always@(posedge clk or negedge rst)
begin
if(~rst)
begin
count1 <= width1;
count2 <= width2;
count3 <= delay;
pulse_out1<= 1'd0;
pulse_out2<= 1'd1;
end
else if(load == 1'd1)
begin
if(start == 1'd1 )
begin
if(count1)
begin
count1 <= count1-8'd1;
pulse_out1 <= 1'd1;
end
else
begin
pulse_out1 <= 1'd0;
end
if(count3)
begin
count1 <= count1-8'd1;
pulse_out2 <= 1'd1;
end
else
begin
if(count2)
begin
count2<=count2-8'd1;
pulse_out2<=1'd0;
end
else
begin
pulse_out2<=1'd1;
end
end
end
end
endmodule
这段编译结果Error (10170): Verilog HDL syntax error at single_pulse.v(75) near text "endmodule"; expec
ting "end",不知道怎么改了,我是为了产生两个可调脉冲,相隔一定时间的。
一周热门 更多>