这段代码在合成时会产生多少次翻转?
how many flip-flips would this code produce when synthesized?
我想了解这段代码在合成时会产生多少次翻转?
我有 2 个具有非阻塞和阻塞赋值代码的测试用例。
测试 1。
wire aclk;
wire [1:0] a;
reg [1:0] c;
reg [1:0] b;
always @(posedge aclk)
begin
b <= a + 1;
c = b;
end
测试 2。
wire aclk;
wire [1:0] a;
reg [1:0] c;
reg [1:0] b;
always @(posedge aclk)
begin
b = a + 1;
c <= b;
end
测试 1 有 4 个 FF,测试 2 有 2 个 FF。
我不明白我只是切换代码有什么不同。
谢谢你让我知道。
它们在功能上是不同的。非阻塞赋值先评估右侧,然后继续执行下一条语句,直到首先评估所有其他语句后,才会存储到左侧。阻塞语句评估右侧并立即将其存储到左侧。
Test1 is doing this:
evaluate (a+1)
store b into c , BEFORE (a+1) is stored into b!!!
store (a+1) into b
Test2 is doing this:
evaluate (a+1)
store (a+1) into b
store b into c
就像提到的工具一样,您通常在顺序逻辑中使用非阻塞语句。大多数人还建议不要在同一个 begin-end 块中混合使用非阻塞和阻塞语句。
我想了解这段代码在合成时会产生多少次翻转?
我有 2 个具有非阻塞和阻塞赋值代码的测试用例。
测试 1。
wire aclk;
wire [1:0] a;
reg [1:0] c;
reg [1:0] b;
always @(posedge aclk)
begin
b <= a + 1;
c = b;
end
测试 2。
wire aclk;
wire [1:0] a;
reg [1:0] c;
reg [1:0] b;
always @(posedge aclk)
begin
b = a + 1;
c <= b;
end
测试 1 有 4 个 FF,测试 2 有 2 个 FF。
我不明白我只是切换代码有什么不同。
谢谢你让我知道。
它们在功能上是不同的。非阻塞赋值先评估右侧,然后继续执行下一条语句,直到首先评估所有其他语句后,才会存储到左侧。阻塞语句评估右侧并立即将其存储到左侧。
Test1 is doing this:
evaluate (a+1)
store b into c , BEFORE (a+1) is stored into b!!!
store (a+1) into b
Test2 is doing this:
evaluate (a+1)
store (a+1) into b
store b into c
就像提到的工具一样,您通常在顺序逻辑中使用非阻塞语句。大多数人还建议不要在同一个 begin-end 块中混合使用非阻塞和阻塞语句。