Baixe o app para aproveitar ainda mais
Prévia do material em texto
Sistemas Digitais EEL 480 GTA/UFRJ LuísHenriqueM.K.Costa luish@gta.ufrj.br UFRJ – DEL/Poli e PEE/COPPE P.O. Box 68504 - CEP 21945-970 - Rio de Janeiro - RJ Brasil - http://www.gta.ufrj.br IntroduçãoàLinguagemVHDL Introdução � VHDL � VHSIC( VeryHighSpeedIntegratedCircuits )H ardware DescriptionL anguage � DesenvolvidapeloDepartmentodeDefesaamericanoe m 1983 GTA/UFRJ � Objetivos � Descriçãoporsoftwaredoprojeto( design)deumsistema digital � Simulação � Síntese ObservaçõesIniciais � Alinguagemnãoé case-sensitive � masfreqüentementesãousadasmaiúsculasparaas palavrasreservadas GTA/UFRJ � Comentários � Iniciadospor“- -” � Terminadospelofimdelinha ComandosBásicos � Atribuiçãodesinal � A<=B; � Comparação � “=”,“>”,“<”,etc. � OperaçõesBooleanas GTA/UFRJ � OperaçõesBooleanas � AND,OR,NOT,XOR � DeclaraçõesSequenciais � CASE,IF,FOR � DeclaraçõesConcorrentes � WHEN-ELSE ElementosBásicosdeumModeloVHDL � DeclaraçãoENTITY � Descrevea interface domodelo:entradasesaídas � CorpoARCHITECTURE Descreveo comportamento domodelo GTA/UFRJ � Descreveo comportamento domodelo � PodemexistirváriasARCHITECTUREparaumamesma ENTITY Exemplo– Contadorde4bits ENTITYcounter_4ISPORT( clk,reset,load_counter: INBIT; data: INBIT_VECTOR(3DOWNTO 0); count_zero: OUTBIT; count: BUFFERBIT_VECTOR(3DOW NTO0) ); GTA/UFRJ ); ENDcounter_4; � Cadasinalpossuium modo (IN,OUT,BUFFER)e um tipo (BIT,BIT_VECTOR) Modosdo Signal � IN:dadosfluemparadentrodaEntidade,quenãopode escreverestessinais � Ex.Clock,entradasdecontrole,entradasunidirecionaisd edados � OUT:dadosfluemparaforadaEntidade,quenãopodel er estessinais OmodoOUTéusadoquandoaEntidadenuncalêestesdad os GTA/UFRJ � OmodoOUTéusadoquandoaEntidadenuncalêestesdad os � BUFFER:dadosfluemparaforadaEntidade,que pode ler estessinais,permitindorealimentaçãointerna � Noentanto,oBUFFERnãopodeserusadopara entrada dedados � INOUT:dadospodemfluirparadentroouparaforadaEnt idade � Sódeveserusadosenecessário � Ex.Barramentodedadosbidirecional � Designmenoscompreensível Tiposdo Signal � BIT,BIT_VECTOR � Valores:“ 0”ou“ 1” � Atribuiçãodevalor: bit_signal<='0'; � NativosdalinguagemVHDL,nãoprecisamdedeclaraç ão debiblioteca GTA/UFRJ debiblioteca � STD_LOGIC,STD_LOGIC_VECTOR � Valores:“ 0”,“ 1”,“ -”(don’tcare),“ Z”(altaimpedância), “X”(indeterminado) � Bibliotecaieee � Declaraçõesnecessárias � LIBRARY � USE Vetores � Declaração bit_vector_signal:BIT_VECTOR(maximum_indexDOWNT O0); � Atribuição GTA/UFRJ � Atribuição � bit_vector_signal(0)<=‘1’; � bit_vector_signal(0)<=bit_signal; � bit_vector_signal<="0001"; Exemplo– Contadorde4bits LIBRARYieee; USEieee.std_logic_1164.ALL; ENTITYcounter_4ISPORT( clock,reset,load_counter:INstd_logic; data:INstd_logic_vector(3 DOWNTO0); GTA/UFRJ data:INstd_logic_vector(3 DOWNTO0); reset_alert:OUTstd_logic; count:BUFFERstd_logic_vector (3DOWNTO0) ); ENDcounter_4; � EvitarmisturarBITcomSTD_LOGIC � Existemfunçõesdeconversãomasocódigosetorna mais complexo Exemplo– Maioriade3 LIBRARYieee; USEieee.std_logic_1164.ALL; ENTITYmajconcIS PORT(A,B,C: INstd_logic; Y: OUTstd_logic GTA/UFRJ Y: OUTstd_logic ); ENDmajconc; ARCHITECTUREarq_majconcOFmajconcIS BEGIN Y<=(AandB)or(AandC)or(BandC); ENDarq_majconc; Exemplo: Full-Adder ENTITYfull_adderIS PORT( a,b,carry_in: INBIT; sum,carry_out: OUTBIT ); ENDfull_adder; GTA/UFRJ ENDfull_adder; ARCHITECTURE1 ARCHITECTUREdataflowOFfull_adderIS � Descriçãodefluxodedados( dataflow)ouconcorrente � Atribuiçõesocorremsimultaneamente � Geralmentedescrevemofluxodedadosnosistema GTA/UFRJ ARCHITECTUREdataflowOFfull_adderIS SIGNALx1,x2,x3,x4,y1:BIT; BEGIN x1<=aANDb; x2<=aANDcarry_in; x3<=bANDcarry_in; x4<=x1ORx2; carry_out<=x3ORx4; y1<=aXORb; sum<=y1XORcarry_in; ENDdataflow; ARCHITECTURE1 ARCHITECTUREdataflowOFfull_adderIS � Pode-seeventualmenteeliminarossinaisinternos adicionais… GTA/UFRJ ARCHITECTUREdataflowOFfull_adderIS BEGIN carry_out<=(aANDb)OR(aANDcarry_in)OR( bANDcarry_in); sum<=aXORbXORcarry_in; ENDdataflow; ARCHITECTURE1 output_vector<="00"WHEN(a=b) ELSE"01"WHEN(a=c)- - anda!=b ELSE"10"WHEN(a=d) - - anda!=banda!=c � Pode-seusarcomandoscondicionais… GTA/UFRJ ELSE"10"WHEN(a=d) - - anda!=banda!=c ELSE"11"; WITHselecting_vectorSELECT output_vector<="0001"WHEN"00", "0010"WHEN"01", "0100"WHEN"10", "1000"WHEN"11"; ARCHITECTURE2 � DescriçãoEstrutural � Asatribuiçõesdesinaissãofeitasatravésdomape amentode entradasesaídasde componentes GTA/UFRJ ENTITYfull_adderISPORT( a,b,carry_in:INBIT; sum,carry_out:OUTBIT ); ENDfull_adder; ARCHITECTUREstructuralOFfull_adderIS SIGNALx1,x2,x3,x4,y1:BIT; COMPONENTand_gatePORT( a,b :INBIT; a_and_b: OUTBIT ); ENDCOMPONENTand_gate; COMPONENTor_gatePORT( a,b :INBIT; a_or_b:OUTBIT ); ENDCOMPONENTor_gate; COMPONENTxor_gatePORT( a,b :INBIT; GTA/UFRJ a,b :INBIT; a_xor_b:OUTBIT ); ENDCOMPONENTxor_gate; BEGIN and0:and_gatePORTMAP(a,b,x1); and1:and_gatePORTMAP(a,carry_in,x2); and2:and_gatePORTMAP(b,carry_in,x3); or0:or_gatePORTMAP(x1,x2,x4); or1:or_gatePORTMAP(x3,x4,carry_out); xor0:xor_gatePORTMAP(a,b,y1); xor1:xor_gatePORTMAP(y1,carry_in,sum); ENDstructural; ARCHITECTURE3 � DescriçãoComportamental � Usadanadescriçãodesistemasseqüenciais � Elementofundamental:PROCESS label (opcional),apalavra PROCESS,euma listadesensibilidade GTA/UFRJ � label (opcional),apalavra PROCESS,euma listadesensibilidade process_name:PROCESS(sensitivity_list_signal_1,. ..) BEGIN -- comandosdoprocesso ENDPROCESSprocess_name; Codificadordeprioridade libraryieee; useieee.std_logic_1164.all; entitypriorityis � 7entradas � Y7maisprioritária � Saída:3bits GTA/UFRJ entitypriorityis port(y1,y2,y3,y4,y5,y6,y7:instd_logic; dout:outstd_logic_vector(2downto0) ); endpriority; � Saída:3bits � Indicaentradamais prioritáriaem1 � 0senenhuma entradaem1 Codificadordeprioridade architectureifelsofpriorityis begin process(y1,y2,y3,y4,y5,y6,y7) begin if(y7='1')thendout<="111"; � Comcomandos IF/ELSIF GTA/UFRJ if(y7='1')thendout<="111"; elsif(y6='1')thendout<="110"; elsif(y5='1')thendout<="101"; elsif(y4='1')thendout<="100"; elsif(y3='1')thendout<="011"; elsif(y2='1')thendout<="010"; elsif(y1='1')thendout<="001"; elsedout<="000"; endprocess; endifels; Codificadordeprioridade architectureso_ifofpriorityis begin process(y1,y2,y3,y4,y5,y6,y7) begin dout<="000; if(y1='1')thendout<="001";endif; � Comcomandos IF � NoPROCESS,o GTA/UFRJ if(y1='1')thendout<="001";endif; if(y2='1')thendout<="010";endif; if(y3='1')thendout<="011";endif; if(y4='1')thendout<="100";endif; if(y5='1')thendout<="101";endif; if(y6='1')thendout<="110";endif; if(y7='1')thendout<="111";endif; endprocess; endso_if; � NoPROCESS,o últimocomando executadoéoque conta � Porissoaordem dasatribuiçõesfoi invertida Codificadordeprioridade architecturewhenelseofpriorityis begin dout<="111"when(y7='1')else "110"when(y6='1')else "101"when(y5='1')else � Comapenasum comando WHEN/ELSE GTA/UFRJ "101"when(y5='1')else "100"when(y4='1')else "011"when(y3='1')else "010"when(y2='1')else "001"when(y1='1')else "000"; endwhenelse; � SemPROCESS MUX4:1comvetoresde8bits libraryieee; useieee.std_logic_1164.all; entitymux4to1_8is port( a,b,c,d:instd_logic_vector(7downto0); sel:instd_logic_vector(1downto0); dout:outstd_logic_vector(7downto0) GTA/UFRJ dout:outstd_logic_vector(7downto0) ); endmux4to1_8; architecturewhenelseofmux4to1_8is begin dout<=bwhen(sel="01")else cwhen(sel="10")else dwhen(sel="11")else a;-- default endwhenelse; Circuitoseqüencial:Contadorde4bits � Aentradaclockdeterminaquandooestadodocircui tomuda GTA/UFRJ ENTITYcounter_4ISPORT( clock,reset,load_counter:INBIT; data:INBIT_VECTOR(3DOWNTO 0); reset_alert:OUTBIT; count:BUFFERBIT_VECTOR(3DOW NTO0) ); ENDcounter_4; Exemplo:Contador ARCHITECTUREbehavioralOFcounter_4IS BEGIN upcount:PROCESS(clock)BEGIN IF(clock'eventANDclock='1')THEN IFreset='1'THEN count<="0000"; ELSIFload_counter='1'THEN count<=data; ELSE count(0)<=NOTcount(0); count(1)<=count(0)XORcount(1); GTA/UFRJ count(1)<=count(0)XORcount(1); count(2)<=(count(0)ANDcount(1))XORcount(2); count(3)<=(count(0)ANDcount(1)ANDcount(2))XOR count(3); IFcount="0000"THEN reset_alert<='1'; ELSE reset_alert<='0'; ENDIF;-- IFcount="0000" ENDIF;-- IFload='1' ENDIF;-- IF(clock'eventANDclock='1') ENDPROCESSupcount; ENDbehavioral;
Compartilhar