Verilog assign statement
Signals of type wire or a similar wire like data type requires the continuous assignment of a value. For example, consider an electrical wire used to connect pieces on a breadboard. As long as the +5V battery is applied to one end of the wire, the component connected to the other end of the wire will get the required voltage.

In Verilog, this concept is realized by the assign statement where any wire or other similar wire like data-types can be driven continuously with a value. The value can either be a constant or an expression comprising of a group of signals.

Assign Syntax
The assignment syntax starts with the keyword assign followed by the signal name which can be either a single signal or a concatenation of different signal nets. The drive strength and delay are optional and are mostly used for dataflow modeling than synthesizing into real hardware. The expression or signal on the right hand side is evaluated and assigned to the net or expression of nets on the left hand side.
Delay values are useful for specifying delays for gates and are used to model timing behavior in real hardware because the value dictates when the net should be assigned with the evaluated value.
- LHS should always be a scalar or vector net or a concatenation of scalar or vector nets and never a scalar or vector register.
- RHS can contain scalar or vector registers and function calls.
- Whenever any operand on the RHS changes in value, LHS will be updated with the new value.
- assign statements are also called continuous assignments and are always active
In the following example, a net called out is driven continuously by an expression of signals. i1 and i2 with the logical AND & form the expression.
If the wires are instead converted into ports and synthesized, we will get an RTL schematic like the one shown below after synthesis.

Continuous assignment statement can be used to represent combinational gates in Verilog.
The module shown below takes two inputs and uses an assign statement to drive the output z using part-select and multiple bit concatenations. Treat each case as the only code in the module, else many assign statements on the same signal will definitely make the output become X.
Assign reg variables
It is illegal to drive or assign reg type variables with an assign statement. This is because a reg variable is capable of storing data and does not require to be driven continuously. reg signals can only be driven in procedural blocks like initial and always .
Implicit Continuous Assignment
When an assign statement is used to assign the given net with some value, it is called explicit assignment. Verilog also allows an assignment to be done when the net is declared and is called implicit assignment.
Combinational Logic Design
Consider the following digital circuit made from combinational gates and the corresponding Verilog code.
Combinational logic requires the inputs to be continuously driven to maintain the output unlike sequential elements like flip flops where the value is captured and stored at the edge of a clock. So an assign statement fits the purpose the well because the output o is updated whenever any of the inputs on the right hand side change.
Hardware Schematic
After design elaboration and synthesis, we do get to see a combinational circuit that would behave the same way as modeled by the assign statement.

See that the signal o becomes 1 whenever the combinational expression on the RHS becomes true. Similarly o becomes 0 when RHS is false. Output o is X from 0ns to 10ns because inputs are X during the same time.
Click here for a slideshow with simulation example !
Global training solutions for engineers creating the world's electronics
- Full Training Programs
- Course Calendar
- SystemVerilog & UVM
- SystemC & TLM-2.0
- Verification Methodology
- Formal Verification
- Deep Learning
- Digital Design
- Embedded C/C++
- Linux & Yocto
- Verilog & SystemVerilog
- FPGA & ASIC Design using VHDL
- Signal Integrity
- PSL Training
- Free Online Training Events
- Which Kernel for your Embedded Linux Project?
- OTA for Embedded Linux Systems
- Maximize Design Productivity using Vivado ML Tools with SystemVerilog
- Connecting AI to IoT Applications
- Become an SVA Expert in One Hour
- Coming Soon...
- Free Technical Resources
- Arm / Embedded
- Video Gallery
- KnowHow FAQs
- Legal issues, Trademarks and Acknowledgements
- Opportunities
- News, PR & Events
- Reference Guides

