The difference between wire and Reg type in Verilog

Source: Internet
Author: User

This is a matter reproduced an article, feel good, although a little bit wrong in the middle.

The difference between wire and Reg type:

Wire type data is commonly used to represent the combined logic signals specified with the Assign keyword. The input and output port type of the module is the wire type by default. The default initial value is Z.

The register type represented by the Reg type. the assigned signal within the Always module must be defined as a reg type , which represents the trigger.

The default initial value is X.

Reg corresponds to a storage unit , which is equivalent to a physical connection .

The physical data of variables in Verilog is divided into linear and register types. These two types of variables are defined with a bit width set, and the default is 1 bits. Each bit of a variable can be a 0,1,x,z. where x represents a variable that is not pre-initialized or is a conflicting linetype variable caused by two or more drives attempting to set it to a different value. Z represents a high-impedance state or a floating volume.

The Linetype data includes several types such as Wire,wand,wor, when driven by more than one excitation source, different linetype data have their own resolution to determine their final value.

The difference between the two is that the register type data is retained for the last assignment, and the Linetype data requires a continuous drive

The input port can be driven by net/reg, but the input port is only net, such as a = B & C, the input port A can only be net type, but its driver b,c can be net/reg type, the output port can make the Net/reg type, the output port only drives net, such as a = B & C, the output port of the module b,c can be net/reg type, but they drive a must be net type, if the output port in the process block (always/initial) is assigned to a reg type, if the outside of the procedure block assignment is net type. Using the keyword InOut to declare a bidirectional port, the InOut port cannot be declared as a register type, only a net type.

Wire Express, that is, as long as the input changes, the output is immediately and unconditionally reflected; Reg indicates that there must be a trigger and the output will reflect the input.

The default is 1-bit wire type without specifying it. specifically specifies the wire type, which may be multi-bit or for making the program easy to read. A wire can only be assigned by assign, and Reg can only be assigned in initial and always. Wire is used in continuous assignment statements, while Reg is used in procedure assignment statements.

In a continuous assignment statement, the evaluation to the right of the expression can immediately update the left side of the expression. In understanding , the equivalent of a logic followed by a straight line, the logic corresponds to the right side of the expression, and this line corresponds to the wire. In a procedure assignment statement, the calculation of the right side of the expression is lowered to a variable in a certain condition, and the variable can be declared as a reg type. depending on the trigger condition, the procedure assignment statement can model different hardware structures: If this condition is the rising or falling edge of the clock, then the hardware model is a trigger; if the condition is a high or low level of a signal, then the hardware model is a latch If this condition is the change of any operand to the right of the assignment statement, then the hardware model is a combinatorial logic.

The variable of wire type is generally a conductor;

The REG variable has two cases in the always block: Always after the sensitive table is (a or B or C) Form, that is, without the clock edge, integrated or combined logic always after the sensitive table is (Posedge clk) Form, that is, with the edge, integrated out general Is the timing logic that contains the trigger (flip-flop)

In the design, the input signal in general you do not know whether the upper level is the register output or the combination of logic output, then for this level is a wire, that is, cable type. And the output signal is your own decision is the register output or combination logic output, wire type, Reg type can be. But in general, the entire design of the external output (that is, the output of the top-level module), the requirements are register output, more stable, fan-out ability is also good.

Notes: 7788 also do not understand, in short, wire assignment with Assign,reg in always use.

The difference between wire and Reg type in Verilog

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.