简体   繁体   English

在始终阻塞的内部使用电线?

[英]Use of wire inside an always block?

Can I use a wire inside an always block? 我可以在Always Block内使用电线吗? Like for example: 例如:

        wire [3:0]a;
        assign a=3;

        always @(c)
           begin
                d=a+c;
           end

It got compiled without throwing any error. 它被编译而不会引发任何错误。 Why? 为什么?

Yes, you can use a wire's value inside an always block, you just can not assign a value to a wire in always or initial block. 是的,您可以在Always块中使用导线的值,而不能在Always块或初始块中为导线分配值。

The only real difference between a wire and reg is the syntax for assigning values. 导线和reg之间的唯一真正区别是分配值的语法。

In the above example d could also have been created as a wire, these are equivalent: 在上面的示例中,d也可以创建为导线,它们是等效的:

reg [3:0] answer_reg;
always @* begin
  answer_reg = a + c;
end

wire [3:0] answer_wire;
assign answer_wire = a + c;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM