verilog仿真时钟信号产生问题
本人刚接触verilog编程,正在摸索着编写一个计数器。需要两路输入信号,一个是时钟clk和重置信号rst,这两个信号都是方波,但是频率不同分别为1MHz和1KHz,在编...
本人刚接触verilog 编程,正在摸索着编写一个计数器。需要两路输入信号,一个是时钟clk和重置信号rst,这两个信号都是方波,但是频率不同分别为1MHz和1KHz,在编写测试文件时该如何编写正确的代码呢?小白求指教。我试着写了个但是是有错的。
`timescale 1ns/1ns
module testsamleratecounter;
reg rst,clk_in,counter,counter1,counter2,rst_tmp;
always
begin
#500 clk_in = ~clk_in;
end
always
begin
always
begin
#50000 rst = ~rst;
end
initial
begin
clk_in = 0;
rst = 0;
counter = 8'd0;
counter1 = 8'd0;
counter2 = 8'd0;
rst_tmp = 0;
end
endmodule 展开
`timescale 1ns/1ns
module testsamleratecounter;
reg rst,clk_in,counter,counter1,counter2,rst_tmp;
always
begin
#500 clk_in = ~clk_in;
end
always
begin
always
begin
#50000 rst = ~rst;
end
initial
begin
clk_in = 0;
rst = 0;
counter = 8'd0;
counter1 = 8'd0;
counter2 = 8'd0;
rst_tmp = 0;
end
endmodule 展开
2个回答
展开全部
你需要用到forever语句:
initial
begin
clk=1'b0;
……
forever #1000 clk = ~clk;
……
end
initial
begin
clk=1'b0;
……
forever #1000 clk = ~clk;
……
end
追问
请问可以这样用产生两路信号么?
initial
begin
clk=1'b0;
rst=1'b0;
forever #500 clk = ~clk;
forever #50000 rst = ~rst;
end
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
北京康思
2018-09-20 广告
2018-09-20 广告
电压的测量利用示波器所做的任何测量,都是归结为对电压的测量。示波器可以测量各种波形的电压幅度,既可以测量直流电压和正弦电压,又可以测量脉冲或非正弦电压的幅度。更有用的是它可以测量一个脉冲电压波形各部分的电压幅值,如上冲量或顶部下降量等。这是...
点击进入详情页
本回答由北京康思提供
展开全部
`timescale 1ns/1ns
module testsamleratecounter;
reg rst,clk_in,counter,counter1,counter2,rst_tmp;
always
begin
#500 clk_in = ~clk_in;
end
// always
// begin 这两句写重复了
always
begin
#50000 rst = ~rst;
end
initial
begin
clk_in = 0;
rst = 0;
counter = 8'd0;
counter1 = 8'd0;
counter2 = 8'd0;
rst_tmp = 0;
end
endmodule
module testsamleratecounter;
reg rst,clk_in,counter,counter1,counter2,rst_tmp;
always
begin
#500 clk_in = ~clk_in;
end
// always
// begin 这两句写重复了
always
begin
#50000 rst = ~rst;
end
initial
begin
clk_in = 0;
rst = 0;
counter = 8'd0;
counter1 = 8'd0;
counter2 = 8'd0;
rst_tmp = 0;
end
endmodule
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询