我在学习Verilog HDL。现在,我正试图运行一个程序的数字亚特兰斯巴达6 xc6slx45。
我正在板上执行这个计数器。
module counter_s2( output reg [7:0] count);
initial begin
count=0;
repeat(127) begin
#10000000 count=count+1;
end
end
endmodule
当我在板上运行这段代码时,最终输入为1111111。在董事会上没有任何延误。我想要产生一个延迟,比如说1秒,来查看输出。谢谢!
P.S:我对Verilog很陌生。
发布于 2014-10-21 10:24:05
您所创建的对于testbench组件来说是很好的,并且将在模拟中工作,但是它的某些部分是不可合成的。
特别是initial
只能在fpgas上使用来设置初始值,它不能随着时间的推移而在这个块中改变,它可以在一个单独的块中更新。注:这是唯一一次,两个街区可以设置相同的雷格。
合成忽略了#delay
值。任意异步定时控制不能可靠地实现,因此不属于综合工具的一部分。
为了开发Verilog计数器,通常使用一个时钟,这意味着他的计数器价值将保持在触发器中。要使计数能被观察到,你需要一个足够慢的时钟。
以下计数器将溢出并持续计数。
module counter_s2(
input clk,
output reg [7:0] count
);
initial begin
count= 'b0;
end
always @(posedge clk) begin
count <= count + 1 ;
end
endmodule
如果是针对专用集成电路,那么您应该使用重置,而不是依赖初始设置。
module counter_s2(
input clk,
input rst_n, //Active Low reset
output reg [7:0] count
);
always @(posedge clk or negedge rst_n) begin
if (~rst_n) begin
count <= 'b0;
end
else begin
count <= count + 1 ;
end
end
endmodule
https://stackoverflow.com/questions/26483101
复制相似问题