KnowHow Free Technical Resources
Find a training course, wire assignments.
A wire can be declared and continuously assigned in a single statement - a wire assignment. This is a shortcut which saves declaring and assigning a wire separately. There are no advantages or disadvantages between the two methods other than the obvious difference that wire assignments reduce the size of the text.
Later on we will discuss delays on assignments and wires. A delay in a wire assignment is equivalent to a delay in the corresponding continuous assignment, not a delay on the wire. Thus it could be necessary to separate the wire declaration from the continuous assignment to put the delay onto the wire rather than the assignment. Note that this is a subtle point that you are unlikely to encounter in practice!
Verilog: Using wire assignments to describe an AOI gate module
So in this sample code, each of the wire declarations and its corresponding assign statement are effectively merged into one wire assignment.
Note the use of a block comment in the Verilog code, rather than the line comments we have seen so far. A block comment may span several lines of code. Block comments may not be nested.

Simulate your VHDL code in a web browser
Related training, henry hastings, lockheed martin.
View more references

- Interview Q

Verilog Tutorial
- Send your Feedback to [email protected]
Help Others, Please Share

Learn Latest Tutorials

Transact-SQL

Reinforcement Learning

R Programming

React Native

Python Design Patterns

Python Pillow

Python Turtle

Preparation

Verbal Ability

Interview Questions

Company Questions
Trending Technologies

Artificial Intelligence

Cloud Computing

Data Science

Machine Learning

B.Tech / MCA

Data Structures

Operating System

Computer Network

Compiler Design

Computer Organization

Discrete Mathematics

Ethical Hacking

Computer Graphics

Software Engineering

Web Technology

Cyber Security

C Programming

Control System

Data Mining

Data Warehouse
Javatpoint Services
JavaTpoint offers too many high quality services. Mail us on h [email protected] , to get more information about given services.
- Website Designing
- Website Development
- Java Development
- PHP Development
- Graphic Designing
- Digital Marketing
- On Page and Off Page SEO
- Content Development
- Corporate Training
- Classroom and Online Training
Training For College Campus
JavaTpoint offers college campus training on Core Java, Advance Java, .Net, Android, Hadoop, PHP, Web Technology and Python. Please mail your requirement at [email protected] . Duration: 1 week to 2 week

- SystemVerilog
- Verification
- Randomization
- Functional Coverage
- UVM Tutorial
- VMM Tutorial
- OVM Tutorial
- Easy Labs : SV
- Easy Labs : UVM
- Easy Labs : OVM
- Easy Labs : VMM
- AVM Switch TB
- VMM Ethernet sample
- Verilog Switch TB
- Basic Constructs
- RVM Switch TB
- RVM Ethernet sample
- Interview Questions
copyright 2007-2017 :: all rights reserved www.testbench.in :: Disclaimer

IMAGES
VIDEO
COMMENTS
Verilog assign statement ... Signals of type wire or a similar wire like data type requires the continuous assignment of a value. For example, consider an
Verilog code for AND-OR-INVERT gate module AOI (input A, B, C, D, output F); /* start of a block comment wire F; wire AB, CD, O; assign AB = A & B;
Verilog - Operators. Bitwise operators give bit-by-bit results. //8-bit wide AND module and8( input [7:0] a,b, output [7:0] z. ); assign z = a & b;.
Verilog assign Statement ... Assign statements are used to drive values on the net. And it is also used in Data Flow Modeling. Signals of type wire or a data type
assign o2 = s ^ c ;. // XOR operation endmodule. I/O port direction declarations. Logic functions. The module is the basic Verilog building block.
DIGITAL CIRCUITS AND SYSTEMS with Verilog. 21 VERILOG ASSIGN STATEMENT AND INSTANTIATION. 7.9K views 7 years ago. KNOWLEDGE TREE.
Introduces the concept of continuous assignment using the assign statement. The video describes how this is effectively just connections
Hardware Description Languages. • Verilog. -- structural: modules, instances. -- dataflow: continuous assignment. -- sequential behavior: always blocks.
This allows efficient code generation. Verilog does not have assignment operators or increment and decrement operators. SystemVerilog includes the C assignment
assign O = AB | CD;. assign F = ~O;. In this module body, there are four continuous assignment statements. These statements are independent and executed