Upload
others
View
8
Download
0
Embed Size (px)
Citation preview
Formation VHDL Vahid MEGHDADI
1
Conception circuit numérique
2- Introduction au langage
VHDL
Introduction A VHDL
Formation VHDL Vahid MEGHDADI
2
V H D L
V VHSIC (Very High Speed Integradted Circuit)
H Hardware
D Description
L Language
Introduction A VHDL
Formation VHDL Vahid MEGHDADI
3
Un peu d’histoire
•Début des années 80
•la nécessité d’un langage non ambigu des systèmes
matériels pour intégration à grande échelle
•normalisation pour être indépendant du fournisseur
•Norme définitive adoptée en 1987 : IEEE Std 1076
•La norme a été revue en 93, 2000 et 2002
•Les premiers outils de synthèse en 1995
Introduction A VHDL
Remarque
Formation VHDL Vahid MEGHDADI
4
Qu’est ce que on attend de VHDL
• VHDL est utilisé pour
• Décrire des circuits numériques
• Décrire des machines à états
• Préparer des signaux de test pour simuler cette écriture
• Le langage concurrent : Verilog
Introduction A VHDL
Formation VHDL Vahid MEGHDADI
5
Qu’est ce que on attend des outils de synthèse
•Une fois le programme en VHDL est écrit, il faut maintenant
le réaliser
•Synthèse logique : générer des fonctions logiques à partir
du programme
•Implémentation : adapter la logique synthétisée à la cible
(mapping, placement routage)
•Génération : Générer un fichier binaire à télécharger sur
la cible (le FPGA)
Introduction A VHDL
Formation VHDL Vahid MEGHDADI
6
Rappel: Niveau d’abstraction
Comportemental
RTL
Logique
Layout
Introduction A VHDL
VHDL
Synthèse
comportemental
Synthèse
logique
Placement
routage
Formation VHDL Vahid MEGHDADI
7
Il existe 5 catégories d’unité de conception
•L’entité (mot clé entity)
Décrit un système vu extérieur (boîte noire)
•L’architecture (mot clé architecture)
Décrit l’intérieur (le fonctionnement) d’une boîte noire.
•La configuration (mot clé configuration)
•La déclaration de paquetage (mot clé package)
•Le corps de paquetage (mot clé package body)
Structure du VHDL
Structure du VHDL
Circuit
principal
Circuit
principal
Package
(librairie)
Formation VHDL Vahid MEGHDADI
8
Minimum design en VHDL
Deux unités obligatoires
• une entité
• une architectureUn circuit décrit en VHDL
Déclaration d’entité
Architecture
Formation VHDL Vahid MEGHDADI
9
Exemple simple: entité
Exemple: L’entité du circuit ci-contre qu’on appellera « AOI»
entity AOI is
Port(
A,B,C,D: in std_logic;
F : out std_logic);
end AOI;
AOI
L’entité déclare la vue externe
du circuit : les ports d’entrée-
sorties et leur type. Elle peut
aussi déclarer des paramètres.
Formation VHDL Vahid MEGHDADI
10
Exercice
entity test is
Port(
A,B: in std_logic;
D,F: out std_logic);
end test;
polling
TestA
B
D
F
entity test is
Port(
A: in std_logic;
B: in std_logic;
D: out std_logic);
F: out std_logic);
end test;
entity test is
Port(
A,B,D,F: std_logic);
end test;
entity test is
Port(
A,B: std_logic;
D,F: std_logic);
end test;
Fig A
Fig B
Fig C
Fig D
Formation VHDL Vahid MEGHDADI
1111
ENTITY nand_gate IS
PORT(
a : IN STD_LOGIC;
b : IN STD_LOGIC;
z : OUT STD_LOGIC
);
END nand_gate;
Reserved words
Entity namePort names Port type
Semicolon
No Semicolon
after last port
Port modes (data flow directions)
Entité décortiquée
ENTITY nand_gate IS PORT(a,b: IN STD_LOGIC;z : OUT STD_LOGIC
);END nand_gate;
Même chose mais en moins lisible, non recommandée !!
Entité
[index]
Formation VHDL Vahid MEGHDADI
12
Remarque
std_logic définit un type plus que binaire. En fait, un objet
de type std_logic peut recevoir des valeurs ‘0’ et ‘1’ mais
aussi autres valeurs comme par exemple « haute
impédance ».
On verra les types bien tôt.
On remarque aussi les modes des signaux: in, out. Il y en a
d’autres: inout et buffer. Xilinx ne conseille d’éviter le mode
buffer.
Formation VHDL Vahid MEGHDADI
13
Exemple simple: architecture
architecture v1 of AOI is
-- les déclarations
begin
F <= not((A and B) or (C and D));
end v1;
L’architecture définit le fonctionnement du circuit.
Formation VHDL Vahid MEGHDADI
14
Remarque
On remarque l’opérateur d’affectation <=
Les opérateurs logiques "and", "or", "nor", "nand" et "not"
font parti des opérateurs connus du langage.
On remarque aussi que -- est utilisé pour des commentaires.
Il existe deux parties dans l’architecture
- avant begin : zone des déclarations
- Après begin : la partie "exécutable".
Formation VHDL Vahid MEGHDADI
15
Exemple simple: architecture bis
architecture v2 of AOIis
signal I1,I2,I3: std_logic;
begin
I1 <= A and B;
I2 <= C and D;
I3 <= I1 or I2;
F <= not I3;
end v2;
I1, I2 et I3 sont des
signaux internes.
Formation VHDL Vahid MEGHDADI
16
Principe de concurrence
architecture v2 of AOI is
signal I1,I2,I3: std_logic;
begin
I1 <= A and B;
I2 <= C and D;
I3 <= I1 or I2;
F <= not I3;
end v2;
architecture v3 of AOI is
signal I1,I2,I3: std_logic;
begin
I1 <= A and B;
F <= not I3;
I2 <= C and D;
I3 <= I1 or I2;
end v3;
architecture v4 of AOI is
signal I1,I2,I3: std_logic;
begin
F <= not I3;
I3 <= I1 or I2;
I2 <= C and D;
I1 <= A and B;
end v4;
Tous les mêmes !
Formation VHDL Vahid MEGHDADI
17
Dans une architecture, toutes les instructions sont exécutées
en parallèle : elles sont concurrentes et non pas
« séquentielles ».
Ainsi, la partie après "begin" dans une architecture est une
zone concurrente.
Remarque
architecture v3 of AOI is
{zone de déclarations}
begin
{zone concurrente}
end v3;
Formation VHDL Vahid MEGHDADI
18
Décrire des délais
Dans des circuits réels, les portes logiques présentent des délais.
On peut aussi les décrire.
Formation VHDL Vahid MEGHDADI
19
Délai dans les affectations
- Une affectation sera déclenchée quand un évènement arrive
- Un évènement est un changement de valeur d’un signal
- Pour l’instruction ci-dessous, cet évènement est le passage de A de 0 à 1.
- Cependant, l’affectation se concrétise après 2 ns.
[index]
event
affectation
New event
Formation VHDL Vahid MEGHDADI
20
Attention: l’instruction d’affectation retardé est utilisée
en simulation, par contre n’a aucun effet en synthèse.
L’outil de synthèse ignore « after »:
Pour la synthèse :
I1 <= A and B after 2 ns; ≡ I1 <= A and B;
Le circuit qui sera réalisé présentera un délai qui
dépendra de la technologie utilisé, longueur des câblage,
etc.
TRES IMPORTANT
Formation VHDL Vahid MEGHDADI
21
Résultat obtenu en simulation
Résultat obtenu en synthèse
Formation VHDL Vahid MEGHDADI
22
Exemple
Demi-
additionneur
A
B
SUM
C
A B SUM C
0 0 0 0
0 1 1 0
1 0 1 0
1 1 0 1
Architecture
A
B
SUM
C
Formation VHDL Vahid MEGHDADI
23
entity DEMI_ADD is
port (A,B: in std_logic;
SUM,C: out std_logic);
end DEMI_ADD;
architecture COMPORT of DEMI_ADD is
begin
SUM <= A xor B; --instruction concurrente
C <= A and B; --instruction concurrente
end COMPORT;
Programme VHDL correspondant
Architecture
[index]
Formation VHDL Vahid MEGHDADI
24
Hiérarchisation en VHDL
Formation VHDL Vahid MEGHDADI
25
Hiérarchie in VHDL
- Un bloc conçu, testé, et fonctionnel peut être réutilisé. On
l’appelle component.
- Dans un design qui utilise ce component
1. On déclare l’entité du component
2. On instancie un exemplaire de ce component dans la
zone concurrente
3. On procède au câblage de ce component
Formation VHDL Vahid MEGHDADI
26
Exemple : multiplexeur 2 voies
Si SEL=‘0’, Y <=X1, et si SEL=‘1’, Y<=X2
Formation VHDL Vahid MEGHDADI
27
Déclaration de component
1-Déclaration du component
Formation VHDL Vahid MEGHDADI
28
Déclaration de signaux
Formation VHDL Vahid MEGHDADI
29
Instanciation du component
2-Instanciation du component et 3- câblage
[index]
Formation VHDL Vahid MEGHDADI
• Une introduction au langage VHDL a été donnée
• L’entité et l’architecture ont été abordées
• Nous avons appris l’affectation retardée
• L’hiérarchisation a été définie
30
Conclusion
Activities on VivadoVery beginning with VHDL
Run Vivado
then
Create a project
Create a VHDL file
Click
Create a VHDL file
main
A
B
C
We are going to design an xor gate.
Double click
The VHDL program
Here is the code that you should type: Save your
file
Create the input signals
Click
Create the input signals
Click
Double click
Simulate
Is the simulation result is what you were waiting for ?
Create the design on the FPGA
We are using the Basys 3 board:
SW1 -> BSW0 -> A
Led0 -> C
3.3 GND
V17
V16
SW0
SW1U16 led0
The signal A is connected to the pin V17, the B to V16 and the C to U16.
Pin assignment
Download the xdc file that contains all the pin connections of the board Basys 3 from:http://www.unilim.fr/pages_perso/vahid/VHDL/Basys3_Master.xdc
Save it the your project directory. Then add source
Browse to the xdc file Then finish
Connect the FPGA pins
We connect A to sw0, B to sw1, and C to led0.For that, in the Basys3_Master.xdc file, uncheck and modify the following lines
And also for the signal C connected to led0 :
FPGA implementationThe circuit is ready, we should generate the configuration file and then download it to the FPGA.
It takes time to complete !
then Here the board Basys3 should be connected to the PC.