Vous êtes sur la page 1sur 8

Mini projet en VHDL

IGUERHZIFEN & EL MANIOUI

Page 1

Mini projet en VHDL


Cahier de charge:
La figure ci-dessous reprsente une ligne de chemin de fer emprunte dans les deux sens ( A vers C ou de C vers A ) . Sur cette ligne sont disposs 3 capteurs A,B et C quon supposera enclenchs (=1) lorsque la tte du train les atteint , et declenchs (=0) seulement aprs le passage de la queue du train . Lordre darrt des vhicules circulant dans la route et allant traverser la voie ferme est matrialis par un feu rouge R (R=1 :feu allum , R=0 :feu teint). Fonctionnement : Si le train circule de A vers C , le feu rouge sallume ds que la tte du train atteint le capteur A(A=1), et ne steint que lorsque la queue du train quitte B(B=0).De mme , lorsque le train circule de C vers A , le feu rouge sallume ds lenclenchement de C et ne steint quaprs dclenchement de B . La largeur L du train peut tre : L>AB ou L<AB , L>BC ou L<BC . L#AB , L#BC , L<AC .

Vhicules R route

Voie ferre A B Train C

Vhicules route

IGUERHZIFEN & EL MANIOUI

Page 2

Mini projet en VHDL


Diagramme de fluence :

IGUERHZIFEN & EL MANIOUI

Page 3

Mini projet en VHDL

Programmation avec VHDL :


---projet.VHD-----Une ligne de chemin de fer commande-----ralis par :-ZOUHAIR IGUERHZIFEN ---KHALID EL MANIOUI -------------------------bibliothques---------------------library ieee; use IEEE.std_logic_1164.all; --------------Dfinition de l'entit-----------------------entity projet is port (RAZ, clk :in std_logic; a,b,c:in std_logic; r:out std_logic); end projet;
IGUERHZIFEN & EL MANIOUI Page 4

Mini projet en VHDL


--Dfinition de L'architecture de la description d'tat-ARCHITECTURE diagramme OF projet IS TYPE etat_12 IS (INIT, V1, V2, V3, V4, V5,V6,V7,V11,V12,V13,V14); SIGNAL etat, nextetat :etat_12 ; signal x :std_logic ; BEGIN definir_etat: PROCESS( raz, clk) -- "definir_etat" :label optionnel BEGIN If raz = '1' THEN etat <= INIT; ELSIF rising_edge(clk) THEN etat <= nextetat; END IF; END PROCESS definir_etat; -------------------Dfinir les tats des sorties-----------sortie: process (etat,a,b,c,x) BEGIN CASE etat IS when INIT => r<='0'; if a='1' and b='0' and c='0' then nextetat <=V1; else x<='0'; if a='0' and b='0' and c='1' and x='0' then nextetat <=V11; else nextetat<=INIT; end if; end if; when V1=> r<='1'; if a='0' and b='0' and c='0' then nextetat <=V2; elsif a='1' and b='1' and c='0' then nextetat <=V3; else nextetat<=V1; end if; when V2=> r<='1'; if a='0' and b='1' and c='0' then nextetat <=V4; else nextetat<=V2; end if; when V3=> r<='1'; if a='0' and b='1' and c='0' then nextetat <=V4; else nextetat<=V3; end if; when V4=> r<='1'; if a='0' and b='0' and c='0' then nextetat <=V5; elsif a='0' and b='1' and c='1' then nextetat <=V6;
IGUERHZIFEN & EL MANIOUI Page 5

Mini projet en VHDL


elsif a='1' and b='1' and c='0' then nextetat <=V13; else nextetat<=V4; end if; when V5=> r<='0'; if a='0' and b='0' and c='1' then nextetat <=V7; else nextetat<=V5; end if; when V6=> r<='1'; if a='0' and b='0' and c='1' then nextetat <=V7; else nextetat<=V6; end if; when V7 => r<='0'; if nextetat=V7 then x<='1'; end if; if a='0' and b='0' and c='0' then nextetat <=INIT; else nextetat<=V7; end if; when V11=> r<='1'; if a='0' and b='1' and c='1' and x='0' then nextetat <=V12; elsif a='0' and b='0' and c='0' and x='0' then nextetat <=V2; else nextetat<=V11; end if; when V12=> r<='1'; if a='0' and b='1' and c='0' and x='0' then nextetat <=V4; else nextetat<=V12; end if; if a='1' and b='1' and c='0' and x='0' then nextetat <=V13; elsif a='0' and b='0' and c='0' and x='0' then nextetat <=V5; else nextetat<=V4; end if; when V13=> r<='1'; if a='1' and b='0' and c='0' and x='0' then nextetat <=V14; else nextetat<=V13; end if; when V14 => r<='0'; if a='0' and b='0' and c='0' and x='0' then nextetat <=INIT; else nextetat <=V14; end if; END CASE; END process sortie ; END diagramme;
IGUERHZIFEN & EL MANIOUI Page 6

Mini projet en VHDL

Le circuit logique :

IGUERHZIFEN & EL MANIOUI

Page 7

Mini projet en VHDL

IGUERHZIFEN & EL MANIOUI

Page 8

Vous aimerez peut-être aussi