提问人:TomatoLV 提问时间:11/10/2019 更新时间:11/10/2019 访问量:1880
Verilog 和 Always 阻止的条件
Verilog and condition for Always block
问:
我正在做一个项目,在追查到一个错误后,我将其缩小到它是由无法正确触发的 Always 块引起的。
module Counter(start,clk_len,done,clk,reset);
input [4:0] clk_len;
input clk,start,reset;
output done;
reg [4:0] cntr_var = 0; reg start_val = 0;
assign done = !start_val;
reg test = 0;
always @(reset){cntr_var,start_val} = 2'b0;
always @(posedge start) begin
start_val = start;
end
always @((done and cntr_var == clk_len)) begin // <=== This is the source of the problem
cntr_var = 0;
start_val = 0;
test = 1;
end
always @(clk and !reset) begin
if (start_val == 1 && cntr_var != clk_len)
cntr_var = cntr_var + 1;
end
endmodule
其中一个 always 块应该在 AND 时触发。done
(cntr_var == clk_len)
我尝试同时使用两者作为逻辑运算符。
为什么这不起作用?&&
and
答:
3赞
dave_59
11/10/2019
#1
你的第一个大问题是意味着“等到表达式有值变化”。该更改可能是 1➩0 或 0➩1。通常,仅用于同步逻辑或组合逻辑。(在 SystemVerilog 中)@(expression)
always @(posedge clk)
always @(*)
always_comb
你的另一个问题是,你应该只从一个变量中分配一个特定的变量,并且只有一个总是阻塞。
下一个:输出数组不会采用数组寄存器的值
评论
always @( * )