开发者

How to declare an array of 4 bits in Verilog

开发者 https://www.devze.com 2023-02-15 16:34 出处:网络
I need an array to hold a 4-bit number. I开发者_开发知识库t is neither an input or an output, just an intermediary value necessary for calculations. How would this be declared?You mean that you need a

I need an array to hold a 4-bit number. I开发者_开发知识库t is neither an input or an output, just an intermediary value necessary for calculations. How would this be declared?


You mean that you need a variable?

reg [3:0] mynumber;


For synthesis, you would use either a register or a wire, depending on what you needed it for.

reg  [3:0] my_reg;

or

wire [3:0] my_wire;

If you will use this value in an always block, you need to declare it as a reg.

If you are using it for combinational logic, not inside an always block, you would declare it as a wire. This would be used with an assign statements or in a port list.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号