- Network Sites:
- Technical Articles
- Market Insights
- Or sign in with
- iHeartRadio
Concurrent Conditional and Selected Signal Assignment in VHDL
Join our engineering community sign-in with:.
This article will review the concurrent signal assignment statements in VHDL.
This article will first review the concept of concurrency in hardware description languages. Then, it will discuss two concurrent signal assignment statements in VHDL: the selected signal assignment and the conditional signal assignment. After giving some examples, we will briefly compare these two types of signal assignment statements.
Please see my article introducing the concept of VHDL if you're not familiar with it.
Concurrent vs. Sequential Statements
To understand the difference between the concurrent statements and the sequential ones, let’s consider a simple combinational circuit as shown in Figure 1.
Figure 1. A combinational circuit.
If we consider the operation of the three logic gates of this figure, we observe that each gate processes its current input(s) in an independent manner from other gates. These physical components are operating simultaneously. The moment they are powered, they will “concurrently” fulfill their functionality. Note that while, in practice, the AND gate has a delay to produce a valid output, this does not mean that the OR gate will stop its functionality and wait until the output of the AND gate is produced. The OR gate will function all the time; however, its output will not be valid until its inputs have settled.
Now, let’s examine the VHDL description of Figure 1. This is shown below:
The main part that we are here interested in is the definition of the three gates:
Each of these lines describes a physical component in Figure 1. For example, the second line, which describes the OR gate, takes sig1 and c as inputs and produces the OR of these two values. We saw that the physical components of Figure 1 operate concurrently. Hence, it is reasonable to expect that the VHDL description of these gates should be evaluated in a concurrent manner. In other words, the above three lines of the code are executed at the same time and there is no significance to the order of these statements. As a result, we can rewrite the architecture section of the above code as below:
Since these statements are evaluated at the same time, we call them concurrent statements. This type of code is quite different from what we have learned in basic computer programming where the lines of code are executed one after the other. For example, consider the following MATLAB code:
This code produces out1=1 and out2=1 . However, if we change the order of the statements to the following, the program will stop working because we are trying to use sig1 before it is generated.
While the VHDL code describing Figure 1 was executed concurrently, the above MATLAB code is evaluated sequentially (i.e., one line after the other). VHDL supports both the concurrent statements and the sequential ones. It's clear that the concurrent VHDL statements will allow us to easily describe a circuit such as the one in Figure 1 above. In a future article, we'll see that the sequential VHDL statements allow us to have a safer description of sequential circuits. Furthermore, using the sequential VHDL, we can easily describe a digital circuit in a behavioral manner. This capability can significantly facilitate digital hardware design.
The following figure illustrates the difference between concurrent and sequential statements.
Figure 2. The difference between concurrent and sequential statements. Image courtesy of VHDL Made Easy .
Now let's take a look at two concurrent signal assignment statements in VHDL: “the selected signal assignment statement” and “the conditional signal assignment statement”.
Selected Signal Assignment or the “With/Select” Statement
Consider an n -to-one multiplexer as shown in Figure 3. This block should choose one out of its n inputs and transfer the value of this input to the output terminal, i.e., output_signal .
Figure 3. A multiplexer selects one of its n inputs based on the value of the control_expression.
The selected signal assignment allows us to implement the functionality of a multiplexer. For example, the VHDL code describing the multiplexer of Figure 3 will be
Here, the value of the control_expression will be compared with the n possible options, i.e., option_1 , option_2 , …, option_n . When a match is found, the value corresponding to that particular option will be assigned to the output signal, i.e., output_signal . For example, if control_expression is the same as option_2 , then value_2 will be assigned to the output_signal .
Note that the options of a “with/select” assignment must be mutually exclusive, i.e., one option cannot be used more than once. Moreover, all the possible values of the control_expression must be included in the set of the options. The following example clarifies these points.
Example 1 : Use the "with/select" statement to describe a one-bit 4-to-1 multiplexer. Assume that the inputs to be selected are a , b , c , and d . And, a two-bit signal, sel , is used to choose the desired input and assign it to out1 .
The code for this multiplexer is given below:
Note that since the std_logic data type can take values other than “0” and “1” , the last line of the “with/select” statement needs to use the keyword “ others ” to take all the possible values of sel into account.
The following figure shows the simulation of this code using the Xilinx ISE simulator. (In case you’re not familiar with ISE, see this tutorial .) As shown in this figure, from 0 nanosecond (ns) until 300 ns the select input, sel , is 00, and, hence, out1 follows the input a . Similarly, you can verify the intended operation for the rest of the simulation interval.
Figure 4. The ISE simulation for the multiplexer of Example 1.
Example 2 : Use the “with/select” statement to describe a 4-to-2 priority encoder with the truth table shown below.
The following VHDL code can be used to describe the above truth table:
The ISE simulation is shown in Figure 5.
Figure 5. The ISE simulation for the priority encoder of Example 2.
Conditional signal assignment or the “when/else” statement.
The “when/else” statement is another way to describe the concurrent signal assignments similar to those in Examples 1 and 2. Since the syntax of this type of signal assignment is quite descriptive, let’s first see the VHDL code of a one-bit 4-to-1 multiplexer using the “when/else” statement and then discuss some details.
Example 3 : Use the when/else statement to describe a one-bit 4-to-1 multiplexer. Assume that the inputs to be selected are a , b , c , and d . And, a two-bit signal, sel , is used to choose the desired input and assign it to out1 .
The code will be
In this case, the expressions after “when” are evaluated successively until a true expression is found. The assignment corresponding to this true expression will be performed. If none of these expressions are true, the last assignment will be executed. In general, the syntax of the “when/else” statement will be:
We should emphasize that the expressions after the “when” clauses are evaluated successively. As a result, the expressions evaluated earlier has a higher priority compared to the next ones. Considering this, we can obtain the conceptual diagram of this assignment as shown in Figure 6. This figure illustrates a conditional signal assignment with three “when” clauses.
Figure 6. The conceptual implementation of a “when/else” statement with three “when” clauses.
Let’s review the main features of the selected signal assignment and the conditional signal assignment.
“With/Select” vs. “When/Else” Assignment
As mentioned above, the options of a “with/select” assignment must be mutually exclusive, i.e., one option cannot be used more than once. Moreover, all the possible values of the control_expression must be included in the set of options. While the “with/select” assignment has a common controlling expression, a “when/else” assignment can operate on expressions with different arguments. For example, consider the following lines of code:
In this case, the expressions are evaluating two different signals, i.e., reset1 and clk .
For the “when/else” assignment, we may or may not include all the possible values of the expressions to be evaluated. For example, the multiplexer of Example 3 covers all the possible values of sel ; however, the above code does not. The above code implies that out1 should retain its previous value when none of the expressions are true. This causes the inference of a latch in the synthesized circuit.
Another important difference between the “with/select” and “when/else” assignment can be seen by comparing the conceptual implementation of these two statements. The priority network of Figure 6 involves a cascade of several logic gates. However, the “with/select” assignment avoids this chain structure and has a balanced structure. As a result, in theory, the “with/select” statement may have better performance in terms of the delay and area (see RTL Hardware Design Using VHDL: Coding for Efficiency, Portability, and Scalability , Xilinx HDL Coding Hints , and Guide to HDL Coding Styles for Synthesis ).
In practice, we generally don’t see this difference because many synthesis software packages, such as the Xilinx XST, try not to infer a priority encoded logic. Though we can use the PRIORITY_EXTRACT constraint of XST to force priority encoder inference, Xilinx strongly suggests that we use this constraint on a signal-by-signal basis; otherwise, the constraint may guide us towards sub-optimal results. For more details see page 79 of the XST user guide .
- Concurrent statements are executed at the same time and there is no significance to the order of these statements. This type of code is quite different from what we have learned in basic computer programming where the lines of code are executed one after the other.
- The selected signal assignment or the "with/select" assignment allows us to implement the functionality of a multiplexer.
- The options of a “with/select” assignment must be mutually exclusive, i.e., one option cannot be used more than once. Moreover, all the possible values of the control_expression must be included in the set of the options.
- For the "when/else" statement, the expressions after the “when” clauses are evaluated successively. As a result, the expressions evaluated earlier has a higher priority compared to the next ones.
- One important difference between the “with/select” and “when/else” assignment can be seen by comparing the conceptual implementation of these two statements. The "when/else" statement has a priority network; however, the “with/select” assignment avoids this chain structure and has a balanced structure.
To see a complete list of my articles, please visit this page .
Featured image used courtesy of Parallella .
Related Content
- Safety in Sensing: Sensor Technology in Smart Cities
- Thermocouple Signal Conditioners and Signal Conditioning Near the Cold Junction
- Reducing Distortion in Tape Recordings with Hysteresis in SPICE
- Test & Measurement in Quantum Computing
- Open RAN – Network Performance in the Lab and in the Field
- Looking for Good Waves: The Importance of Signal Integrity in High-Speed PCB Design
Learn More About:
- programmable logic
Great content. The link to the ISE guide requires password. Can we get that posted again? Thanks!
You May Also Like
Advancements in Battery Technology & Chargers Are Accelerating Automation
In Partnership with Sager Electronics
NXP Combines UWB Radar and Secure Ranging in a Single Chip
by Jake Hertz
Fundamentals of THz Technology for 6G
by Rohde & Schwarz
Evolving Healthcare Regulations Force Embedded Technology Change
by NXP Semiconductors
MIT’s Implantable Microphone May Lead to Internal Cochlear Implants
by Duane Benson
Welcome Back
Don't have an AAC account? Create one now .
Forgot your password? Click here .
- Stack Overflow for Teams Where developers & technologists share private knowledge with coworkers
- Advertising & Talent Reach devs & technologists worldwide about your product, service or employer brand
- OverflowAI GenAI features for Teams
- OverflowAPI Train & fine-tune LLMs
- Labs The future of collective knowledge sharing
- About the company Visit the blog
Collectives™ on Stack Overflow
Find centralized, trusted content and collaborate around the technologies you use most.
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
Get early access and see previews of new features.
Staging Ground badges
Earn badges by improving or asking questions in Staging Ground.
concurrent and conditional signal assignment (VHDL)
In VHDL, there are two types for signal assignment:
Problem is that some say that when...else conditions are checked line by line (king of sequential) while select...when...else conditionals are checked once. See this reference for example.
I say that when..else is also a sequential assignment because you are checking line by line. In other words, I say that there no need to say if..else within a process is equivalent to when..else . Why they assume when..else is a concurrent assignment?
- concurrency
- What is your question? – mkrieger1 Commented Mar 7, 2017 at 0:06
- 1 And why down vote?... I edited the post – mahmood Commented Mar 7, 2017 at 6:21
2 Answers 2
Where you are hinting at in your problem has nothing to do with concurrent assignments or sequential statements. It has more to do with the difference between if and case. Before we get to that first lets understand a few equivalents. The concurrent conditional assignment:
Is exactly equivalent to a process with the following code:
Likewise the concurrent selected assignment:
Is equivalent to a process with the following:
From a coding perspective, the sequential forms above have a little more coding capability than the assignment form because case and if allow blocks of code, where the assignment form only assigns to one signal. However other than that, they have the same language restrictions and produce the same hardware (as much as synthesis tools do that). In addition for many simple hardware problems, the assignment form works well and is a concise capture of the problem.
So where your thoughts are leading really comes down to the difference between if and case. If statements (and their equivalent conditional assignments) that have have multiple "elsif" in (or implied in) them tend to create priority logic or at least cascaded logic. Where as case (and their equivalent selected assignments) tend to be well suited for things like multiplexers and their logic structure tends to be more of a balanced tree structure.
Sometimes tools will refactor an if statement to allow it to be equivalent to a case statement. Also for some targets (particularly LUT based logic like Xilinx and Altera), the difference between them in terms of hardware effiency does not show up until there are enough "elsif" branches though.
With VHDL-2008, the assignment forms are also allowed in sequential code. The transformation is the same except without the process wrapper.
Concurrent vs Sequential is about independence of execution.
A concurrent statement is simply a statement that is evaluated and/or executed independently of the code that surrounds it. Processes are concurrent. Component/Entity Instances are concurrent. Signal assignments and procedure calls that are done in the architecture are concurrent.
Sequential statements (other than wait) run when the code around it also runs.
Interesting note, while a process is concurrent (because it runs independently of other processes and concurrent assignments), it contains sequential statements.
Often when we write RTL code, the processes that we write are simple enough that it is hard to see the sequential nature of them. It really takes a statemachine or a testbench to see the true sequential nature of a process.
- So please include this answer in the previous one. It is now clear – mahmood Commented Mar 7, 2017 at 6:20
Your Answer
Reminder: Answers generated by artificial intelligence tools are not allowed on Stack Overflow. Learn more
Sign up or log in
Post as a guest.
Required, but never shown
By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy .
Not the answer you're looking for? Browse other questions tagged concurrency vhdl or ask your own question .
- The Overflow Blog
- Is this the real life? Training autonomous cars with simulations
- Featured on Meta
- Preventing unauthorized automated access to the network
- Upcoming initiatives on Stack Overflow and across the Stack Exchange network...
- Feedback Requested: How do you use the tagged questions page?
- Proposed designs to update the homepage for logged-in users
Hot Network Questions
- Is grounding an outlet only to its box enough?
- Counting with trees
- In what Disney film did a gelatinous cube appear?
- Stick lodging into front wheel - is it preventable?
- Select unique row and column entry from an nxn matrix
- What is this 4 element monoid?
- Prevent ugly hyphenation point in Danish
- Can I vacuum seal my homemade bone broth in a Ball jar?
- What is the action economy required to retrieve an item from stowage?
- Efficiently combining list elements by matching information
- What does "epic column inches" mean?
- What was the poison gas created in "Armadale" by Wilkie Collins?
- Sets that project to zero measure on all lines except one
- Secure Key Size in an extension field
- Progressive matrix with circles in/around boxes
- Do I need a fuse for each device connected to an AC-DC power supply?
- Could there be mini systems within our solar system, beyond what we can currently percieve?
- Document layout error
- How many dots are there?
- A letter starting the largest number of days of the week
- Are retrocomputers best left on or off?
- Reality Check - How possible is it for a single human to reach "Space Engineers" level of technological prowess?
- Are there infinitely many possible thoughts?
- How do I tell a powerline apart from other wires?
VHDL Concurrent Conditional Assignment
The Conditional Signal Assignment statement is concurrent because it is assigned in the concurrent section of the architecture. It is possible to implement the same code in a sequential version, as we will see next.
The conditional signal assignment statement is a process that assigns values to a signal.
It is a concurrent statement; this means that you must use it only in concurrent code sections.
The statement that performs the same operation in a sequential environment is the “ if ” statement.
The syntax for a conditional signal assignment statement is:
This is a simple example of a two-way mux as reported here:
The output “ a ” is equal to “ b ” when the selector “ c ” is “1” else is equal to “ d ”
Concurrent Conditional Signal Assignment Example 1
This example extends the previous one. This is a 4-way mux, implemented as concurrent code.
The architecture declarative section is empty. As you can notice, we don’t care about how the mux is implemented.
In this moment we don’t’ talk about logic gate, and or nand ect, we are describing the behavior of circuit using a high level description.
A graphical representation can be this one.
It is up to the synthesizer to implement the best architecture on the selected technology in terms of logic gates. In fact if you are using FPGA the synthesizer will use LUT to map the VHDL functions, if you are implementing an ASIC the synthesized logic will depend on differ technology and will be implemented using, for instance, NAND, OR, NOR gate, depending on the technology.
Running the RTL compiler on Altera Quartus II , this is the output of the RTL viewer, if we try to layout this mux4 .
As clear, the RTL translation is implemented in terms of AND gate and 2-way mux. The output “ e ” is generated by cascading 3 two-way mux.
This is the output of the Altera MAP viewer selecting Cyclone IV FPGA technology. Our mux4 is implemented using LOGIC_COMB_CELL Look Up Table present in the Cyclone IV FPGA . This example should clarify the meaning of “technology dependent”.
Concurrent Conditional Signal Assignment Example 2
This example is the same 4-way mux as the previous one, in which we used a different syntax to implement the selector. In this case, we have introduced the statement “with select”.
In the architecture declarative section, we declared a signal “ sel ” of type integer used to address the mux. The signal “ sel ” is coded as binary to integer.
The statement “ with select ” allows compacting the syntax of the mux code. Note the introduction of the “ other ” keyword. It is necessary because the mux assignment cover only 3 of the 2^32 possible integer values. If we try to layout the code, it is interesting to see how RTL viewer interprets the VHDL code:
This case is different from the previous one. We can notice that the VHDL relative to the signal sel is decoded in order to implement mux selection and that the output mux is implemented as 4-way mux. So the RTL view of the RTL code is totally different from the previous one.
The FPGA used in this example is the same as the previous example, in fact the output of Altera MAP viewer have the same implementation of the previous RTL code as clear if we make a comparison between the two implementations.
These two examples should clarify the meaning of behavioral. We have seen two different implementations of a simple mux mapped on the same hardware :
implementation of different RTL code can generate the same hardware logic.
Of course, gaining the sensibility to write good VHDL/RTL code is only a matter of time and experience . If you will follow the course, you will find good advices in order to gain all the shortcuts useful reduce this amount of time.
Previous – Next
vhdl_reference_93:concurrent_signal_assignment
Concurrent signal assignment ,... <= ..."
Concurrent_signal_assignment_statement.
- architecture_statement_part
- block_statement_part
Further definitions
Conditional_signal_assignment.
target <= options conditional_waveforms ;
selected_signal_assignment
with expression select target <= options selected_waveforms ;
Additional information
With a conditional signal assignment there is always an equivalent process statement; in general, this is valid for all concurrent assignments.
The equivalent process statement of a concurrent signal assignment statement including the keyword POSTPONED is a postponed process.
If the conditional signal assignment has the form
the signal assignment in the corresponding process statement has the form
If the (conditional) waveform is a simple waveform the signal assignment in the corresponding process statement has the form
The process statement of the wave_transform of a waveform of the form
has the form
null is here a null statement, not a null transaction!
The waveforms` characteristics and the conditions contained in the signal assignment have to be formulated appropriately so that the IF-statement in the corresponding process statement is a permitted statement.
With a selecting signal assignment there is always an equivalent process statement. If the selecting signal assignment has the form
For wave_transform look at the previous topic on conditional signal assignment.
The characteristics of the selected expression, of the waveforms and the criteria of selection contained in the signal assignment have to be formulated appropriately so that the CASE statement in the corresponding process statement is a permitted statement.
If the option GUARDED is contained in the signal assignment it is a so-called controlled assignment. If the target is also controlled the statement part of the corresponding process statement looks as follows:
If the target is not controlled the statement part of the corresponding process statement looks as follows:
It is also possible that neither signal assignment nor target is controlled. If this is the case the statement part of the corresponding process statement looks as follows:
It is not permitted to handle a signal assignment as being not controlled while handling the corresponding target as being controlled!
The value of b is assigned to the signal a after 5ns. In the first case the inertial delay model and in the second case the transport delay model is used.
The controlled signal assignment is only carried out if the corresponding condition in the block declaration is fulfilled.
If sel=0 then a is assigned the value 1 after 5ns; if sel=1 then a is assigned the value 0 after 3ns and the value 1 after 5ns; otherwise a is given the value X after 2 ns.
In this value assignment to the signal sig the value of of muxval is taken into consideration.
If muxval=0 then sig is assigned the value 001 etc. For this assignment the delay model TRANSPORT is used irrespective of the value of muxval .
S is only driven if the driver value is different the current value of S ; otherwise nothing happens.
Concurrent Statement | ----used in ----> | Architecture |
Syntax |
signal_name <= expression |
signal_name <= expression delay; |
See LRM section 9.5
Rules and Examples |
A concurrent signal assignment assigns a new value to the target signal whenever any of the signals on the right hand side change: |
Concurrent assignments have an "equivalent process". This is the equivalent process for the concurrent statements above. |
A signal assignment may have a delay specified:
|
The default delay model is . This means that "pulses" shorter than the delay time are not propagated. The alternative is delay, which propagates all transitions:
|
Multiple concurrent assignments to the same signal imply multiple drivers. A signal which is the target of multiple concurrent signal assignments must be of a resolved type, e.g. std_logic, std_logic_vector. |
For , see |
Synthesis Issues |
Concurrent signal assignments are generally synthesisable, providing they use types and operators acceptable to the synthesis tool.
A signal assigned with a concurrent statemant will be inferred as combinational logic.
Guarded assignments are not usually supported, and delays are ignored.
Whats New in '93 |
In VHDL -93, any signal assignment statement may have an optional label:
Concurrent Signal Assignment
- Architecture
Reference Manual
- Section 9.5
Rules and Examples
A concurrent signal assignment assigns a new value to the target signal whenever any of the signals on the right hand side change:
Concurrent assignments have an “equivalent process”. This is the equivalent process for the concurrent statements above.
A signal assignment may have a delay specified:
The default delay model is inertial . This means that “pulses” shorter than the delay time are not propagated. The alternative is transport delay, which propagates all transitions:
A delayed signal assignment with inertial delay may be explicitly preceded by the keyword inertial . It may also have a reject time specified. This is the minimum “pulse width” to be propagated, if different from the inertial delay:
Multiple concurrent assignments to the same signal imply multiple drivers. A signal which is the target of multiple concurrent signal assignments must be of a resolved type, e.g. std_logic, std_logic_vector.
For guarded assignments , see blocks .
A concurrent signal assignment can be specified to run as a postponed process (see process ).
Synthesis Issues
Concurrent signal assignments are generally synthesizable, providing they use types and operators acceptable to the synthesis tool.
A signal assigned with a concurrent statement will be inferred as combinational logic.
Guarded assignments are not usually supported, and delays are ignored.
- Block Statement
- Conditional Signal Assignment
COMMENTS
This article will first review the concept of concurrency in hardware description languages. Then, it will discuss two concurrent signal assignment statements in VHDL: the selected signal assignment and the conditional signal assignment. After giving some examples, we will briefly compare these two types of signal assignment statements.
In VHDL, there are two types for signal assignment: concurrent ----> when...else. ----> select...when...else. sequential ----> if...else. ----> case...when. Problem is that some say that when...else conditions are checked line by line (king of sequential) while select...when...else conditionals are checked once.
The conditional signal assignment statement is a process that assigns values to a signal. It is a concurrent statement; this means that you must use it only in concurrent code sections. The statement that performs the same operation in a sequential environment is the “ if ” statement.
The concurrent domain is represented by an architecture that contains processes, concurrent procedure calls, concur-rent signal assignments, and component instantiations (described in Laboratory No. 8). This laboratory work presents the format and use of sequential and concurrent statements.
With a conditional signal assignment there is always an equivalent process statement; in general, this is valid for all concurrent assignments. The equivalent process statement of a concurrent signal assignment statement including the keyword POSTPONED is a postponed process.
Concurrent signal assignment statements: This category contains two very useful statements, called when and select. They are referred to as conditional signal assignment and selected signal assignment statements, respectively. Their original (concurrent) version is proper only for the construction of combinational cir cuits.
This slide set covers the concurrent signal assignment statements, which include the. conditional signal assignment and selected signal assignment stmts. Topics include. Simple signal assignment statement (conditional assign. without a condition) Conditional signal assignment statement. Selected signal assignment statement.
Concurrent signal assignments are generally synthesisable, providing they use types and operators acceptable to the synthesis tool. A signal assigned with a concurrent statemant will be inferred as combinational logic. Guarded assignments are not usually supported, and delays are ignored.
Concurrent Signal Assignment. Signals that appear outside of a process. Event-triggered, when an event (change in value) occurs on one of the signals in the expression. Three types. concurrent signal assignment. conditional signal assignment. selected signal assignment.
Concurrent signal assignments are generally synthesizable, providing they use types and operators acceptable to the synthesis tool. A signal assigned with a concurrent statement will be inferred as combinational logic.