DL3701-Fall - 2024-VHDL - Overview - I
DL3701-Fall - 2024-VHDL - Overview - I
Christophe Bobda
VHDL
Parallelism
3
a b f g h
0 0 1 0 1
0 1 0 0 1
1 0 1 1 0
1 1 0 1 1
𝑓 = 𝑎ത 𝑏ത + 𝑎𝑏ത
g = 𝑎𝑏ത + 𝑎𝑏
h = 𝑎ത 𝑏ത + 𝑎𝑏
ത + 𝑎𝑏
4
Entity – Wrapper and interface definition
ENTITY ENTITY
x1 x1 Signals can be connected
y y to ports from inside or from
x2 x2 outside.
5
Entity as „Black Box“
Example below: Entity with two inputs and one output port
Functionality not defined yet
Name two_gate
Port
x1
Structure y
Port and
x2 Behavior ?
6
Entity – Definition
Keywords in blue Library to be used Which part of the library should be
Architecture
The behavior of an Entity is x1
described in the Architecture. Structure y
and
The Architecture x2 Behavior
• has a unique name,
• signals and components can be internally declared,
• is assigned to a unique Entity.
Architecture name
9
XOR-Entity
LIBRARY ieee;
USE ieee.std_logic_1164.all;
ENTITY xor_gate IS
END behavioral;
10
VHDL Operators
Signal Assignment: y <= x1
Boolean Operators:
• AND/and: logical and
• OR/or: logical or
• NAND/nand: logical complement of and
• NOR/ nor: logical complement
• XOR/xor: logical exclusive
• XNOR/ xnor : logical complement of exclusive
VHDL JAVA
A <= B;
C <= A; = A = B;
C = A;
12
Example
LIBRARY ieee;
USE ieee.std_logic_1164.all;
ENTITY my_circuit IS
PORT( a, b : IN std_logic;
x, y, z : OUT std_logic );
END my_circuit ;
13
Example
Provide the VHDL design for the circuit below Entity Declaration
LIBRARY ieee;
USE ieee.std_logic_1164.all;
ENTITY example2 IS
PORT( A, B, c : IN std_logic;
w,y : IN std_logic;
z : IN std_logic;
x : IN std_logic;
H, g : OUT std_logic );
END example2;
Architecture Implementation
14
Design Flow
15
Signals
16
Internal Signals
ENTITY Position IS
PORT( A : in std_logic_vector( 2 downto 0 );
B : out std_logic_vector( 0 to 2 ) );
END Position;
Begin
signal1 <= A(0) AND B(2);
B(0) <= signal1 XOR A(1);
...
17
Example
Provide the VHDL design for the circuit below Entity Declaration
LIBRARY ieee;
USE ieee.std_logic_1164.all;
ENTITY example2 IS
PORT( A, B, c : IN std_logic;
w,y : IN std_logic;
int_sig
z : IN std_logic;
x : IN std_logic;
H, g : OUT std_logic );
END example2;
Architecture Implementation
Write(assign a value)
Signals not connected are floating and
to the signal
will be removed by the compiler architecture structural arc IS
signal int_sig: std_logic;
Assigning multiple values to a signal Read from
begin
the signal
simultaneously will creat and multi-drive
int_sig <= (b OR c)
situation.
g <= c AND (int_sig AND (NOT(a AND b)));
H <= NOT(NOT Y OR NOT z) AND (NOT W AND NOT X));
END architecture;
18
Variables
PROCESS(a, b)
VARIABLE c: bit;
c := b and c;
19
Datatypes
Datatype
• Define a set of values a signal or a variable can take, along with operations
on those values.
• Predefined datatype
• bit (std_logic): '0', '1'
• bit_vector (std_logic_vector): "00101", "001001"
• integer: 10, 123, 56
• character: 'a', 'v', 'n'
• string: "anmggzem"
• Boolean: FALSE, TRUE
• real: 1.23, 234.6, -0.34
• User-defined datatype
• SATES
• CAN_PARAMETERS
• NETWORK_PACKET
• …
20
Multi-Value Logic
• Standard logic IEEE 1164
• Declaration in Package „standard_logic_1164“
• Possible values:
´U´ not initialized
´X´ unknown
´0´ Logic 0
´1´ Logic 1
´Z´ high impedance
´W´ unknown (weak signal)
´L´ logic 0 ( weak signal)
´H´ Logic 1 (weak signal)
´-´ Don't care
• Standard_logic_vector: Vektor von standard_logic values
21
Bit vectors
20 21 2 2
3-bit wide, binary coded Bit-vector, 1 1 0 ➔ value: 3
write: x downto y means decreasing index from
the MSB to the LSB LSB MSB
(MSB: most significant bit, LSB: least ...)
Decreasing index
22
Bit Vectors
• Declaration
• signal Z_Bus: bit_vector(3 downto 0);
• signal Z_Bus: std_logic_vector(0 to 3);
• Assignment:
• “By position”
• Z_Bus(3) <= C_Bus(1);
• Z_Bus(1) <= C_Bus(1);
• Z_Bus(3 downto 2) <= “01“
• “Concatenation”:
• Z_Bus <= A & B & C & D;
• “Aggregates”:
• Z_Bus <= (A, B, C, D);
• “Specifying by element index“:
• Z_Bus <= (3 => ‘ 1‘, 1 downto 0 => ‘ 1‘, 2 => ‘ 0‘);
• “others“:
• Z_Bus <= (3 => ‘ 1‘, 1 => ‘ 0‘, other => ‘ 0‘);
23
VHDL Operators
• Logic operators
• AND, OR, NAND, NOR, XOR (equal precedence)
• NOT (higher precedence)
• comparison
• < (smaller than), <= (smaller or equal than), = (equal), >= (bigger or
equal) , > (bigger than), /= (different)
• Arithmetic operators
• + (Addition), - (subtraction), * (Multiplication), / (Division), **
(Exponent), abs (Magnitude), mod (Modulo), rem (Remainder)
24
Want To Learn More ?
Consider Undergraduate
Research With Us/Other Labs
https://smartsystems.ece.ufl.edu/
25