VHDL Exercices Du Cours

download VHDL Exercices Du Cours

of 16

Transcript of VHDL Exercices Du Cours

Introduction au langage VHDL

Exercices:1 Fonctions logiques combinatoires . ................................................3 1.1 Exercice 1 : Dcodage dadresses . ..............................................3 1.2 Exercice 2 : Multiplexeur . .....................................................5 1.3 Exercice 3 : Dcodeur Hexadcimal / 7 segments . ................................7 1.4 Exercice 4 : Dmultiplexeur 1 8 . ..............................................9 2 Sorties trois tats, entres/sorties . ...........................................10 2.1 Exercice 5 : Buffer trois tats . ..............................................10 2.2 Exercice 6 : Transceiver . .....................................................10 3 Circuits logiques squentiels . ..................................................11 3.1 Exercice 7 : Latch . ...........................................................11 3.2 Exercice 8 : Registre . ........................................................12 3.3 Exercice 9 : Registre avec mise zro asynchrone . ............................12 3.4 Exercice 10 : Registre avec mise zro et mise un synchrone ................13 3.5 Exercice 11 : Compteur binaire avec mise zro asynchrone ....................13 3.6 Exercice 12 : Compteur binaire chargeable .....................................14 3.7 Exercice 13 : Compteur/Dcompteur binaire chargeable . .........................16

2

Introduction au langage VHDL

1 Fonctions logiques combinatoires1.1 Exercice 1 : Dcodage dadresses Logigramme de la fonction raliser On donne ci-dessous un plan mmoire (mapping memory) raliser. A15 A14 A13 $FFFF ROM1 (8k) $E000 $DFFF ROM2 (8k) $C000 $BFFF Libre (32k) $4000 $3FFF I/O (8k) $2000 $1FFF RAM (8k) $0000 Solution 1 classique : Tableau dadressageA15 A14 A13 A12 A11 A10 A9 A8 A7 A6 A5 A4 A3 A2 A1 A0 @ $FFFF $E000 $DFFF $C000 $BFFF $4000 $3FFF $2000 $1FFF $0000 Remarque : Les broches de slection des botiers mmoires sont actives ltat bas. Decod_Add

ROM1 ROM2 Libre IO RAM

Equations /ROM1 =

/Libre /A13 A13

/A15./A14

/0A115.A14

A15.A14

A15./A14

/ROM2 = /libre = /I_O =

/RAM =

Solution 2 : Description flot de donnes en VHDL (.vhd) entity Decod_Add is

architecture flot_Decod_Add of Decod_Add is begin

end flot_Decod_Add; 3

Introduction au langage VHDL

Solution 3 : Descriptions comportementales en VHDL (.vhd) Utilisation dune affectation concurrente conditionnelle On se limite la sortie ROM1. entity Decod_Add1 is port( BusAdd: in std_logic_vector (15 downto 13) ; ROM1: out std_logic ); end Decod_Add1 ; architecture comporte1_Decod_Add1 of Decod_Add1 is begin ROM1 Z) est quivalente ZZZZZZZZ

2.2 Exercice 6 : Transceiver Ecrire le fichier .VHD correspondant au transceiver ci-dessous.

OEAB

8 D_IN

8

D_OUT

OEBA

entity Transceiver is

architecture comporte_Trans of Transceiver is begin

end comporte_Trans; end Transceiver;

10

Introduction au langage VHDL

Schma RTL du Transceiver

3 Circuits logiques squentielsCircuit squentiel asynchrone Rappel : Un latch (ou verrou) possde deux modes de fonctionnement : passant lorsque son entre LE (Latch Enable) est un (par exemple), verrouill lorsque LE est zro. 3.1 Exercice 7 : LATCH Ecrire le fichier .VHD correspondant au Latch ci-dessous. 8

D LE

8

Q

entity Latch is

architecture comporte_Latch of Latch is begin

end Latch;

end comporte_Latch;

Schma RTL du LATCH

11

Introduction au langage VHDL

Circuits squentiels synchrones 3.2 Exercice 8 : Registre 8 bits Ecrire le fichier .VHD correspondant au registre ci-dessous. D CLK 8 8 Fonctionnement Q [X]; @repeat 5 {[c,0,0,X] -> [X];} [c,0,1,8] -> [X]; @repeat 20 {[c,0,0,X] -> [X];} end

Simulation fonctionnelle

15

Introduction au langage VHDL

3.7 Exercice 13 : Compteur/Dcompteur binaire chargeable Ecrire le fichier .VHD correspondant au compteur/dcompteur ci-dessous. 8 D clk load rst down up entity CMP_DEC is architecture comporte_CMP_DEC of CMP_DEC isCMPDEC

8 Q

Fonctionnement attendu - chargement synchrone, - reset asynchrone UP DOWN___Comportement_______ 0 0 Rien 1 0 compte 0 1 dcompte 1 1 Rien

begin

end CMP_DEC; end comporte_CMP_DEC;

Fichier de simulation .abvmodule testcpde // input clk, rst, load,up,down D_7_,D_6_,D_5_,D_4_,D_3_,D_2_,D_1_,D_0_ // output Q_7_,Q_6_,Q_5_,Q_4_,Q_3_,Q_2_,Q_1_,Q_0_

pin; pin ;

pin istype 'reg_d,buffer';

// Vectors Q = [Q_7_,Q_6_,Q_5_,Q_4_,Q_3_,Q_2_,Q_1_,Q_0_]; D = [D_7_,D_6_,D_5_,D_4_,D_3_,D_2_,D_1_,D_0_]; // constantes c = .c.; x = .x.; X = [x,x,x,x,x,x,x,x]; equations test_vectors ([clk,rst,load,up,down,D] -> [Q]) [c,1,0,0,0,0] -> [X]; @repeat 10 {[c,0,0,1,0,X] -> [X];} [c,0,1,0,0,20] -> [X]; @repeat 10 {[c,0,0,0,1,X] -> [X];} end

16

Introduction au langage VHDL

Fichier .vhd entity Div3b is port( E, Rc: in std_logic ; s: out std_logic ); end Div3b; architecture Comporte of Div3b is (A REFAIRE) type liste_etat is (Etat0,Etat1,Etat2,Etat3); signal etat:liste_etat; begin process(E) begin if (E'event and E='1') then case etat is when Etat0 => s