VHDL Syntax
VHDL Syntax
page 1 page 3
Type declaration Reserved words
architecture a of e is package p is
abs range
begin access record
end p; if
after register
end a; impure
alias reject
in
all rem
inertial
and report
inout
architecture return
is
array rol
label
assert ror
library
attribute select
in the STD.STANDARD package: linkage
begin severity
type boolean is (false, true); literal
block shared
type bit is ('0', '1'); loop
body signal
type character is (NUL, SOH, <...> '}', '~', DEL); map
buffer sla
type string is array(positive range <>) of character; mod
bus sll
type bit_vector is array(natural range <>) of bit; nand
case sra
new
component srl
next
configuration subtype
nor
constant then
not
disconnect to
null
in the IEEE.STD_LOGIC_1164 package: downto transport
of
type std_uLogic is ('U', 'X', '0', '1', 'Z', else type
on
'W', 'L', 'H', '-'); elsif unaffected
open
end units
or
type std_uLogic_vector is entity until
others
array(natural range <>) of std_uLogic; exit use
out
file variable
package
for wait
port
function when
procedure
generate while
process
generic with
in the IEEE.NUMERIC_STD package: pure
group xnor
type unsigned is array(natural range <>) of std_Logic; guarded xor
type signed is array(natural range <>) of std_logic;
page 4 page 2
Subtype declaration Signal declaration
begin begin
end p;
end a; end a;
page 5 page 7
Variable declaration Constant declaration
begin begin
end p;
end process p; end a;
page 8 page 6
Process statement
Concurrent architecture a of e is
begin
statements end a;
With statement
page 9 page 11
When statement Signal assignment
architecture a of e is architecture a of e is
begin begin
end a; end a;
y1 <= a;
y2 <= a and b;
y3 <= to_integer(a);
y <= "00000011";
y <= x0 when sel = '0' else y <= "0000" & "0011";
x1 when sel = '1' else y <= ('0', '0','0', '0','0', '0', '1', '1');
'X'; y <= (7 downto 2 => '0', 1|0 => '1');
y <= (7 downto 2 => '0', others => '1');
y1 <= a;
y2 <= a after 2 ns;
y3 <= inertial a after 1 ns;
y4 <= transport a after 4 ns;
y5 <= reject 1 ns inertial a after 5 ns;
page 12 page 10
With statement
architecture a of e is
begin
Sequential
end a; statements
page 13 page 15
Variable assignment
p: process (s_list)
begin
end process p;
y1 := a;
y2 := a and b;
y3 := to_integer(a);
page 16 page 14
If statement Loop statement
begin begin
if sel = 0 then
y <= x0;
elsif sel = 1 then multipl: for indexB in 0 to nBits-1 loop
y <= x1; partialProd: for indexA in nBits-1 downto 0 loop
elsif sel = 2 then partProd(indexA) <= a(indexA) and b(indexB);
y <= x2; end loop partialProd;
else if (a = '0') and (b = '0') then cumSum(indexB+1) <= cumSum(indexB) + partProd;
y <= x3; y <= '1'; end loop multipl;
end if; else
y <= '0';
end if;
page 17 page 19
Case statement
p: process (s_list)
begin
end process p;
case sel is
when "00" => y <= x0;
case opCode is
when "01" => y <= x1;
when add => y1 <= x0;
when "10" => y <= x2;
y2 <= x1;
when "11" => y <= x3;
when sub => y1 <= x1;
when others => null;
y2 <= x0;
end case;
when others => null;
end case;
case value is
when 1 => nBits <= 1;
when 2|3 => nBits <= 2;
when 4 to 7 => nBits <= 3;
when 8 to 15 => nBits <= 3;
when others => nBits <= 0;
end case;
case to_integer(sel) is
when 0 => y <= x0 after 1 ns;
when 1 => y <= x1 after 1 ns;
when 2 => y <= x2 after 1 ns;
when 3 => y <= x3 after 1 ns;
when others => y <= 'X';
end case;
page 20 page 18
Arithmetic operators
operator description
Operators +
-
addition
substraction
* multiplication
/ division
** power
abs absolute value
mod modulo
rem reminder of the division
sla arithmetic shift left
Logic operators sra arithmetic shift right
Arithmetic operators
Comparisons
Concatenation
page 21 page 23
Comparisons Logic operators
operator description operator description
= equal to not inversion
/= not equal to and logical AND
< smaller than or logical OR
> greater than xor exclusive-OR
<= smaller than or equal to nand NAND-function
>= greater than or equal to nor NOR-function
xnor exclusive-NOR
sll logical shift left
srl logical shift right
rol rotate left
ror rotate right
page 24 page 22
Concatenation
operator description
& concatenation
Attributes
page 25 page 27
Type related attributes
attribute result
flip: process(count1)
begin
for index in count1'low to count1'high loop
count2(index) <= count1(count1'length-index);
end loop;
end process flip;
page 28 page 26
Array related attributes Wait statement
attribute result
page 29 page 31
Assert statement
p: process
begin
Simulation
end process p; elements
page 32 page 30
Index
Lexical elements 1
Declarations 3
Concurrent statements 9
Sequential statements 15
Operators 21
Attributes 27
Simulation elements 29
Arithmetic operators
Array related attributes
Assert statement
Case statement
23
29
31
18
VHDL syntax
Comparisons
Concatenation
Constant declaration
24
25
6
shortform
If statement 17
Logic operators 22
Loop statement 19
Process statement 11
Reserved words 2
Type declaration 4
Type related attributes 28
Signal assignment 10
Signal declaration 7
Subtype declaration 5
Variable assignment 16
Variable declaration 8
Wait statement 30
When statement 12
With statement 13