![assignment statement meaning in vhdl GitHub](https://nandland.com/wp-content/uploads/2022/06/GITHUB.png)
![](http://serviteca.online/777/templates/cheerup2/res/banner1.gif)
Assignment Symbol in VHDL
VHDL assignments are used to assign values from one object to another. In VHDL there are two assignment symbols:
Either of these assignment statements can be said out loud as the word “gets”. So for example in the assignment: test <= input_1; You could say out loud, “The signal test gets (assigned the value from) input_1.”
Note that there is an additional symbol used for component instantiations (=>) this is separate from an assignment.
Also note that <= is also a relational operator (less than or equal to). This is syntax dependent. If <= is used in any conditional statement (if, when, until) then it is a relational operator , otherwise it’s an assignment.
One other note about signal initialization: Signal initialization is allowed in most FPGA fabrics using the := VHDL assignment operator. It is good practice to assign all signals in an FPGA to a known-value when the FPGA is initialized. You should avoid using a reset signal to initialize your FPGA , instead use the := signal assignment.
Learn Verilog
Leave A Comment Cancel reply
Save my name, email, and website in this browser for the next time I comment.
VHDL Logical Operators and Signal Assignments for Combinational Logic
In this post, we discuss the VHDL logical operators, when-else statements , with-select statements and instantiation . These basic techniques allow us to model simple digital circuits.
In a previous post in this series, we looked at the way we use the VHDL entity, architecture and library keywords. These are important concepts which provide structure to our code and allow us to define the inputs and outputs of a component.
However, we can't do anything more than define inputs and outputs using this technique. In order to model digital circuits in VHDL, we need to take a closer look at the syntax of the language.
There are two main classes of digital circuit we can model in VHDL – combinational and sequential .
Combinational logic is the simplest of the two, consisting primarily of basic logic gates , such as ANDs, ORs and NOTs. When the circuit input changes, the output changes almost immediately (there is a small delay as signals propagate through the circuit).
Sequential circuits use a clock and require storage elements such as flip flops . As a result, changes in the output are synchronised to the circuit clock and are not immediate. We talk more specifically about modelling combinational logic in this post, whilst sequential logic is discussed in the next post.
Combinational Logic
The simplest elements to model in VHDL are the basic logic gates – AND, OR, NOR, NAND, NOT and XOR.
Each of these type of gates has a corresponding operator which implements their functionality. Collectively, these are known as logical operators in VHDL.
To demonstrate this concept, let us consider a simple two input AND gate such as that shown below.
The VHDL code shown below uses one of the logical operators to implement this basic circuit.
Although this code is simple, there are a couple of important concepts to consider. The first of these is the VHDL assignment operator (<=) which must be used for all signals. This is roughly equivalent to the = operator in most other programming languages.
In addition to signals, we can also define variables which we use inside of processes. In this case, we would have to use a different assignment operator (:=).
It is not important to understand variables in any detail to model combinational logic but we talk about them in the post on the VHDL process block .
The type of signal used is another important consideration. We talked about the most basic and common VHDL data types in a previous post.
As they represent some quantity or number, types such as real, time or integer are known as scalar types. We can't use the VHDL logical operators with these types and we most commonly use them with std_logic or std_logic_vectors.
Despite these considerations, this code example demonstrates how simple it is to model basic logic gates.
We can change the functionality of this circuit by replacing the AND operator with one of the other VHDL logical operators.
As an example, the VHDL code below models a three input XOR gate.
The NOT operator is slightly different to the other VHDL logical operators as it only has one input. The code snippet below shows the basic syntax for a NOT gate.
- Mixing VHDL Logical Operators
Combinational logic circuits almost always feature more than one type of gate. As a result of this, VHDL allows us to mix logical operators in order to create models of more complex circuits.
To demonstrate this concept, let’s consider a circuit featuring an AND gate and an OR gate. The circuit diagram below shows this circuit.
The code below shows the implementation of this circuit using VHDL.
This code should be easy to understand as it makes use of the logical operators we have already talked about. However, it is important to use brackets when modelling circuits with multiple logic gates, as shown in the above example. Not only does this ensure that the design works as intended, it also makes the intention of the code easier to understand.
- Reduction Functions
We can also use the logical operators on vector types in order to reduce them to a single bit. This is a useful feature as we can determine when all the bits in a vector are either 1 or 0.
We commonly do this for counters where we may want to know when the count reaches its maximum or minimum value.
The logical reduction functions were only introduced in VHDL-2008. Therefore, we can not use the logical operators to reduce vector types to a single bit when working with earlier standards.
The code snippet below shows the most common use cases for the VHDL reduction functions.
Mulitplexors in VHDL
In addition to logic gates, we often use multiplexors (mux for short) in combinational digital circuits. In VHDL, there are two different concurrent statements which we can use to model a mux.
The VHDL with select statement, also commonly referred to as selected signal assignment, is one of these constructs.
The other method we can use to concurrently model a mux is the VHDL when else statement.
In addition to this, we can also use a case statement to model a mux in VHDL . However, we talk about this in more detail in a later post as this method also requires us to have an understanding of the VHDL process block .
Let's look at the VHDL concurrent statements we can use to model a mux in more detail.
VHDL With Select Statement
When we use the with select statement in a VHDL design, we can assign different values to a signal based on the value of some other signal in our design.
The with select statement is probably the most intuitive way of modelling a mux in VHDL.
The code snippet below shows the basic syntax for the with select statement in VHDL.
When we use the VHDL with select statement, the <mux_out> field is assigned data based on the value of the <address> field.
When the <address> field is equal to <address1> then the <mux_out> signal is assigned to <a>, for example.
We use the the others clause at the end of the statement to capture instance when the address is a value other than those explicitly listed.
We can exclude the others clause if we explicitly list all of the possible input combinations.
- With Select Mux Example
Let’s consider a simple four to one multiplexer to give a practical example of the with select statement. The output Q is set to one of the four inputs (A,B, C or D) depending on the value of the addr input signal.
The circuit diagram below shows this circuit.
This circuit is simple to implement using the VHDL with select statement, as shown in the code snippet below.
VHDL When Else Statements
We use the when statement in VHDL to assign different values to a signal based on boolean expressions .
In this case, we actually write a different expression for each of the values which could be assigned to a signal. When one of these conditions evaluates as true, the signal is assigned the value associated with this condition.
The code snippet below shows the basic syntax for the VHDL when else statement.
When we use the when else statement in VHDL, the boolean expression is written after the when keyword. If this condition evaluates as true, then the <mux_out> field is assigned to the value stated before the relevant when keyword.
For example, if the <address> field in the above example is equal to <address1> then the value of <a> is assigned to <mux_out>.
When this condition evaluates as false, the next condition in the sequence is evaluated.
We use the else keyword to separate the different conditions and assignments in our code.
The final else statement captures the instances when the address is a value other than those explicitly listed. We only use this if we haven't explicitly listed all possible combinations of the <address> field.
- When Else Mux Example
Let’s consider the simple four to one multiplexer again in order to give a practical example of the when else statement in VHDL. The output Q is set to one of the four inputs (A,B, C or D) based on the value of the addr signal. This is exactly the same as the previous example we used for the with select statement.
The VHDL code shown below implements this circuit using the when else statement.
- Comparison of Mux Modelling Techniques in VHDL
When we write VHDL code, the with select and when else statements perform the same function. In addition, we will get the same synthesis results from both statements in almost all cases.
In a purely technical sense, there is no major advantage to using one over the other. The choice of which one to use is often a purely stylistic choice.
When we use the with select statement, we can only use a single signal to determine which data will get assigned.
This is in contrast to the when else statements which can also include logical descriptors.
This means we can often write more succinct VHDL code by using the when else statement. This is especially true when we need to use a logic circuit to drive the address bits.
Let's consider the circuit shown below as an example.
To model this using a using a with select statement in VHDL, we would need to write code which specifically models the AND gate.
We must then include the output of this code in the with select statement which models the multiplexer.
The code snippet below shows this implementation.
Although this code would function as needed, using a when else statement would give us more succinct code. Whilst this will have no impact on the way the device works, it is good practice to write clear code. This help to make the design more maintainable for anyone who has to modify it in the future.
The VHDL code snippet below shows the same circuit implemented with a when else statement.
Instantiating Components in VHDL
Up until this point, we have shown how we can use the VHDL language to describe the behavior of circuits.
However, we can also connect a number of previously defined VHDL entity architecture pairs in order to build a more complex circuit.
This is similar to connecting electronic components in a physical circuit.
There are two methods we can use for this in VHDL – component instantiation and direct entity instantiation .
- VHDL Component Instantiation
When using component instantiation in VHDL, we must define a component before it is used.
We can either do this before the main code, in the same way we would declare a signal, or in a separate package.
VHDL packages are similar to headers or libraries in other programming languages and we discuss these in a later post.
When writing VHDL, we declare a component using the syntax shown below. The component name and the ports must match the names in the original entity.
After declaring our component, we can instantiate it within an architecture using the syntax shown below. The <instance_name> must be unique for every instantiation within an architecture.
In VHDL, we use a port map to connect the ports of our component to signals in our architecture.
The signals which we use in our VHDL port map, such as <signal_name1> in the example above, must be declared before they can be used.
As VHDL is a strongly typed language, the signals we use in the port map must also match the type of the port they connect to.
When we write VHDL code, we may also wish to leave some ports unconnected.
For example, we may have a component which models the behaviour of a JK flip flop . However, we only need to use the inverted output in our design meaning. Therefore, we do not want to connect the non-inverted output to a signal in our architecture.
We can use the open keyword to indicate that we don't make a connection to one of the ports.
However, we can only use the open VHDL keyword for outputs.
If we attempt to leave inputs to our components open, our VHDL compiler will raise an error.
- VHDL Direct Entity Instantiation
The second instantiation technique is known as direct entity instantiation.
Using this method we can directly connect the entity in a new design without declaring a component first.
The code snippet below shows how we use direct entity instantiation in VHDL.
As with the component instantiation technique, <instance_name> must be unique for each instantiation in an architecture.
There are two extra requirements for this type of instantiation. We must explicitly state the name of both the library and the architecture which we want to use. This is shown in the example above by the <library_name> and <architecture_name> labels.
Once the component is instantiated within a VHDL architecture, we use a port map to connect signals to the ports. We use the VHDL port map in the same way for both direct entity and component instantiation.
Which types can not be used with the VHDL logical operators?
Scalar types such as integer and real.
Write the code for a 4 input NAND gate
We can use two different types of statement to model multiplexors in VHDL, what are they?
The with select statement and the when else statement
Write the code for an 8 input multiplexor using both types of statement
Write the code to instantiate a two input AND component using both direct entity and component instantiation. Assume that the AND gate is compiled in the work library and the architecture is named rtl.
Leave a Reply Cancel reply
Your email address will not be published. Required fields are marked *
Save my name, email, and website in this browser for the next time I comment.
Table of Contents
Sign up free for exclusive content.
Don't Miss Out
We are about to launch exclusive video content. Sign up to hear about it first.
- Product Manual
- Knowledge Base
- Release Notes
- Tech Articles
- Screencasts
Signal Assignments in VHDL: with/select, when/else and case
Sometimes, there is more than one way to do something in VHDL. OK, most of the time , you can do things in many ways in VHDL. Let’s look at the situation where you want to assign different values to a signal, based on the value of another signal.
With / Select
The most specific way to do this is with as selected signal assignment. Based on several possible values of a , you assign a value to b . No redundancy in the code here. The official name for this VHDL with/select assignment is the selected signal assignment .
When / Else Assignment
The construct of a conditional signal assignment is a little more general. For each option, you have to give a condition. This means that you could write any boolean expression as a condition, which give you more freedom than equality checking. While this construct would give you more freedom, there is a bit more redundancy too. We had to write the equality check ( a = ) on every line. If you use a signal with a long name, this will make your code bulkier. Also, the separator that’s used in the selected signal assignment was a comma. In the conditional signal assignment, you need the else keyword. More code for the same functionality. Official name for this VHDL when/else assignment is the conditional signal assignment
Combinational Process with Case Statement
The most generally usable construct is a process. Inside this process, you can write a case statement, or a cascade of if statements. There is even more redundancy here. You the skeleton code for a process (begin, end) and the sensitivity list. That’s not a big effort, but while I was drafting this, I had put b in the sensitivity list instead of a . Easy to make a small misstake. You also need to specify what happens in the other cases. Of course, you could do the same thing with a bunch of IF-statements, either consecutive or nested, but a case statement looks so much nicer.
While this last code snippet is the largest and perhaps most error-prone, it is probably also the most common. It uses two familiar and often-used constructs: the process and the case statements.
Hard to remember
The problem with the selected and conditional signal assignments is that there is no logic in their syntax. The meaning is almost identical, but the syntax is just different enough to throw you off. I know many engineers who permanenty have a copy of the Doulos Golden Reference Guide to VHDL lying on their desks. Which is good for Doulos, because their name gets mentioned all the time. But most people just memorize one way of getting the job done and stick with it.
- VHDL Pragmas (blog post)
- Records in VHDL: Initialization and Constraining unconstrained fields (blog post)
- Finite State Machine (FSM) encoding in VHDL: binary, one-hot, and others (blog post)
- "Use" and "Library" in VHDL (blog post)
- The scope of VHDL use clauses and VHDL library clauses (blog post)
- Search Search Search …
VHDL Description of Variables, Signals and Constants
- Course Name: Digital Systems Design
- Course Code: ECEL 4110
- Chapter Title: Introduction to VHDL
- Chapter No.: One
- Lecture Title: VHDL Description of Variables, Signals and Constants
- Variables and Signals in VHDL appears to be very similar. They can both be used to hold any type of data assigned to them. The most obvious difference is that variables use the := assignment symbol whereas signals use the <= assignment symbol.
- Signals can be considered as wires in a schematic circuit that can have a current value and future values, and that are a function of the signal assignment statements.
- On the other hand, Variables and Constants are used to model the behavior of a circuit and are used in processes, procedures and functions, similarly as they would be in a programming language.
- A constant can have a single value of a given type and cannot be changed during the simulation.
- A constant is declared as follows,
constant list_of_name_of_constant: type [ := initial value] ;
where the initial value is optional.
- Constants can be declared at the start of an architecture and can then be used anywhere within the architecture.
- Constants declared within a process can only be used inside that specific process.
constant DELAY1: time := 4 ns;
constant DATA_BUS: integer := 16;
- A variable can have a single value, as with a constant, but a variable can be updated using a variable assignment statement. The variable is updated without any delay as soon as the statement is executed. Variables must be declared inside a process (and are local to the process).
- The variable declaration is as follows:
variable list_of_variable_names: type [ := initial value] ;
variable CNTR_BIT: bit :=0;
variable SUM: integer range 0 to 256 :=16;
variable STS_BIT: bit_vector (7 downto 0);
- The variable SUM, in the example above, is an integer that has a range from 0 to 256 with initial value of 16 at the start of the simulation. The third example defines a bit vector or 8 elements: STS_BIT(7), STS_BIT(6),… STS_BIT(0). A variable can be updated using a variable assignment statement such as
Variable_name := expression;
- As soon as the expression is executed, the variable is updated without any delay.
- Signals are declared outside the process using the following statement:
signal list_of_signal_names: type [ := initial value] ;
signal SUM, CARRY: std_logic ;
signal CLOCK: bit ;
signal VALUE: integer range 0 to 100;
- Signals are updated when their signal assignment statement is executed, after a certain delay, as illustrated below,
SUM <= (A xor B) after 2 ns;
- If no delay is specified, the signal will be updated after a delta delay where delta is an infinitesimal time unit used by simulator for processing the signals.
- One can also specify multiple waveforms using multiple events as illustrated below,
signal wavefrm : std_logic ;
wavefrm <= ‘0’, ‘1’ after 5ns, ‘0’ after 10ns, ‘1’ after 20 ns;
Next Lecture: VHDL Modules: Entity and Architecture
You may also like
Stepper motor interfacing with 8086 microprocessor.
Course Details Field of Study: Computer Science & Engineering Course Name: Interfacing Techniques Description: Stepper motor interfacing with 8086 microprocessor to rotate […]
Matlab Code for Monson H. Hayes Statistical DSP Computer Exercise C3.4
Matlab Code for Monson H. Hayes Statistical DSP Computer Exercise C3.4 of chapter 3. The problem, matlab code and output of simulation […]
Data Encryption Program Using Javascript
Developing Data Encryption Program Using Javascript Encryption is the process of transforming (or encoding) plain text in to cipher text. In this […]
What is LASER?
Course Details Field of Study: Electronics Engineering Course Name: Optoelectronics Description: LASER is an acronym for Light Amplification by Stimulated Emission of […]
Leave a comment Cancel reply
Your email address will not be published. Required fields are marked *
Save my name, email, and website in this browser for the next time I comment.
Currently you have JavaScript disabled. In order to post comments, please make sure JavaScript and Cookies are enabled, and reload the page. Click here for instructions on how to enable JavaScript in your browser.
Sequential statement | ---- used in ----> | Process Procedure |
Syntax |
Rules and Examples |
A sequential signal assignment takes effect only when the process suspends. If there is more than one assignment to the same signal before suspension, the last one executed takes effect: | |
An equivalent process: |
If a signal which has assignments to it within a process is also in the sensitivity list, it may cause the process to be reactivated: In this architecture, the signals Y and Z will both get the same value (2*A + B) because even though two assignments to the signal M are executed, the first will always be superceded by the second |
A sequential signal assignment may have a delay: | |
The rules about what happpens when a delayed signal assignment is subsequently overridden are complex: see the LRM section 8.3.1 or "A Primer" by Jayaram Bhasker, section 4.14 | A delayed sequential signal assignment does suspend the process or procedure for the time specified. The assignment is to occur after the specified time, and any further sequential statements are executed immediately |
Synthesis Issues |
Sequential signal assignments are generally synthesisable, providing they use types and operators acceptable to the synthesis tool. Delays are usually ignored. All signals with assignments to them within a "clocked process" will become the outputs of registers in the synthesised design. Signals driven by a "combinational process" will be inferred as the outputs of combinational logic a signal which is assigned only under certain conditions may infer a latch. Assignment to 'Z' will normally generate tri-state drivers. assignment to 'X' may not be supported. |
Whats New in '93 |
In VHDL -93, any signal assignment statement may have an optional label:
- Network Sites:
- Technical Articles
- Market Insights
![assignment statement meaning in vhdl All About Circuits](https://www.allaboutcircuits.com/images/site/AAClogo.png)
- Or sign in with
- iHeartRadio
![assignment statement meaning in vhdl All About Circuits](https://www.allaboutcircuits.com/images/site/AAClogo.png)
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.
![assignment statement meaning in vhdl assignment statement meaning in vhdl](https://www.allaboutcircuits.com/uploads/articles/Arar_VHDL_signal_assignment1.jpg)
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.
![assignment statement meaning in vhdl assignment statement meaning in vhdl](https://www.allaboutcircuits.com/uploads/articles/Fig2.png)
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 .
![assignment statement meaning in vhdl assignment statement meaning in vhdl](https://www.allaboutcircuits.com/uploads/articles/Arar_VHDL_signal_assignment2.jpg)
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.
![assignment statement meaning in vhdl assignment statement meaning in vhdl](https://www.allaboutcircuits.com/uploads/articles/Mux1_Sim1_Waveform.png)
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.
![assignment statement meaning in vhdl assignment statement meaning in vhdl](https://www.allaboutcircuits.com/uploads/articles/Table1m12272017.png)
The following VHDL code can be used to describe the above truth table:
The ISE simulation is shown in Figure 5.
![assignment statement meaning in vhdl assignment statement meaning in vhdl](https://www.allaboutcircuits.com/uploads/articles/prio_encoder1_Waveform.png)
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.
![assignment statement meaning in vhdl assignment statement meaning in vhdl](https://www.allaboutcircuits.com/uploads/articles/Arar_VHDL_signal_assignment3.jpg)
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
![assignment statement meaning in vhdl assignment statement meaning in vhdl](https://www.allaboutcircuits.com/images/site/default_avatar.jpg)
Great content. The link to the ISE guide requires password. Can we get that posted again? Thanks!
You May Also Like
![assignment statement meaning in vhdl assignment statement meaning in vhdl](https://www.allaboutcircuits.com/uploads/tech-days/_lg/How_to_avoid.jpg)
How to Avoid Electronics Manufacturing and Assembly Issues Using Integrated ECAD/MCAD
In Partnership with MacroFab
![assignment statement meaning in vhdl assignment statement meaning in vhdl](https://www.allaboutcircuits.com/uploads/thumbnails/_315_220/nonlinear-magnetization-curves-thumbnail.jpg)
Using Permeability to Understand Magnetic Core Saturation
by Dr. Steve Arar
![assignment statement meaning in vhdl assignment statement meaning in vhdl](https://www.allaboutcircuits.com/uploads/thumbnails/_315_220/Working_vitrimer-based_PCB_.jpg)
![](http://serviteca.online/777/templates/cheerup2/res/banner1.gif)
New Vitrimer PCBs Can Be Recycled Many Times Over
by Duane Benson
![assignment statement meaning in vhdl assignment statement meaning in vhdl](https://www.allaboutcircuits.com/uploads/thumbnails/_315_220/Companies_Rally_RISC-V_Support.jpg)
Companies Rally RISC-V Support for AI and HPC Applications
by Arjun Nijhawan
![assignment statement meaning in vhdl assignment statement meaning in vhdl](https://www.allaboutcircuits.com/uploads/thumbnails/_315_220/ST_NFC_reader.jpg)
ST Introduces Minuscule NFC Reader for Embedded Contactless Interaction
![assignment statement meaning in vhdl All About Circuits](https://www.allaboutcircuits.com/images/site/AAClogo2.png)
Welcome Back
Don't have an AAC account? Create one now .
Forgot your password? Click here .
![assignment statement meaning in vhdl All About Circuits Logo](https://www.allaboutcircuits.com/images/site/aac_logo.png)
Stack Exchange Network
Stack Exchange network consists of 183 Q&A communities including Stack Overflow , the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
Assignments with after and signals
I am trying to understand how assignments with 'after foo' work, so I read about the delay model and simulated the following code:
In Xilinx's Vivaldo, I get the following output:
When what I expected was simply a 10ns delay. Can someone explain what is going on here?
EDIT: To be clear, my beef here is that, if the behaviour I'm describing is indeed default, it sounds like an awful leak of abstraction: when I write
the behavior I expect would be one that simulates a latch being driven (temp is the input, goes_out is the output), and so temp would have to keep its new value for 10ns in order to properly drive the latch (hence the "inertial delay" model).
Now, if this were indeed the case, the proper behaviour for my circuit would be to do nothing, since I attempt to write a 'Z' to goes_out and immediately after that, that 'Z' is overwritten by a '1' - therefore, the value of temp driving the latch is not kept, and it fails to drive goes_out. (obviously you can't drive latches with 'Z', thought I could use '0' and '1' and my point would stand)
So my question is: is there a good reason for this odd behaviour? To me, it seems trivial to "make things right": the algorithm that simulates the inertial delay could check for changes in the value of temp in the delta cycle it is being assigned to goes_out, and cancel the assignment if something is happening - instead of only cancelling the assignment if the NEW value of temp does not change.
2 Answers 2
The key here is your use of <= , which causes assignments to happen in parallel.
Consider the assignment of 1 to input . That triggers the process(input) . The first line temp <= input; effectively queues the assignment of 1 to temp immediately after the current time step . temp retains the value of 0 for the execution of the next line, which is interpreted as "queue the assignment of the value that temp had at the start of this process to be assigned to goes_out in 10ns time".
If you collapse it to goes_out <= input after 10ns; and remove temp entirely, it looks a bit more intuitive. Or view the values of temp and input in your simulator.
temp hasn't change by the time you read it to assign it to goes_out . Until some time passes (ie all the processes triggered during this delta cycle have completed) any assignments made in those processes are merely scheduled to happen at the next time step.
You could do:
The wait for 0 ps; forces some time to pass (0ps counts as forcing delta cycles to finish)
![assignment statement meaning in vhdl Martin Thompson's user avatar](https://i.sstatic.net/4Nkc0.jpg?s=64)
- \$\begingroup\$ Didn't work. The compiler says: "process cannot have both a wait statement and a sensitivity list". \$\endgroup\$ – FrancoVS Commented May 7, 2013 at 22:11
- 1 \$\begingroup\$ Yes, I didn't put a complete process in, it was just to show how to make time pass. See update for code which shows the whole process \$\endgroup\$ – Martin Thompson Commented May 8, 2013 at 8:53
Your Answer
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 vhdl simulation delay or ask your own question .
- The Overflow Blog
- Where does Postgres fit in a world of GenAI and vector databases?
- Featured on Meta
- We've made changes to our Terms of Service & Privacy Policy - July 2024
- Bringing clarity to status tag usage on meta sites
Hot Network Questions
- A string view over a Java String
- Flight left while checked in passenger queued for boarding
- What is this strengthening dent called in a sheet metal part?
- Can a rope thrower act as a propulsion method for land based craft?
- Is it possible to configure an eqnarry environment to automatically split over multiple pags
- How to attach a 4x8 plywood to a air hockey table
- Why are most big lakes in North America aligned?
- Is every recursively axiomatizable and consistent theory interpretable in the true arithmetic (TA)?
- Completely introduce your friends
- How to allocate memory in NASM without C functions (x64)?
- What is the difference between using a resistor or a capacitor as current limiter?
- What did Jesus mean by 'cold water'' in Mtt 10:42?
- Why doesn't the immune system ever destroy the glucagon-producing alpha cells in the pancreas? Why only insulin-making beta cells?
- Routing radiused edges between nodes in TikZ
- Should I report a review I suspect to be AI-generated?
- Philosophies about how childhood beliefs influence / shape adult thoughts
- Fill a grid with numbers so that each row/column calculation yields the same number
- How could Bangladesh protect itself from Indian dams and barrages?
- My school wants me to download an SSL certificate to connect to WiFi. Can I just avoid doing anything private while on the WiFi?
- How Can this Limit be really Evaluated?
- How do I safely remove a mystery cast iron pipe in my basement?
- Do metal objects attract lightning?
- Can a 2-sphere be squashed flat?
- CPU is idle, but huge load, and NFS client stop responding
Designing Circuits with VHDL
1. introduction, 2. combinational circuits, signal assignments in vhdl.
library IEEE; use IEEE.STD_LOGIC_1164.ALL; use IEEE.STD_LOGIC_ARITH.ALL; use IEEE.STD_LOGIC_UNSIGNED.ALL; entity fullAdder is port( A,B: in std_logic; -- input bits for this stage Ci: in std_logic; -- carry into this stage S: out std_logic; -- sum bit Co: out std_logic -- carry out of this stage ); end fullAdder; architecture a1 of fullAdder is begin S <= A xor B xor Ci; Co <= (A and B) or ((A xor B) and Ci); end a1;
Processes and Conditional Statements
if a = '0' then x <= a; y <= b; elsif a = b then x <= '0'; y <= '1'; else x <= not b; y <= not b; end if;
Every signal that is assigned a value inside a process must be defined for all possible conditions.
Case Statements
Structural vhdl, 3. sequential circuits.
![assignment statement meaning in vhdl](https://www.arl.wustl.edu/serialComareSim.jpg)
busy is high when the circuit is in the middle of performing an operation; while busy is high, the insert and delete inputs are ignored; the outputs are not required to have the correct values when busy is high empty is high when there are no pairs stored in the priority queue; delete operations are ignored in this case full is high when there is no room for any additional pairs to be stored; insert operations are ignored in this case
- For adjacent pairs in the bottom row, the pair to the left has a key that is less than or equal to that of the pair on the right.
- For pairs that are in the same column, the key of the pair in the bottom row is less than or equal to that of the pair in the top row.
- In both rows, the empty blocks (those with dp =0) are to the right and either both rows have the same number of empty blocks or the top row has one more than the bottom row.
entity priQueue is Port (clk, reset : in std_logic; insert, delete : in std_logic; key, value : in std_logic_vector(wordSize-1 downto 0); smallValue : out std_logic_vector(wordSize-1 downto 0); busy, empty, full : out std_logic ); end priQueue; architecture a1 of priQueue is constant rowSize: integer := 4; -- local constant declaration type pqElement is record dp: std_logic; key: std_logic_vector(wordSize-1 downto 0); value: std_logic_vector(wordSize-1 downto 0); end record pqElement; type rowTyp is array(0 to rowSize-1) of pqElement; signal top, bot: rowTyp; type state_type is (ready, inserting, deleting); signal state: state_type; begin process(clk) begin if rising_edge(clk) then if reset = '1' then for i in 0 to rowSize-1 loop top(i).dp <= '0'; bot(i).dp <= '0'; end loop; state <= ready; elsif state = ready and insert = '1' then if top(rowSize-1).dp /= '1' then for i in 1 to rowSize-1 loop top(i) <= top(i-1); end loop; top(0) <= ('1',key,value); state <= inserting; end if; elsif state = ready and delete = '1' then if bot(0).dp /= '0' then for i in 0 to rowSize-2 loop bot(i) <= bot(i+1); end loop; bot(rowSize-1).dp <= '0'; state <= deleting; end if; elsif state = inserting or state = deleting then for i in 0 to rowSize-1 loop if top(i).dp = '1' and (top(i).key < bot(i).key or bot(i).dp = '0') then bot(i) <= top(i); top(i) <= bot(i); end if; end loop; state <= ready; end if; end if; end process; smallValue <= bot(0).value when bot(0).dp = '1' else (others => '0'); empty <= not bot(0).dp; full <= top(rowSize-1).dp; busy <= '1' when state /= ready else '0'; end a1;
4. Functions and Procedures
package commonConstants is constant lgWordSize: integer := 4; constant wordSize: integer := 2**lgWordSize; end package commonConstants; library IEEE; use IEEE.STD_LOGIC_1164.ALL; use IEEE.STD_LOGIC_ARITH.ALL; use IEEE.STD_LOGIC_UNSIGNED.ALL; use work.commonConstants.all; entity firstOne is Port (a: in std_logic_vector(0 to wordSize-1); x: out std_logic_vector (lgWordSize downto 0) ); end firstOne; architecture a1 of firstOne is procedure encode(x: in std_logic_vector(0 to wordSize-1); indx: out std_logic_vector(lgWordSize-1 downto 0); errFlag: out std_logic) is -- Unary to binary encoder. -- Input x is assumed to have at most a single 1 bit. -- Indx is equal to the index of the bit that is set. -- If no bits are set, errFlag bit is made high. -- This is conceptually simple. -- -- indx(0) is OR of x(1),x(3),x(5), ... -- indx(1) is OR of x(2),x(3), x(6),x(7), x(10),x(11), ... -- indx(2) is OR of x(4),x(5),x(6),x(7), x(12),x(13),x(14(,x(15),... -- -- but it's tricky to code so it works for different word sizes. type vec is array(0 to lgWordSize-1) of std_logic_vector(0 to (wordSize/2)-1); variable fOne: vec; variable anyOne: std_logic_vector(0 to wordSize-1); begin -- fOne(0)(j) is OR of first j bits in x1,x3,x5,... -- fOne(1)(j) is OR of first j bits in x2,x3, x6,x7, x10,x11,... -- fOne(2)(j) is OR of first j bits in x4,x5,x6,x7, x12,x13,x14,x15,... for i in 0 to lgWordSize-1 loop for j in 0 to (wordSize/(2**(i+1)))-1 loop for h in 0 to (2**i)-1 loop if j = 0 and h = 0 then fOne(i)(0) := x(2**i); else fOne(i)((2**i)*j+h) := fOne(i)((2**i)*j+h-1) or x(((2**i)*(2*j+1))+h); end if; end loop; end loop; indx(i) := fOne(i)((wordSize/2)-1); end loop; anyOne(0) := x(0); for i in 1 to wordSize-1 loop anyOne(i) := anyOne(i-1) or x(i); end loop; errFlag := not anyOne(wordSize-1); end procedure encode; function firstOne(x: std_logic_vector(0 to wordSize-1)) return std_logic_vector is -- Returns the index of the first 1 in bit string x. -- If there are no 1's in x, the value returned has a -- 1 in the high order bit. variable allZero: std_logic_vector(0 to wordSize-1); variable fOne: std_logic_vector(0 to wordSize-1); variable rslt: std_logic_vector(lgWordSize downto 0); begin allZero(0) := not x(0); fOne(0) := x(0); for i in 1 to wordSize-1 loop allZero(i) := (not x(i)) and allZero(i-1); fOne(i) := x(i) and allZero(i-1); end loop; encode(fOne,rslt(lgWordSize-1 downto 0),rslt(lgWordSize)); return rslt; end function firstOne; begin x <= firstOne(a); end a1;
5. Closing Remarks
Introduction to Digital Systems: Modeling, Synthesis, and Simulation Using VHDL by
Get full access to Introduction to Digital Systems: Modeling, Synthesis, and Simulation Using VHDL and 60K+ other titles, with a free 10-day trial of O'Reilly.
There are also live events, courses curated by job role, and more.
4.9 VHDL SIGNAL AND GENERATE STATEMENTS
4.9.1 signal statement.
Signal is a VHDL keyword. It declares a signal of specified data type. A signal declaration is used to represent internal signals within an architecture declaration.
![assignment statement meaning in vhdl images](https://www.oreilly.com/api/v2/epubs/9780470900550/files/images/ch004-f020.jpg)
Figure 4.20 Logic Circuit with Internal Signals
Unlike entity ports, internal signals do not have a direction. Signal assignment statements execute only when the associated signals (appearing on the right-hand side of the assignment statement) change values. In VHDL, the order of concurrent statements in VHDL code does not affect the order in which the statements are executed. Signal assignments are concurrent and could execute in parallel fashion. Consider the logic circuit in Figure 4.20 where the internal signals are identified. Notice, that from the point of view of an entity declaration, the signals Sig 1 , Sig 2 , and Sig 3 are internal signals. They are neither input ports nor output ports, and therefore do not have a direction.
The VHDL program in Figure 4.21 implements the logic circuit in Figure 4.20 . The entity declaration is similar to that in the VHDL program of Figure 4.6 . The architecture declaration has been modified to include the internal signals. The logic function of the circuit is described in an indirect way using the internal signals. Both VHDL implementations ( Figures 4.6 and 4.21 ) have the same logic function and should yield the same ...
Get Introduction to Digital Systems: Modeling, Synthesis, and Simulation Using VHDL now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.
Don’t leave empty-handed
Get Mark Richards’s Software Architecture Patterns ebook to better understand how to design components—and how they should interact.
It’s yours, free.
![assignment statement meaning in vhdl Cover of Software Architecture Patterns](https://cdn.oreillystatic.com/oreilly/images/report-software-architecture-patterns-553x420.jpg)
Check it out now on O’Reilly
Dive in for free with a 10-day trial of the O’Reilly learning platform—then explore all the other resources our members count on to build skills and solve problems every day.
![assignment statement meaning in vhdl assignment statement meaning in vhdl](https://cdn.oreillystatic.com/oreilly/images/laptop-flat-topics-ml-1124x638.png)
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:
![assignment statement meaning in vhdl Two Way Mux example](https://surf-vhdl.com/wp/wp-content/uploads/2015/07/mux2.jpg)
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.
![assignment statement meaning in vhdl 4 way mux representation](https://surf-vhdl.com/wp/wp-content/uploads/2015/07/mux4.jpg)
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 .
![assignment statement meaning in vhdl Altera RTL Viewer of 4-way-mux](https://surf-vhdl.com/wp/wp-content/uploads/2015/07/mux4-rtl-viewer.jpg)
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.
![assignment statement meaning in vhdl Altera MAP Viewer of 4-way-mux](https://surf-vhdl.com/wp/wp-content/uploads/2015/07/mux4-map-viewer.jpg)
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:
![assignment statement meaning in vhdl Altera RTL Viewer of 4-way-mux using select clause](https://surf-vhdl.com/wp/wp-content/uploads/2015/07/mux4_select-rtl-viewer.jpg)
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.
![assignment statement meaning in vhdl Altera MAP Viewer of 4-way-mux using select clause](https://surf-vhdl.com/wp/wp-content/uploads/2015/07/mux4_select-map-viewer.jpg)
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
courses:system_design:vhdl_language_and_syntax:concurrent_statements
- Concurrent Statements
Introduction
- Concurrent statements are executed at the same time;
- independent of the order in which they appear
All statements within architectures are executed concurrently.
While it is possible to use VHDL processes as the only concurrent statement, the necessary overhead (process, begin, end, sensitivity list) lets designer look for alternatives when the sequential behavior of processes is not needed.
The signal assignment statement:
- The signal on the left side of the assignment operator ’⇐’ receives a new value whenever a signal on the right side changes.
- The new value stems from another signal or can be calculated from a number of other signals.
Conditional Signal Assignment (CSA)
- Condition is a boolean expression
- Conditions may overlap
- Equivalent of “if …, elsif …, else” constructs
The signal assignment can be extended by the specification of conditions.
The condition is appended after the new value and is introduced by the keyword ’ when ’.
VHDL'87: The keyword ’ else ’ is also strictly necessary after each condition. (as an unconditional signal assignment has to be present.)
Consequently, using VHDL'87 standard it is not possible to generate storage elements with an conditional signal assignment. Otherwise the behavior is equivalent to the if …, elsif …, else … construct that is used within processes.
VHDL’93: Conditional Signal Assignment
Vhdl rtl-synthesis standard (ieee 1076.6:2004).
6.2.1.2 Level-sensitive storage from concurrent signal assignment
“A level-sensitive storage element (=Latch) shall be modeled for a signal that is assigned in a concurrent signal assignment statement that can be mapped to a process that adheres to the rules in 6.2.1.1.”
6.2.1.1 Level-sensitive storage from process with sensitivity list
“A level-sensitive storage element (=Latch) shall be modeled for a signal (or variable) when all the following apply:
- The signal (or variable) has an explicit assignment.
- The signal (or variable) does not have an execution path with <clock_edge> as a condition.
- There are executions that do not execute an explicit assignment to the signal (or variable).”
6.4 Combinational logic
“Any process that does not contain a clock edge or wait statement shall model either combinational logic or level-sensitive sequential logic. If there is always an assignment to a variable or signal in all possible executions of the process and all variables and signals have well-defined values, then the variable or signal models combinational logic.”
➔ so if not, a Latch could be generated…
- If the variable or signal is updated before it is read in all executions of a process, then it shall model combinational logic.
- If a variable or signal is read before it is updated, then it may model combinational logic.
Conditional Signal Assignment: Example
In the example, two equivalent descriptions of a simple multiplexer are given.
Please note that all signals appearing on the right side of the signal assignment operator are entered into the process’ sensitivity list.
The unconditional else path could be replaced by an unconditional (default) signal assignment in front of the if statement.
This “default” assignments would be overwritten, if any of the conditions were true.
Selected Signal Assignment (SSA)
- Choice options must not overlap
- Single values
- Value ranges
- Selection of values (“I” means “or”)
- “when others” covers all remaining choice options ➔ is mandatory!
- Equivalent of “case …, when …” constructs
The behavior of the so called selected signal assignment is similar to the case statement.
It suffers from the same restrictions as its sequential counterpart, namely that all possible choice options have to be covered and none of the choice options may overlap with another.
Selected Signal Assignment: Example
Like with conditional signal assignments, the signal assignment operator ’⇐’ can be seen as the core of the construct.
Again, the choice options are appended after the keyword ’when’, yet the different assignment alternatives are separated by ’,’ symbols. The equivalent of the ’case EXPRESSION is’ construct from the case statement must be placed as header line in front of the actual assignment specification. The keywords have to be translated, however, to ’with EXPRESSION select’.
- Conditional signal assignment: decision based upon several signals
- Selected signal assignment: decision based upon values of an expression
- Conditional signal assignment ⇔ if …, elsif …, else …, end if
- Selected signal assignment ⇔ case …, when …, end case
All concurrent statements describe the functionality of multiplexer structures.
VHDL'87 : It is impossible to model storage elements , like flip flops with concurrent statements, only.
Consequently, the unconditional else path is necessary in conditional signal assignments.
Every concurrent signal assignment, whether conditional or selected, can be modelled with a process construct, however.
As sequentially executed code is easier comprehensible, the concurrent versions should be used as shortcut when simple functionality would be obfuscated by the process overhead, only.
- ...are only executed, when a signal changes, that is read in the statement.
- ...appear in the statement part of an architecture.
Chapters of System Design > VHDL Language and Syntax
- General Issues
- VHDL Structural Elements
- Process Execution
- Extended Data Types
- Sequential Statements
- Subprograms
- Subprogram Declaration and Overloading
- 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.
VHDL: setting a constant conditionally based on another constant's value
I need to set a constant's value using an "if-else" or "case", and select a different constant value based on another constant's value. Is this possible in VHDL? It would be a one time change of constant values at the beginning of simulation... Example:
The above VHDL code gives the error message:
In Verilog, Its very easy to do this type of thing...so I assume VHDL has a away to do this as well? Verilog example:
![assignment statement meaning in vhdl pico's user avatar](https://i.sstatic.net/WtYR8.jpg?s=64)
- 1 Vhdl 2019 will (finally) allow this code. – Tricky Commented Aug 6, 2019 at 6:02
3 Answers 3
This solution is a little bit strange, but it works:
- Yes, that is the way to do it, and VHDL overloading allows you to declare multiple functions with the same name but different argument and result types, whereby the VHDL compiler will apply the right function like magic ;-) – Morten Zilmer Commented Aug 5, 2019 at 16:56
Correct answers have been posted, but there are also one-line alternatives.
The simplest solution is to change the datatype of burst_mode to integer with range 0 to 1, and then use some math:
If the datatype of burst_mode cannot be changed, then you can also do it with a type conversion:
Though pico posted an answer already, it is a very relevant question worthy of elaboration.
The declaration of the function may be similar to "conditional expressions" or "ternary if" in other languages like Python with res_true if cond else res_false or C with cond ? res_true : res_false .
The condition is then a boolean, and the result for true comes before the result for false . The declaration could be like:
And having multiple functions with different result types, a version for real could also be defined like:
![assignment statement meaning in vhdl Morten Zilmer's user avatar](https://i.sstatic.net/qj1Of.jpg?s=64)
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 vhdl or ask your own question .
- The Overflow Blog
- Where does Postgres fit in a world of GenAI and vector databases?
- Featured on Meta
- We've made changes to our Terms of Service & Privacy Policy - July 2024
- Bringing clarity to status tag usage on meta sites
- What does a new user need in a homepage experience on Stack Overflow?
- Staging Ground Reviewer Motivation
- Feedback requested: How do you use tag hover descriptions for curating and do...
Hot Network Questions
- Can a rope thrower act as a propulsion method for land based craft?
- What happens when a helicopter loses the engine and autorotation is not initiated?
- How can you trust a forensic scientist to have maintained the chain of custody?
- What can I do when someone else is literally duplicating my PhD work?
- Is it advisable to contact faculty members at U.S. universities prior to submitting a PhD application?
- Are there any theoretical reasons why we cannot measure the position of a particle with zero error?
- Can light become a satellite of a black hole?
- What did Jesus mean by 'cold water'' in Mtt 10:42?
- How can I draw water level in a cylinder like this?
- Trying to find an old book (fantasy or scifi?) in which the protagonist and their romantic partner live in opposite directions in time
- Is there a way to skip frames in beamer?
- DATEDIFF Rounding
- Why did General Leslie Groves evade Robert Oppenheimer's question here?
- Completely introduce your friends
- What is the difference between using a resistor or a capacitor as current limiter?
- How bad would near constant dreary/gloomy/stormy weather on our or an Earthlike world be for us and the environment?
- Refactoring Enumeration Classes to Use Generics
- Change output language of internal commands like "lpstat"?
- Can a 2-sphere be squashed flat?
- Do metal objects attract lightning?
- Story where character has "boomerdisc"
- Why do National Geographic and Discovery Channel broadcast fake or pseudoscientific programs?
- Routing radiused edges between nodes in TikZ
- Is the theory of ordinals in Cantor normal form with just addition decidable?
![](http://serviteca.online/777/templates/cheerup2/res/banner1.gif)
IMAGES
COMMENTS
In VHDL there are two assignment symbols: <= Assignment of Signals. := Assignment of Variables and Signal Initialization. Either of these assignment statements can be said out loud as the word "gets". So for example in the assignment: test <= input_1; You could say out loud, "The signal test gets (assigned the value from) input_1.".
The signal assignment operator specifies a relationship between signals. In other words, the signal on the left side of the signal assignment operator is dependent upon the signals on the right side of the operator. (Source: Digital_Mclogic_Design by Bryan Mealy, Section: The Signal Assignment Operator: "<=", page 339)
The VHDL code shown below uses one of the logical operators to implement this basic circuit. and_out <= a and b; Although this code is simple, there are a couple of important concepts to consider. The first of these is the VHDL assignment operator (<=) which must be used for all signals.
The statement "Others => '0'" is a feature of the VHDL when the coder want to defined several items in an array with the same value. In your example, all item std_logic in the array are set to '0'. Another application of this statement is to set some items at a specific value and all others at a default value : cmd_r <= (0 => '1', 4 => '1',
With / Select. The most specific way to do this is with as selected signal assignment. Based on several possible values of a, you assign a value to b. No redundancy in the code here. The official name for this VHDL with/select assignment is the selected signal assignment. with a select b <= "1000" when "00", "0100" when "01", "0010" when "10 ...
A VHDL description has two domains: a sequential domain and a concurrent domain. The sequential domain is represented by a process or subprogram that contains sequential statements. These statements are exe-cuted in the order in which they appear within the process or subprogram, as in programming languages.
The most obvious difference is that variables use the := assignment symbol whereas signals use the <= assignment symbol. Signals can be considered as wires in a schematic circuit that can have a current value and future values, and that are a function of the signal assignment statements.
The next statement is a condition that tests whether the en signal is '1'. If it is, the statements between the keywords then and end if are executed, updating the pro-cess's variables using the values on the input signals. After the conditional if state-ment, there are four signal assignment statements that cause the output signals to be
The VHDL program in Figure 4.8 implements the 2: 1 multiplexer in Figure 4.7. The function of the multiplexer is described in the architecture of the code using selected signal assignment statements. The signal assignment statement selected begins with the reserved keyword with followed by the selection condition, which is in the input signal, s.
In VHDL-93, any signal assignment statement may have an optional label: label: signal_name <= expression; 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:
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 ...
Until some time passes (ie all the processes triggered during this delta cycle have completed) any assignments made in those processes are merely scheduled to happen at the next time step. You could do: process. begin. wait until input'event; temp <= input; wait for 0 ps; goes_out <= temp after 10ns; end process;
The conditional signal assignment statement is very general in that any readable signals or inputs may be tested to determine the value to be assigned to the target. Note that the simple concurrent signal assignment statement (e.g. A <= B;) is simply the degenerate case of a conditional signal assignment statement. The selected signal ...
While VHDL code bears a superficial resemblance to programs in conventional sequential programming languages, the meaning of VHDL code differs in important ways from sequential programs. Ultimately, the meaning of a VHDL specification is a circuit, while the meaning of an ordinary program is the sequential execution of the program statements ...
4.9 VHDL SIGNAL AND GENERATE STATEMENTS 4.9.1 Signal Statement. Signal is a VHDL keyword. It declares a signal of specified data type. A signal declaration is used to represent internal signals within an architecture declaration.. Figure 4.20 Logic Circuit with Internal Signals. Unlike entity ports, internal signals do not have a direction. Signal assignment statements execute only when the ...
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:
5. 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: Y <= A when ASel = '1' else B when BSel = '1' else C ;
VHDL RTL-Synthesis Standard (IEEE 1076.6:2004) 6.2.1.2 Level-sensitive storage from concurrent signal assignment. "A level-sensitive storage element (=Latch) shall be modeled for a signal that is assigned in a concurrent signal assignment statement that can be mapped to a process that adheres to the rules in 6.2.1.1.".
The simplest solution is to change the datatype of burst_mode to integer with range 0 to 1, and then use some math: library ieee; use ieee.std_logic_1164.all; use ieee.numeric_std.all; entity bridge is. generic (. burst_mode :integer range 0 to 1 := 0. ); end entity;