Use of wire inside an always block?

落花浮王杯 提交于 2019-12-20 04:15:36

问题


Can I use a wire inside an 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?


回答1:


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.

The only real difference between a wire and reg is the syntax for assigning values.

In the above example d could also have been created as a wire, these are equivalent:

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

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


来源:https://stackoverflow.com/questions/15125760/use-of-wire-inside-an-always-block

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!