Concurrent assignments
Combinational logic as equations
A concurrent signal assignment in VHDL (signal <= boolean expression) describes a piece of combinational logic that is always active, the same standing gate network the expression denotes, and it can be derived directly from a truth table as a sum of products.
Build it in the lab →You now know std_logic wires and the entity/architecture split. This lesson covers the workhorse of combinational VHDL: the concurrent signal assignment, the
F <= ... line. Every one is a standing gate network, and because a truth table completely specifies a combinational function, you can write the assignment straight from the table.Concurrent means always live
A statement like
F <= A and B is concurrent: it is not executed once, it describes a gate that drives F continuously from A and B. Write several such lines in an architecture and they all run at the same time, in parallel, in any order, because each is its own piece of hardware. This is the direct opposite of software statements, and it is exactly how every gate on your canvas behaves: always on, instantly reflecting its inputs.Because concurrent statements are parallel hardware, their order in the file does not matter.
F <= t and C; then t <= A and B; describes the same circuit as the reverse order: two gates wired together, and wires do not care which line you typed first. If reordering lines could change behavior, you are thinking in software, not hardware.From truth table to sum of products
Any combinational output can be written as a sum of products: OR together one product (an AND) for each input row where the output is
1, with each input that is 0 in that row negated. "Sum" is OR, "product" is AND, an old habit from boolean algebra. Take XOR, whose output is 1 exactly when the inputs differ:| A | B | F |
|---|---|---|
| 0 | 0 | 0 |
| 0 | 1 | 1 |
| 1 | 0 | 1 |
| 1 | 1 | 0 |
Read off the two rows where
F is 1. The row A=0, B=1 gives the product (not A) and B. The row A=1, B=0 gives A and (not B). OR them together and you have the equation, which is also the VHDL, line for line:library ieee;
use ieee.std_logic_1164.all;
entity xor_gate is
port (
A : in std_logic;
B : in std_logic;
F : out std_logic
);
end entity;
architecture rtl of xor_gate is
begin
F <= (not A and B) or (A and not B);
end architecture;That single expression is a complete description of XOR: two AND gates (the products), each fed by an inverter on one input, ORed together. It is the same structure you would draw by hand, just written as one line. The synthesis tool is free to optimise it (perhaps into NANDs), but the behavior is fixed by the equation.
F is 1 only when A and B differ, matching (not A and B) or (A and not B).A frequent mistake is forgetting to negate the inputs that are
0 in a row. The row A=0, B=1 is not A and B, it is (not A) and B, the term must be true for that exact row and no other. Drop the not and your equation lights up for the wrong input combination. Always negate every input that reads 0 in the row you are encoding.Why this matters: sum of products is the bridge from the truth tables you have been filling in to real HDL. Any combinational block you can describe with a table, a decoder, a comparator, one bit of an adder, you can now write as a concurrent assignment. A Karnaugh map then trims that equation to fewer gates. Sequential logic (anything that remembers) needs one more tool, the process, which is next.
Try it
Write the concurrent assignment for a two-input function
F that is 1 only when A=1 and B=0 (and 0 for all three other rows). Then say how many product terms it needs.Answer
Only one row has output
1, so it is a single product term: F <= A and not B;. With just one 1 in the table there is nothing to OR together. (This function is sometimes called "A AND NOT B", or "A but not B".) If two rows were 1, you would OR two products; the count of product terms equals the count of 1 rows.Frequently asked
What is a concurrent assignment in VHDL?
A concurrent signal assignment (signal <= expression) describes a piece of combinational logic that is always active. It is not executed once like a software statement; it is a standing gate network that continuously drives the signal from its inputs. Multiple concurrent statements all run in parallel.
Does the order of concurrent statements in VHDL matter?
No. Concurrent statements describe parallel hardware, so reordering them does not change the circuit. They are wires and gates connected together, and wires do not care which line you wrote first.
How do you write a VHDL equation from a truth table?
Use sum of products: OR together one product (AND) term for each row where the output is 1, negating every input that is 0 in that row. For XOR, the rows (A=0,B=1) and (A=1,B=0) give F <= (not A and B) or (A and not B).
What does sum of products mean?
It is a boolean expression written as an OR (the 'sum') of AND terms (the 'products'). Each product term is true for exactly one input combination, so ORing the terms for every '1' row reproduces the truth table exactly.
You've got the theory. Now build it from scratch and watch it work.
Build it in the lab →