Baixe o app para aproveitar ainda mais
Prévia do material em texto
UNIVERSIDADE DO ESTADO DO RIO DE JANEIRO Centro de Tecnologia e Ciências Faculdade de Engenharia Departamento de Engenharia de Sistema e Computação Arquitetura de Computadores Profª Luiza de Macedo Mourelle Trabalho Simulador de Micro-Arquitetura Aluno: Andressa da Silva Siqueira Matricula: 2006.1.03249.11 Email: siq.andressa@gmail.com 1. Introdução 6 2. Descrição do modelo 6 3. Os componentes 7 3.1. Multiplexadores 7 3.2. Decodificadores 7 3.3. Deslocador 7 3.4. Circuitos Latch 7 3.5. Relógio (Clock) 8 3.6. Memória Principal 8 3.7. Memória de Controle 8 3.8. Barramento Tri-state 9 3.9. Registrador 9 3.10. ALU 9 3.11. LMS 9 4. Os componentes em VHDL 10 4.1. Mux 2X1 10 As especificações 10 Código algorítmico do componente 10 Testebench código algorítmico do componente 10 A simulação do testbench do código algorítmico do componente 11 Código comportamental do componente 12 Testebench do código comportamental do componente 12 A simulação do código comportamental do componente 13 Código estrutural do componente 14 TestBench do código estrutural do componente 14 A simulação código estrutural do componente 15 4.2. Mux 16 bits 16 As especificações 16 Código estrutural do componente 16 Testbench do código estrutural do componente 17 A simulação do código estrutural do componente 17 4.3. Decodificador 4 X 16 18 Código algorítmico do componente 18 Testbench do código algorítmico do componente 19 A simulação do código algorítmico do componente 20 Código comportamental do componente 21 Testbench do código comportamental do componente 22 Simulação do código comportamental do componente 23 Código estrutural do componente 24 Testbench do código estrutural do componente 25 Simulação do código estrutural do componente 26 4.4. ALU 1 bit 27 A especificação 27 Código algorítmico do componente 27 Testbench do código algorítmico do componente 29 A simulação do código algorítmico do componente 30 4.5. ALU 16 bit 31 A especificação 31 Código estrutural do componente 32 Testbench do código estrutural do componente 33 A simulação do código estrutural do componente 34 4.6. Deslocador 35 A especificação 35 Código estrutural do componente 35 Testbench do código estrutural do componente 39 Simulação do código estrutural do componente 39 4.7. Lógica de micro sequenciamento 40 A especificação 40 Código estrutural do componente 41 Testbench do código estrutural do componente 42 Simulação do código estrutural do componente 42 4.8. Memória de controle 43 A especificação 43 Código estrutural do componente 43 Testbench do código estrutural do componente 46 4.9. Flip-Flop D 48 A especificação 48 Código estrutural do componente 48 Testbench do código estrutural do componente 49 4.10. Registradores Local 50 A especificação 50 Código estrutural do componente 50 Testbench do código estrutural do componente 50 4.11. Latch 51 A especificação 51 Código algorítmica do componente 52 Testbench do código algorítmica do componente 52 4.12. MBR 53 A especificação 53 Código estrutural do componente 53 Testbench do código estrutural do componente 54 4.13. MAR 55 A especificação 55 Código estrutural do componente 55 Testbench do código estrutural do componente 56 4.14. MIR 57 A especificação 57 Código estrutural do componente 57 Testbench do código estrutural do componente 58 4.15. GSC 58 Código estrutural do componente 59 4.16. Somador 60 Código estrutural do componente 60 Testbench do código estrutural do componente 61 4.17. Incrementador 62 Código estrutural do componente 62 Testbench do código estrutural do componente 62 4.18. TriState 63 Código estrutural do componente 63 Testbench do código estrutural do componente 64 4.19. Memoria principal 64 Código estrutural do componente 64 4.20. MPC 66 Código estrutural do componente 66 4.21. AMUX 66 Código estrutural do componente 66 4.22. Processador 67 Código estrutural do componente 67 Testbench do código estrutural do componente 67 Simulação do código estrutural do componente 67 4.23. Componentes And, or e Nor 67 3. Observações 68 4. Conclusão 71 5. Referências 72 Introdução Este trabalho visa consolidar os conhecimentos adquiridos em sala de aula sobre a microarquitetura. A proposta é modelar uma das micro-arquiteturas discutidas (horizontal ou vertical) do Tanenbaum, utilizando a linguagem de descrição de hardware VHDL. A validação do modelo será feita através de simulação, utilizando o simulador MODELSIM. Descrição do modelo Neste capitulo será falado à especificação de cada componente, em VHDL, a descrição dos testes realizados e a imagem das janelas de simulação correspondentes que foram realizadas no ModelSim. Todos os componentes lógicos utilizados no projeto como portas And, Or ou Not foram colocadas em um arquivo separado denominado “Componentes”. A figura abaixo mostra o modelo horizontal dessa arquitetura, sobre o qual foi utilizado como referência para este projeto. Como pode ser observado nesta arquitetura é composta dos seguintes componentes: ALU; Registradores; Latch A; Latch B; Registrador MBR; Registrador MAR; Multiplexador; GSC; MPC; INC; MC; MIR; LMS; Dec A; Dec B; Dec C; AMUX; Deslocador; Os componentes Multiplexadores No nível de lógica digital, um multiplexador é um circuito que tem 2n entradas de dados, uma saída de dados e n entradas de controle que são responsáveis por selecionar uma das entradas de dados. A entrada de dados seleciona será “conectada” à saída. Ou seja, o valor que estiver na entrada selecionada irá para a saída. Decodificadores O decodificador é um circuito que toma com entrada um número de n bits e o utiliza para selecionar (ou seja, colocar em 1) exatamente uma das 2n linhas de saída. Deslocador É um circuito MSI (Medium Scale Integration ) aritmético que desloca o valor da entrada para a esquerda ou para a direita, dependendo da linha de controle. Circuitos Latch Estes componentes são circuitos que guardam temporariamente valores lidos anteriormente dos registradores. Podem ser construídos com duas portas NOR. Relógio (Clock) O clock é um dispositivo que emite uma sequência periódica de pulsos. Estes pulsos definem os ciclos de máquina. Durante cada ciclo, ocorre uma atividade básica, tal como a execução de uma microinstrução. É bem útil a divisão do ciclo em subciclos, de modo que diferentes partes da microinstrução possam ser realizadas em uma ordem definida. Memória Principal Os processadores precisam ser capazes de ler e escrever dados na memória principal. Para ler da memória, a CPU coloca um endereço de memória no barramento de endereço e estabelece os sinais de controle apropriados, ativando RD (read). A memória coloca o conteúdo no barramento de dados. Alguns computadores apresentam a leitura/ escrita de forma síncrona. Em outros, a memória demora o tempo que for necessário, sinalizando a presença de dados usando uma linha de controle quando terminar. A escrita é feita da seguinte forma: a CPU coloca o dado a ser escrito no barramento de dados e o endereço a ser armazenado no barramento de endereços, e então ativa o WR (write) . Para acessar a memória, o microprograma deve manter os valores corretos nos barramentos de dados e endereços. Para isso usa-se dois registradores: MAR (Memory Address Register) e o MBR (Memory Buffer Register), que alimentam os barramentos de endereços e dados, respectivamente. Esses registradores ficam entre a CPU e o barramento do sistema. Memória de Controle Esta memória rápida especial é onde as microinstruções são mantidas. Em algumas máquina é somente para leitura. Em outra, para leitura e escrita Como qualquer outra memória, a memória de controle precisa de um MAR e um MBR. Para a memória de controle o MAR é chamado de MPC (Microprogram Counter), já que sua única função é apontar para a próxima microinstrução a ser executada. O MBR, neste caso, é chamado de MIR (Microinstruction Register), o registrador de microinstrução. A diferença entre a memória de controle e a memória principal é que a primeira guarda o microprogama, enquantoque a segunda guarda o programa na linguagem de máquina convencional. Barramento Tri-state Este tipo de barramento é um dispositivo capaz de se conectar e se desconectar eletricamente dos barramentos aos quais estão fisicamente ligados. Tais conexões podem ser feitas e desfeitas em nanossegundos. Cada linha pode ser 0,1 ou estar desconectada. Barramentos tri-state são comumente usados quando há muitos dispositivos ligados a um barramento. Registrador É um dispositivo capaz de armazenar informações. Conceitualmente, os registradores são o mesmo que memória principal, com a diferença de que os registradores estão fisicamente localizados dentro do próprio processador, de modo que eles podem ser lidos e escritos mais rapidamente do que palavras na memória principal, que usualmente estão em pastilhas isoladas. Um registrador pode ser caracterizado por um único número: quantos bits ele pode armazenar. A informação colocada num registrador permanece lá até que outra informação a substitua. O processo de ler a informação de um registrador não afeta o conteúdo do mesmo. Ou seja, quando o registrador é lido, uma cópia de seu conteúdo é feita e o original é deixado intacto no registrador. ALU A ALU (Arithmetic Logic Unit) faz operações de lógicas e aritméticas. Possui duas entradas e uma saída para dados, havendo outras entradas e saídas de controle. As entradas A e B são operadas de acordo com F0F1, que determinam qual operação a ALU deve realizar. Uma ALU pode também ter saídas de controle. Saídas típicas são linhas que estão em 1 quando a saída da ALU é negativa, e zero, quando existe um vai-1 do bit de mais alta ordem (overflow). Tais resultados são indicados pelos Flags N e Z. LMS A lógica de micro sequenciamento (LMS), é que determina à próxima microinstrução, durante T4, quando os valores N e Z se tornam válidos. Os componentes em VHDL Mux 2X1 As especificações Um multiplexador tem 2 entradas de 1 bit e uma saída da mesma largura da entrada e uma entrada de controle de 1 bit, que seleciona uma das entradas e a direciona para a saída. Controle Saída C=0 A C=1 B Código algorítmico do componente library ieee; use ieee.std_logic_1164.all; entity MUX2x1 is port (A, B, C: in bit; S: out bit); end MUX2x1; architecture algoritmica of MUX2x1 is begin process (A, B, C) begin if C='0' then S<=A; else S<=B; end if; end process; end algoritmica; Testebench código algorítmico do componente entity testbenchMUX2x1 is end testbenchMUX2x1; architecture teste of testbenchMUX2x1 is component MUX2x1 port (A, B, C: in bit; S: out bit); end component; signal sigA, sigB, sigC, sigS: bit; begin comp: MUX2x1 port map (sigA, SigB, sigC, sigS); process begin sigA <= '0','1' after 2 ns,'0' after 4 ns; sigB <= '1','0' after 3 ns,'1' after 5 ns; sigC <= '0','1' after 3 ns,'0' after 6 ns; wait; end process; end teste; A simulação do testbench do código algorítmico do componente Código comportamental do componente library ieee; use ieee.std_logic_1164.all; entity MUX2x1_fluxo is port (A, B, C: in bit; S: out bit); end MUX2x1_fluxo; architecture fluxo of MUX2x1_fluxo is begin S<=(B AND C) OR (A AND NOT(C)); end fluxo; Testebench do código comportamental do componente entity testbenchMUX2x1_fluxo is end testbenchMUX2x1_fluxo; architecture teste of testbenchMUX2x1_fluxo is component MUX2x1_fluxo port (A, B, C: in bit; S: out bit); end component; signal sigA, sigB, sigC, sigS: bit; begin comp: MUX2x1_fluxo port map (sigA, SigB, sigC, sigS); process begin sigA <= '0','1' after 2 ns,'0' after 4 ns; sigB <= '1','0' after 3 ns,'1' after 5 ns; sigC <= '0','1' after 3 ns,'0' after 6 ns; wait; end process; end teste; A simulação do código comportamental do componente Código estrutural do componente library ieee; use ieee.std_logic_1164.all; entity MUX2x1_estrutural is port (A,B,C:in std_logic; S:out std_logic); end MUX2x1_estrutural ; architecture estrutural of MUX2x1_estrutural is component AND2 port (E1,E2:in std_logic; S: out std_logic); end component; component INV port (E: in std_logic; S: out std_logic); end component; component OR2 port (E1,E2:in std_logic; S: out std_logic); end component; signal S1,S2,S3: std_logic; begin P1: AND2 port map (B,C,S1); P2: INV port map (C,S2); P3: AND2 port map (S2,A,S3); P4: OR2 port map (S1,S3,S); END estrutural; TestBench do código estrutural do componente library ieee; use ieee.std_logic_1164.all; entity testBenchMUX2x1_estrutural is end testBenchMUX2x1_estrutural; architecture teste_estrutural of testBenchMUX2x1_estrutural is component MUX2x1_estrutural port (A,B,C:in std_logic; S:out std_logic); end component; signal sigA,sigB,sigC,digS:std_logic; begin comp: MUX2x1_estrutural port map (sigA,sigB,sigC,digS); process begin sigA <= '0','1' after 2 ns, '0' after 4 ns; sigB <= '1','0' after 3 ns, '1' after 5 ns; sigC <= '0','1' after 3 ns, '0' after 6 ns; wait; end process; end teste_estrutural; A simulação código estrutural do componente Mux 16 bits As especificações Um multiplexador tem 2 entradas de 16 bit cada e uma saída da mesma largura da entrada e uma entrada de controle de 1 bit, que seleciona uma das entradas e a direciona para a saída. Código estrutural do componente library ieee; use ieee.std_logic_1164.all; entity mux2x1_16 is port (A,B:in std_logic_vector (15 downto 0); C: in std_logic; S:out std_logic_vector (15 downto 0)); end mux2x1_16; architecture estrutural of mux2x1_16 is component mux2x1 port (A,B,C: in std_logic; S:out std_logic); end component; begin M15:mux2x1 port map (A(15),B(15),C,S(15)); M14:mux2x1 port map (A(14),B(14),C,S(14)); M13:mux2x1 port map (A(13),B(13),C,S(13)); M12:mux2x1 port map (A(12),B(12),C,S(12)); M11:mux2x1 port map (A(11),B(11),C,S(11)); M10:mux2x1 port map (A(10),B(10),C,S(10)); M09:mux2x1 port map (A(9),B(9),C,S(9)); M08:mux2x1 port map (A(8),B(8),C,S(8)); M07:mux2x1 port map (A(7),B(7),C,S(7)); M06:mux2x1 port map (A(6),B(6),C,S(6)); M05:mux2x1 port map (A(5),B(5),C,S(5)); M04:mux2x1 port map (A(4),B(4),C,S(4)); M03:mux2x1 port map (A(3),B(3),C,S(3)); M02:mux2x1 port map (A(2),B(2),C,S(2)); M01:mux2x1 port map (A(1),B(1),C,S(1)); M00:mux2x1 port map (A(0),B(0),C,S(0)); end estrutural; Testbench do código estrutural do componente library ieee; use ieee.std_logic_1164.all; entity testbenchMUX2X1_16 is end testbenchMUX2X1_16; architecture teste of testbenchMUX2X1_16 is component MUX2X1_16 port (A,B:in std_logic_vector (15 downto 0);C: in std_logic; S:out std_logic_vector (15 downto 0)); end component; signal sigA,sigB,sigS:std_logic_vector (15 downto 0); signal sigC:std_logic; begin comp:MUX2X1_16 port map (sigA,sigB,sigC,sigS); process begin sigA<="0000000000000000","1111111111111111" after 2 ns,"0000000000000000" after 4 ns; sigB<="1111111111111111","0000000000000000" after 3 ns,"1111111111111111" after 5 ns; sigC<='0','1' after 3 ns,'0' after 6 ns; wait; end process; end teste; A simulação do código estrutural do componente Decodificador 4 X 16 Componente que recebe 4 entradas de 1 bit cada e possui uma saída de 16bits. A partir da analise combinatória das entradas é definida a saída, onde: Entrada Saida 0000 0000000000000001 0001 0000000000000010 0010 0000000000000100 0011 0000000000001000 0100 0000000000010000 0101 0000000000100000 0110 0000000001000000 0111 0000000010000000 1000 0000000100000000 1001 0000001000000000 1010 0000010000000000 1011 0000100000000000 1100 0001000000000000 1101 0010000000000000 1110 0100000000000000 1111 1000000000000000 Código algorítmico do componente library ieee; use ieee.std_logic_1164.all; entity Decodificador4x16 is port(entDec:in std_logic_vector(3 downto 0); enDec: in std_logic; sDec: out std_logic_vector(15 downto 0)); end Decodificador4x16; architecture ComportamentoDec of Decodificador4x16 is begin process (entDec,enDec) begin sDec <= "0000000000000000"; if (enDec = '1') then case entDec is when "0000" => sDec <= "0000000000000001"; when "0001" => sDec <= "0000000000000010"; when "0010" => sDec <= "0000000000000100"; when "0011" => sDec <= "0000000000001000"; when "0100" => sDec <= "0000000000010000"; when "0101" => sDec <= "0000000000100000"; when "0110" => sDec <= "0000000001000000"; when "0111" => sDec <= "0000000010000000"; when "1000" => sDec <= "0000000100000000"; when "1001" => sDec <= "0000001000000000"; when "1010" => sDec <= "0000010000000000"; when "1011" => sDec <= "0000100000000000"; when "1100" => sDec <= "0001000000000000"; when "1101" => sDec <= "0010000000000000"; when "1110" => sDec <= "0100000000000000"; when "1111" => sDec <= "1000000000000000"; when others => null; end case; end if; end process; end ComportamentoDec; Testbench do código algorítmico do componente library ieee; use ieee.std_logic_1164.all; entity testBenchDecodificador4x16 is end testBenchDecodificador4x16; architecture testDecodificador4x16 of testBenchDecodificador4x16 is component Decodificador4x16 port (entDec: in std_logic_vector(3 downto 0); enDec: in std_logic; sDec: out std_logic_vector(15 downto 0)); end component; signal entDec:std_logic_vector (3 downto 0); signal enDec:std_logic; signal sDec:std_logic_vector(15 downto 0); begin comp:Decodificador4x16 port map (entDec,enDec,sDec); process begin enDec <= '1'; entDec <= "0000","1111" after 2 ns,"0000" after 4 ns; wait; end process; end testDecodificador4x16; A simulação do código algorítmico do componente Código comportamental do componente library ieee; use ieee.std_logic_1164.all; entity Decodificador4x16_fluxo is port(entDec: in std_logic_vector(3 downto 0); enDec: in std_logic; sDec: out std_logic_vector(15 downto 0)); end Decodificador4x16_fluxo; architecture fluxoDec of Decodificador4x16_fluxo is begin --sDec <="0000000000000000"; --ENTRADAS ="0000" => SAIDA = "0000000000000001" sDec(0) <= (NOT(entDec(3)) AND NOT(entDec(2)) AND NOT(entDec(1)) AND NOT(entDec(0)) AND enDec); --ENTRADAS ="0001" => SAIDA = "0000000000000010" sDec(1) <= (NOT(entDec(3)) AND NOT(entDec(2)) AND NOT(entDec(1)) AND entDec(0) AND enDec); --ENTRADAS ="0010" => SAIDA = "0000000000000100" sDec(2) <= (NOT(entDec(3)) AND NOT(entDec(2)) AND entDec(1) AND NOT(entDec(0)) AND enDec); --ENTRADAS ="0011" => SAIDA = "0000000000001000" sDec(3) <= (NOT(entDec(3)) AND NOT(entDec(2)) AND entDec(1) AND entDec(0) AND enDec); --ENTRADAS ="0100" => SAIDA = "0000000000010000" sDec(4) <= (NOT(entDec(3)) AND entDec(2) AND NOT(entDec(1)) AND NOT(entDec(0)) AND enDec); --ENTRADAS ="0101" => SAIDA = "0000000000100000" sDec(5) <= (NOT(entDec(3)) AND entDec(2) AND NOT(entDec(1)) AND entDec(0) AND enDec); --ENTRADAS ="0110" => SAIDA = "0000000001000000" sDec(6) <= (NOT(entDec(3)) AND entDec(2) AND entDec(1) AND NOT(entDec(0)) AND enDec); --ENTRADAS ="0111" => SAIDA = "0000000010000000" sDec(7) <= (NOT(entDec(3)) AND entDec(2) AND entDec(1) AND entDec(0) AND enDec); --ENTRADAS ="1000" => SAIDA = "0000000100000000" sDec(8) <= (entDec(3) AND NOT(entDec(2)) AND NOT(entDec(1)) AND NOT(entDec(0)) AND enDec); --ENTRADAS ="1001" => SAIDA = "00000010000000000" sDec(9) <= (entDec(3) AND NOT(entDec(2)) AND NOT(entDec(1)) AND entDec(0) AND enDec); --ENTRADAS ="1010" => SAIDA = "00000100000000000" sDec(10) <= (entDec(3) AND NOT(entDec(2)) AND entDec(1) AND NOT(entDec(0)) AND enDec); --ENTRADAS ="1011" => SAIDA = "00001000000000000" sDec(11) <= (entDec(3) AND NOT(entDec(2)) AND entDec(1) AND entDec(0) AND enDec); --ENTRADAS ="1100" => SAIDA = "00010000000000000" sDec(12) <= (entDec(3) AND entDec(2) AND NOT(entDec(1)) AND NOT(entDec(0)) AND enDec); --ENTRADAS ="1101" => SAIDA = "00100000000000000" sDec(13) <= (entDec(3) AND entDec(2) AND NOT(entDec(1)) AND entDec(0) AND enDec); --ENTRADAS ="1110" => SAIDA = "01000000000000000" sDec(14) <= (entDec(3) AND entDec(2) AND entDec(1) AND NOT(entDec(0)) AND enDec); --ENTRADAS ="1111" => SAIDA = "10000000000000000" sDec(15) <= (entDec(3) AND entDec(2) AND entDec(1) AND entDec(0) AND enDec); end fluxoDec; Testbench do código comportamental do componente library ieee; use ieee.std_logic_1164.all; entity testBenchDecodificador4x16_fluxo is end testBenchDecodificador4x16_fluxo; architecture teste of testBenchDecodificador4x16_fluxo is component Decodificador4x16_fluxo port (entDec: in std_logic_vector(3 downto 0); enDec: in std_logic; sDec: out std_logic_vector(15 downto 0)); end component; signal sigEntDec: std_logic_vector (3 downto 0); signal sigEnDec: std_logic; signal signalSaidaDec: std_logic_vector (15 downto 0); begin comp: Decodificador4x16_fluxo port map (sigEntDec, sigEnDec, signalSaidaDec); process begin sigEnDec <= '0','1' after 2 ns,'0' after 34 ns; sigEntDec <= "0000","0001" after 4 ns,"0010" after 6 ns, "0011" after 8 ns, "0100" after 10 ns,"0101" after 12 ns,"0110" after 14 ns,"0111" after 16 ns,"1000" after 18 ns, "1001" after 20 ns,"1010" after 22 ns,"1011" after 24 ns,"1100" after 26 ns,"1101" after 28 ns, "1110" after 30 ns,"1111" after 32 ns; -- sigEntDec <= "0000","1111" after 4 ns; wait; end process; end teste; Simulação do código comportamental do componente Código estrutural do componente library ieee; use ieee.std_logic_1164.all; entity Decodificador4x16_estrutural is port(EntDec: in std_logic_vector(3 downto 0); enDec: in std_logic; sDec: out std_logic_vector(15 downto 0)); end Decodificador4x16_estrutural; architecture estrutural of Decodificador4x16_estrutural is component AND5 port (E4,E3,E2,E1,E5:in std_logic; S: out std_logic); end component; component INV port (E:in std_logic; S: out std_logic); end component; signal S1,S2,S3,S4: std_logic; begin P1: INV port map (EntDec(3),S1); P2: INV port map (EntDec(2),S2); P3: INV port map (EntDec(1),S3); P4: INV port map (EntDec(0),S4); --ENTRADAS ="0000" => SAIDA = "0000000000000001" P5: AND5 port map (S1,S2,S3,S4,enDec,sDec(0)); --ENTRADAS ="0001" P6: AND5 port map (S1,S2,S3,EntDec(0),enDec,sDec(1)); --ENTRADAS ="0010" P7: AND5 port map (S1,S2,EntDec(1),S4,enDec,sDec(2)); --ENTRADAS ="0011" P8: AND5 port map (S1,S2,EntDec(1),EntDec(0),enDec,sDec(3)); --ENTRADAS ="0100" P9: AND5 port map (S1,EntDec(2),S3,S4,enDec,sDec(4)); --ENTRADAS ="0101" P10: AND5 port map (S1,EntDec(2),S3,EntDec(0),enDec,sDec(5)); --ENTRADAS ="0110" P11: AND5 port map (S1,EntDec(2),EntDec(1),S4,enDec,sDec(6)); --ENTRADAS ="0111" P12: AND5 port map (S1,EntDec(2),EntDec(1),EntDec(0),enDec,sDec(7)); --ENTRADAS ="1000" P13: AND5 port map (EntDec(3),S2,S3,S4,enDec,sDec(8)); --ENTRADAS ="1001" P14: AND5 port map (EntDec(3),S2,S3,EntDec(0),enDec,sDec(9)); --ENTRADAS ="1010" P15: AND5 port map (EntDec(3),S2,EntDec(1),S4,enDec,sDec(10)); --ENTRADAS ="1011" P16: AND5 port map (EntDec(3),S2,EntDec(1),EntDec(0),enDec,sDec(11)); --ENTRADAS ="1100" P17: AND5 port map (EntDec(3),EntDec(2),S3,S4,enDec,sDec(12)); --ENTRADAS ="1101" P18: AND5 port map (EntDec(3),EntDec(2),S3,EntDec(0),enDec,sDec(13));--ENTRADAS ="1110" P19: AND5 port map (EntDec(3),EntDec(2),EntDec(1),S4,enDec,sDec(14)); --ENTRADAS ="1111" P20: AND5 port map (EntDec(3),EntDec(2),EntDec(1),EntDec(0),enDec,sDec(15)); END estrutural; Testbench do código estrutural do componente library ieee; use ieee.std_logic_1164.all; entity testBenchDecodificador4x16_estrutural is end testBenchDecodificador4x16_estrutural; architecture teste_estrutural of testBenchDecodificador4x16_estrutural is component Decodificador4x16_estrutural port (EntDec: in std_logic_vector(3 downto 0); enDec: in std_logic; sDec: out std_logic_vector(15 downto 0)); end component; signal sigEnt: std_logic_vector (3 downto 0); signal sigEna: std_logic; signal sigS: std_logic_vector (15 downto 0); begin comp: Decodificador4x16_estrutural port map (sigEnt,sigEna,sigS); process begin sigEna <='0', '1' after 3 ns; sigEnt <= "0000","1111" after 2 ns, "0000" after 4 ns, "0001" after 6 ns,"0010" after 8 ns, "0011" after 10 ns, "0100" after 12 ns, "0101" after 14 ns, "0110" after 16 ns, "0111" after 18 ns, "1000" after 20 ns, "1001" after 22 ns, "1010" after 24 ns, "1011" after 28 ns, "1100" after 30 ns, "1101" after 32 ns, "1110" after 34 ns, "1111" after 36 ns; wait; end process; end teste_estrutural; Simulação do código estrutural do componente ALU 1 bit A especificação Para que a ALU funcione perfeitamente na operação A xor B primeiramente devemos criar um componente de um bit e que tenha um Carry out e Carry in que será utilizada como sinais internos na ALU de 16 bits para que a soma dos componentes A e B seja feita corretamente. Código algorítmico do componente library ieee; use ieee.std_logic_1164.all; use ieee.std_logic_unsigned.all; entity ALU_Algoritmica_1bit is port(EntA,EntB,Cin:in std_logic; EntF: in std_logic_vector (1 downto 0); SaiS: out std_logic; Cout: out std_logic); end ALU_Algoritmica_1bit; architecture ALU_Algo_1bit of ALU_Algoritmica_1bit is begin process (EntA, EntB, Cin, EntF) begin --Caso seja a opcao 00 = A+B if EntF(1)='0' and EntF(0)='0' then if Cin = '0' then if EntA = '0' then if EntB = '0' then SaiS <= '0'; Cout <= '0'; else SaiS <= '1'; Cout <= '0'; end if; else if EntB = '0' then SaiS <= '1'; Cout <= '0'; else SaiS <= '0'; Cout <= '1'; end if; end if; else if EntA = '0' then if EntB = '0' then SaiS <= '1'; Cout <= '0'; else SaiS <= '0'; Cout <= '1'; end if; else if EntB = '0' then SaiS <= '0'; Cout <= '1'; else SaiS <= '1'; Cout <= '1'; end if; end if; end if; --Caso seja a opcao 01 = AB elsif EntF(1) = '0' and EntF(0) = '1' then if EntA='1' and EntB='1' then SaiS <= '1'; else SaiS <= '0'; end if; --Caso seja a opcao 10 = A elsif EntF(1) = '1' and EntF(0) = '0' then if EntA = '1' then SaiS <= '1'; else SaiS <= '0'; end if; --Caso seja a opcao 11 = NOT(A) else if EntA = '0' then SaiS <= '1'; else SaiS <= '0'; end if; end if; end process; end ALU_Algo_1bit; Testbench do código algorítmico do componente library ieee; use ieee.std_logic_1164.all; entity testbenchALU_1bit_algoritimica is end testbenchALU_1bit_algoritimica; architecture teste of testbenchALU_1bit_algoritimica is component ALU_Algoritmica_1bit port (EntA,EntB,Cin:in std_logic; EntF: in std_logic_vector (1 downto 0); SaiS: out std_logic; Cout: out std_logic); end component; signal sigA,sigB,sigCin,sigS, sigCout: std_logic; signal sigF: std_logic_vector(1 downto 0); begin comp: ALU_Algoritmica_1bit port map (sigA,sigB, sigCin, sigF, sigS, sigCout); process begin sigA<='0','1' after 2 ns,'0' after 12 ns, '1' after 14 ns; sigB<='0','1' after 4 ns, '0' after 12 ns, '1' after 16 ns; sigCin<='0','1' after 12 ns; sigF<="00","01" after 6 ns,"11" after 8 ns, "10" after 10 ns, "00" after 14 ns, "01" after 20 ns, "11" after 22 ns,"10" after 24 ns; wait; end process; end teste; A simulação do código algorítmico do componente ALU 16 bit A especificação Neste caso, a ALU recebe duas entradas de 16 bits e 1 entrada de 2 bits. Na montagem do código foi levado em conta a estrutura criada para a ALU de 1 bit. Código estrutural do componente library ieee; use ieee.std_logic_1164.all; entity ALU_16bits is port (EntA,EntB:in std_logic_vector (15 downto 0); EntF: in std_logic_vector (1 downto 0); saiS:out std_logic_vector (15 downto 0); SaiN,SaiZ: out std_logic); end ALU_16bits; architecture estrutural of ALU_16bits is component ALU_Algoritmica_1bit port (EntA,EntB:in std_logic; Cin: in std_logic; EntF: in std_logic_vector (1 downto 0); SaiS:out std_logic; Cout: out std_logic); end component; signal S1,S2,S3,S4,S5,S6,S7,S8,S9,S10,S11,S12,S13,S14,S15,S16: std_logic; signal Cout1,Cout2,Cout3,Cout4,Cout5,Cout6,Cout7,Cout8,Cout9,Cout10,Cout11,Cout12,Cout13,Cout14,Cout15,Cout16: std_logic; begin M00:ALU_Algoritmica_1bit port map (EntA(0),EntB(0),'0',EntF,S1,Cout1); M01:ALU_Algoritmica_1bit port map (EntA(1),EntB(1),Cout1,EntF,S2,Cout2); M02:ALU_Algoritmica_1bit port map (EntA(2),EntB(2),Cout2,EntF,S3,Cout3); M03:ALU_Algoritmica_1bit port map (EntA(3),EntB(3),Cout3,EntF,S4,Cout4); M04:ALU_Algoritmica_1bit port map (EntA(4),EntB(4),Cout4,EntF,S5,Cout5); M05:ALU_Algoritmica_1bit port map (EntA(5),EntB(5),Cout5,EntF,S6,Cout6); M06:ALU_Algoritmica_1bit port map (EntA(6),EntB(6),Cout6,EntF,S7,Cout7); M07:ALU_Algoritmica_1bit port map (EntA(7),EntB(7),Cout7,EntF,S8,Cout8); M08:ALU_Algoritmica_1bit port map (EntA(8),EntB(8),Cout8,EntF,S9,Cout9); M09:ALU_Algoritmica_1bit port map (EntA(9),EntB(9),Cout9,EntF,S10,Cout10); M10:ALU_Algoritmica_1bit port map (EntA(10),EntB(10),Cout10,EntF,S11,Cout11); M11:ALU_Algoritmica_1bit port map (EntA(11),EntB(11),Cout11,EntF,S12,Cout12); M12:ALU_Algoritmica_1bit port map (EntA(12),EntB(12),Cout12,EntF,S13,Cout13); M13:ALU_Algoritmica_1bit port map (EntA(13),EntB(13),Cout13,EntF,S14,Cout14); M14:ALU_Algoritmica_1bit port map (EntA(14),EntB(14),Cout14,EntF,S15,Cout15); M15:ALU_Algoritmica_1bit port map (EntA(15),EntB(15),Cout15,EntF,S16,Cout16); saiS(0) <= S1; saiS(1) <= S2; saiS(2) <= S3; saiS(3) <= S4; saiS(4) <= S5; saiS(5) <= S6; saiS(6) <= S7; saiS(7) <= S8; saiS(8) <= S9; saiS(9) <= S10; saiS(10) <= S11; saiS(11) <= S12; saiS(12) <= S13; saiS(13) <= S14; saiS(14) <= S15; saiS(15) <= S16; saiN <= S16; saiZ <= (not(((((((((((((((S16 or S15) or S14) or S13) or S12) or S11) or S10) or S9) or S8) or S7) or S6) or S5) or S4) or S3) or S2) or S1)); end estrutural; Testbench do código estrutural do componente library ieee; use ieee.std_logic_1164.all; entity testbenchALU_16 is end testbenchALU_16; architecture teste of testbenchALU_16 is component ALU_16bits port (EntA,EntB:in std_logic_vector (15 downto 0); EntF: in std_logic_vector (1 downto 0); saiS:out std_logic_vector (15 downto 0); SaiN,SaiZ: out std_logic); end component; signal sigA,sigB,sigS:std_logic_vector (15 downto 0); signal sigF:std_logic_vector (1 downto0); signal sigN,sigZ:std_logic; begin comp:ALU_16bits port map (sigA,sigB, sigF,sigS, sigN, sigZ); process begin sigA<="0000000000000000","0000000000000001" after 2 ns; sigB<="0000000000000001","0000000000000011" after 4 ns; sigF<="00","01" after 6 ns,"11" after 8 ns, "10" after 10 ns; wait; end process; end teste; A simulação do código estrutural do componente Deslocador A especificação A função do deslocador é de deslocar um bit a esquerda ou a direita inserindo zeros no lado oposto do deslocamento. Código estrutural do componente library ieee; use ieee.std_logic_1164.all; entity Deslocador_estrutural is port(EntA: in std_logic_vector(15 downto 0); EntF: in std_logic_vector(1 downto 0); SaiS: out std_logic_vector(15 downto 0)); end Deslocador_estrutural; architecture Deslocador_estrutural of Deslocador_estrutural is component AND2 port (E2,E1:in std_logic; S: out std_logic); end component; component INV port (E: in std_logic; S: out std_logic); end component; component OR2 port (E1,E2:in std_logic; S: out std_logic); end component; component AND3 port (E1,E2,E3:in std_logic; S: out std_logic); end component; component OR3 port (E1,E2,E3:in std_logic; S: out std_logic); end component; signal S1,S2,S3,S4,S5,S6,S7,S8: std_logic; signaL S10,S11,S12,S14,S15,S16: std_logic; signal S18,S19,S20,S22,S23,S24: std_logic; signal S26,S27,S28,S30,S31,s32: std_logic; signal S34,S35,S36,S38,S39,S40: std_logic; signal S42,S43,S44,S46,S47,S48: std_logic; signal S50,S51,S52,S54,S55,S56: std_logic; signal S58,S59,S60,S62,S63,S64: std_logic; signal S66,S67: std_logic; begin P1: INV port map (EntF(0), S1); P2: INV port map (EntF(1), S2); P3: AND2 port map (S1,EntF(1),S3); P4: AND2 port map (S2,EntF(0),S4); P5: OR2 port map (S3,S4,S5); P6:INV port map (S5, S6); --lOGICA DA SAIDA 0 P7: AND2 port map (S6,EntA(0),S7); P8: AND2 port map (S4,EntA(1),S8); P9: OR2 port map (S7,S8,SaiS(0)); --lOGICA DA SAIDA 1 P10: AND2 port map (S3,EntA(0),S10); P11: AND2 port map (S6,EntA(1),S11); P12: AND2 port map (S4,EntA(2),S12); P13: OR3 port map (S10,S11,S12,SaiS(1)); --lOGICA DA SAIDA 2 P14: AND2 port map (S3,EntA(1),S14); P15: AND2 port map (S6,EntA(2),S15); P16: AND2 port map (S4,EntA(3),S16); P17: OR3 port map (S14,S15,S16,SaiS(2)); --lOGICA DA SAIDA 3 P18: AND2 port map (S3,EntA(2),S18); P19: AND2 port map (S6,EntA(3),S19); P20: AND2 port map (S4,EntA(4),S20); P21: OR3 port map (S18,S19,S20,SaiS(3)); --lOGICA DA SAIDA 4 P22: AND2 port map (S3,EntA(3),S22); P23: AND2 port map (S6,EntA(4),S23); P24: AND2 port map (S4,EntA(5),S24); P25: OR3 port map (S22,S23,S24,SaiS(4)); --lOGICA DA SAIDA 5 P26: AND2 port map (S3,EntA(4),S26); P27: AND2 port map (S6,EntA(5),S27); P28: AND2 port map (S4,EntA(6),S28); P29: OR3 port map (S26,S27,S28,SaiS(5)); --lOGICA DA SAIDA 6 P30: AND2 port map (S3,EntA(5),S30); P31: AND2 port map (S6,EntA(6),S31); P32: AND2 port map (S4,EntA(7),S32); P33: OR3 port map (S30,S31,S32,SaiS(6)); --lOGICA DA SAIDA 7 P34: AND2 port map (S3,EntA(6),S34); P35: AND2 port map (S6,EntA(7),S35); P36: AND2 port map (S4,EntA(8),S36); P37: OR3 port map (S34,S35,S36,SaiS(7)); --lOGICA DA SAIDA 8 P38: AND2 port map (S3,EntA(7),S38); P39: AND2 port map (S6,EntA(8),S39); P40: AND2 port map (S4,EntA(9),S40); P41: OR3 port map (S38,S39,S40,SaiS(8)); --lOGICA DA SAIDA 9 P42: AND2 port map (S3,EntA(8),S42); P43: AND2 port map (S6,EntA(9),S43); P44: AND2 port map (S4,EntA(10),S44); P45: OR3 port map (S42,S43,S44,SaiS(9)); --lOGICA DA SAIDA 10 P46: AND2 port map (S3,EntA(9),S46); P47: AND2 port map (S6,EntA(10),S47); P48: AND2 port map (S4,EntA(11),S48); P49: OR3 port map (S46,S47,S48,SaiS(10)); --lOGICA DA SAIDA 11 P50: AND2 port map (S3,EntA(10),S50); P51: AND2 port map (S6,EntA(11),S51); P52: AND2 port map (S4,EntA(12),S52); P53: OR3 port map (S50,S51,S52,SaiS(11)); --lOGICA DA SAIDA 12 P54: AND2 port map (S3,EntA(11),S54); P55: AND2 port map (S6,EntA(12),S55); P56: AND2 port map (S4,EntA(13),S56); P57: OR3 port map (S54,S55,S56,SaiS(12)); --lOGICA DA SAIDA 13 P58: AND2 port map (S3,EntA(12),S58); P59: AND2 port map (S6,EntA(13),S59); P60: AND2 port map (S4,EntA(14),S60); P61: OR3 port map (S58,S59,S60,SaiS(13)); --lOGICA DA SAIDA 14 P62: AND2 port map (S3,EntA(13),S62); P63: AND2 port map (S6,EntA(14),S63); P64: AND2 port map (S4,EntA(15),S64); P65: OR3 port map (S62,S63,S64,SaiS(14)); --lOGICA DA SAIDA 15 P66: AND2 port map (S3,EntA(14),S66); P67: AND2 port map (S6,EntA(15),S67); P68: OR2 port map (S66,S67,SaiS(15)); end Deslocador_estrutural; Testbench do código estrutural do componente library ieee; use ieee.std_logic_1164.all; entity testBenchDeslocador_estrutural is end testBenchDeslocador_estrutural; architecture teste_estrutural of testBenchDeslocador_estrutural is component Deslocador_estrutural port (EntA: in std_logic_vector(15 downto 0); EntF: in std_logic_vector(1 downto 0); SaiS: out std_logic_vector(15 downto 0)); end component; signal sigEntA: std_logic_vector (15 downto 0); signal sigEntF: std_logic_vector(1 downto 0); signal sigSaiS: std_logic_vector (15 downto 0); begin comp: Deslocador_estrutural port map (sigEntA,sigEntF,sigSaiS); process begin sigEntA <= "1111111111111111","1111111111111110" after 14 ns; sigEntF <= "00", "01" after 4 ns,"11" after 8 ns,"10" after 12 ns, "00" after 16 ns,"01" after 20 ns,"11" after 24 ns,"10" after 28 ns; wait; end process; end teste_estrutural; Simulação do código estrutural do componente Lógica de micro sequenciamento A especificação A unidade de logica de micro sequenciamento tem três entradas que são de controle e uma saída que informa Mux o que deve ser feito. Código estrutural do componente library ieee; use ieee.std_logic_1164.all; entity Logica_microsequenciamento_estrutural is port(EntN,EntZ: in std_logic; EntCond: in std_logic_vector(1 downto 0); SaiS: out std_logic); end Logica_microsequenciamento_estrutural; architecture Logica_microsequenciamento_estrutural of Logica_microsequenciamento_estrutural is component AND2 port (E2,E1:in std_logic; S: out std_logic); end component; component OR3 port (E1,E2,E3:in std_logic; S: out std_logic); end component; signal S1,S2,S3: std_logic; begin P1: AND2 port map (EntN,EntCond(0),S1); P2: AND2 port map (EntZ,EntCond(1),S2); P3: AND2 port map (EntCond(0),EntCond(1),S3); P4: OR3 port map (S1,S2,S3,SaiS); end Logica_microsequenciamento_estrutural; Testbench do código estrutural do componente library ieee; use ieee.std_logic_1164.all; entity testBenchLogica_microsequenciamento_estrutural is end testBenchLogica_microsequenciamento_estrutural; architecture teste_estrutural of testBenchLogica_microsequenciamento_estrutural is component Logica_microsequenciamento_estrutural port (EntN,EntZ: in std_logic; EntCond: in std_logic_vector(1 downto 0); SaiS: out std_logic); end component; signal sigEntN,sigEntZ,sigSaiS: std_logic; signal sigEntCond: std_logic_vector(1 downto 0); begin comp: Logica_microsequenciamento_estrutural port map (sigEntN,sigEntZ,sigEntCond,sigSaiS); process begin sigEntN <= '0','1' after 2ns, '0' after 6 ns,'1' after 12ns, '0' after 16 ns, '1' after 22ns, '0' after 26 ns,'1' after 32ns, '0' after 36 ns; sigEntZ <= '0','1' after 4ns, '0' after 8 ns,'1' after 14ns, '0' after 18 ns, '1' after 24ns, '0' after 28 ns,'1' after 34ns, '0' after 38 ns; sigEntCond <= "00", "01" after 10ns , "10" after 20 ns,"11" after 30 ns;wait; end process; end teste_estrutural; Simulação do código estrutural do componente Memória de controle A especificação Contém uma entrada de 8 bits e uma saída de 32 bits. Na memória de controle se encontra todas as microinstruções guardadas. Código estrutural do componente library ieee; use ieee.std_logic_1164.all; use ieee.numeric_bit.all; entity Memoria_Controle is port(Address: in unsigned (7 downto 0); Dado: out std_logic_vector (31 downto 0)); end Memoria_Controle; architecture algoritmica of Memoria_Controle is type TP_Memoria is array (0 to 73) of std_logic_vector (31 downto 0); constant Memoria: TP_Memoria := ("00000000110000000000000000000000", -- 0 "00000000010100000110000000000000", -- 1 "10001000000110101000000000000000", -- 2 "10110000000100110000000000011101", -- 3 "00010100000101000000001100000000", -- 4 "00110100000101000000010000010100", -- 5 "00110100000101000000010000001110", -- 6 "00110000000101000000010000001011", -- 7 "00000000110000001010000000000000", -- 8 "00000000010000000000000000000000", -- 9 "11110000000100010000000000000000", -- 10 "00010001100000001010000100000000", -- 11 "00000000001000000000000000000000", -- 12 "01100000001000000000000000000000", -- 13 "00000000110000001010000000000000", -- 14 "00110000010101000000010000010001", -- 15 "11100000000100010001000000000000", -- 16 "10011000000110100000000000000000", -- 17 "00000000000110101010011000000000", -- 18 "01100000000100010001101000000000", -- 19 "00110100000101000000010000011010", -- 20 "00110000000101000000010000011000", -- 21 "00110000000100010000000100000000", -- 22 "01100000000000000000000000011011", -- 23 "01010000000100010000000100011011", -- 24 "01100000000000000000000000000000", -- 25 "00110000000101000000010000011100", -- 26 "01110000000100000000101000000000", -- 27 "01110000000100010000101000000000", -- 28 "00110100000101000000010000011111", -- 29 "01100000000110101010001000000110", -- 30 "00110100000101000000010000100101", -- 31 "00110000000101000000010000100011", -- 32 "00110000000100010000000100011011", -- 33 "01100000000000000000000000000000", -- 34 "01010000000100010000000100000000", -- 35 "01100000000000000000000000011011", -- 36 "00110100000101000000010000101010", -- 37 "00000000000100100111001000000000", -- 38 "00010001100000000010000000000000", -- 39 "00010000001100000000101000000000", -- 40 "01100000001000000000000000000000", -- 41 "00110100000101000000010000111101", -- 42 "00110100000101000000010000110101", -- 43 "00110000000101000000010000110001", -- 44 "00000000110000000001000000000000", -- 45 "00000000010100100010011100000000", -- 46 "00000000101000000010000000000000", -- 47 "01100000001000000000000000000000", -- 48 "00000000110000000010000000000000", -- 49 "00000000010100100010011000000000", -- 50 "00000000101000000001000000000000", -- 51 "01100000001000000000000000000000", -- 52 "00110000000101000000010000111010", -- 53 "00000000000100100010011100000000", -- 54 "00010001100000000010000100000000", -- 55 "00000000001000000000000000000000", -- 56 "01100000001000000000000000000000", -- 57 "00000000110000000010000000000000", -- 58 "00000000010100100010011000000000", -- 59 "11110000000100010000000000000000", -- 60 "00110100000101000000010001000101", -- 61 "00110000000101000000010001000010", -- 62 "00000000110000000010000000000000", -- 63 "00000000010100100010011000000000", -- 64 "11110000000100000000000000000000", -- 65 "00010000000110100000000100000000", -- 66 "00010000000100010000001000000000", -- 67 "00010000000100100000101000000000", -- 68 "00000000000110100011100100000000", -- 69 "00110000000101000000010001001000", -- 70 "01100000000100100010101000000000", -- 71 "00011000000110100000101000000000", -- 72 "01100000000110101010011001000111"); -- 73 begin process (Address) begin Dado <= Memoria(to_integer(Address)); end process; end algoritmica; Testbench do código estrutural do componente library ieee; use ieee.std_logic_1164.all; use ieee.numeric_bit.all; entity TestBench_MC is end TestBench_MC; architecture test of TestBench_MC is component Memoria_Controle port(Address: in unsigned (7 downto 0); Dado: out std_logic_vector (31 downto 0)); end component; signal SigAdd: unsigned(7 downto 0); signal SigDado: std_logic_vector(31 downto 0); begin MC: Memoria_Controle port map (SigAdd, SigDado); process begin SigAdd <="00000000", "00000001" after 1 ns, "00000010" after 2 ns, "00000011" after 3 ns, "00000100" after 4 ns, "00000101" after 5 ns, "00000110" after 6 ns, "00000111" after 7 ns, "00001000" after 8 ns, "00001001" after 9 ns, "00001010" after 10 ns, "00001011" after 11 ns, "00001100" after 12 ns, "00001101" after 13 ns, "00001110" after 14 ns, "00001111" after 15 ns, "00010000" after 16 ns, "00010001" after 17 ns, "00010010"after 18 ns, "00010011" after 19 ns, "00010100" after 20 ns, "00010101" after 21 ns, "00010110" after 22 ns, "00010111" after 23 ns, "00011000" after 24 ns, "00011001" after 25 ns, "00011010" after 26 ns, "00011011" after 27 ns, "00011100" after 28 ns, "00011101" after 29 ns, "00011110" after 30 ns, "00011111" after 31 ns, "00100000" after 32 ns, "00100001" after 33 ns, "00100010" after 34 ns, "00100011" after 35 ns, "00100100" after 36 ns, "00100101" after 37 ns, "00100110" after 38 ns, "00100111" after 39 ns, "00101000" after 40 ns, "00101001" after 41 ns, "00101010" after 42 ns, "00101011" after 43 ns, "00101100" after 44 ns, "00101101" after 45 ns, "00101110" after 46 ns, "00101111" after 47 ns, "00110000" after 48 ns, "00110001" after 49 ns, "00110010" after 50 ns, "00110011" after 51 ns, "00110100" after 52 ns, "00110101" after 53 ns, "00110110" after 54 ns, "00110111" after 55 ns, "00111000" after 56 ns, "00111001" after 57 ns, "00111010" after 58 ns, "00111011" after 59 ns, "00111100" after 60 ns, "00111101" after 61 ns, "00111110" after 62 ns, "00111111" after 63 ns, "01000000" after 64 ns, "01000001" after 65 ns, "01000010" after 66 ns, "01000011" after 67 ns, "01000100" after 68 ns, "01000101" after 69 ns, "01000110" after 70 ns, "01000111" after 71 ns, "01001000" after 72 ns, "01001001" after 73 ns; wait; end process; end test; Flip-Flop D A especificação O flip-flop ou multivibrador biestável é um circuito digital pulsado capaz de servir como uma memória de um bit. Código estrutural do componente library ieee; use ieee.std_logic_1164.all; entity ffD is port(RST,CLK:in bit; D: in std_logic; Q,NQ: out std_logic); end ffD; architecture algoritmica of ffD is begin process (RST,D,CLK) begin if ( RST = '1' ) then Q<= '0'; NQ <= '1'; elsif ( CLK = '1' and CLK'event ) then Q <= D; NQ <= not D; end if; end process; end algoritmica; Testbench do código estrutural do componente library ieee; use ieee.std_logic_1164.all; entity teste_ffD is end teste_ffD; architecture teste of teste_ffD is component ffD port(RST,CLK:in bit; D: in std_logic; Q,NQ: out std_logic); end component; signal sigRST, sigCLK: bit; signal sigD,sigQ,sigNQ :std_logic ; begin comp:ffD port map (sigRST, sigCLK, sigD,sigQ,sigNQ); process begin sigCLK <='0', not (sigCLK) after 3 ns; sigD<='0','1' after 2 ns; wait for 6 ns; end process; end teste; Registradores Local A especificação Um registrador é um grupo de flip-flops dispostos em conjunto, capazes de armazenar, cada um, 1 bit de informação. Um registrador de n bits possui um grupo de n flip-flops e é capaz de armazenar qualquer informação binária de até n bits Código estrutural do componente library ieee; use ieee.std_logic_1164.all; entity ffD16 is port(RST,CLK:in bit; D: in std_logic_vector(15 downto 0); Q,NQ: out std_logic_vector(15 downto 0)); end ffD16; architecture estru_ffD16 of ffD16 is component ffD port(RST,CLK:in bit; D: in std_logic; Q,NQ: out std_logic); end component; begin GEN:for I in 15 downto 0 generate ff : ffD port map (RST, CLK, D(I), Q(I),NQ(I)); end generate ; end estru_ffD16; Testbench do código estrutural do componente library ieee; use ieee.std_logic_1164.all; entity teste_ffD16 is end teste_ffD16; architecture teste of teste_ffD16 is component ffD16 port(RST,CLK:in bit; D: in std_logic_vector(15 downto 0); Q,NQ: out std_logic_vector(15 downto 0)); end component; signal sigRST, sigCLK: bit; signal sigD,sigQ,sigNQ :std_logic_vector(15 downto 0) ; begin comp:ffD16 port map (sigRST, sigCLK, sigD,sigQ,sigNQ); process begin sigCLK <='0', not (sigCLK) after 3 ns; wait for 5 ns; end process; process begin sigD<="1011100010111001","0100001000001000" after 2 ns,"0000001000010001" after 10 ns; sigRST<='0', '1' after 4 ns; wait ; end process; end teste; Latch A especificação Latch é um circuito sequencial biestável assíncrono,[7] ou seja, é um circuito constituído por portas lógicas, capaz de armazenar um bit de informação,[8] onde as saídas de certo instante dependem dos valores de entrada do instante mais os valores anteriores de saída, isto é, do seu estado atual, e onde as saídas mudam a qualquer instante de tempo, podendo ter ou não variáveis de controle. Código algorítmica do componente library ieee; use ieee.std_logic_1164.all; entity Latch is port( D: in std_logic_vector(15 downto 0); CK: in std_logic; Q: out std_logic_vector(15 downto 0) ); end Latch; architecture algoritmica of Latch is begin process (D,CK) begin if CK ='1' and CK'event then Q<=D; end if; end process; end algoritmica; Testbench do código algorítmica do componente library ieee; use ieee.std_logic_1164.all; entity testbench_latch is end testbench_latch; architecture testbench of testbench_latch is component Latch is generic (tam: integer); port (en: in std_logic_vector (tam - 1 downto 0); comando: in std_logic; saida: out std_logic_vector (tam - 1 downto 0)); end component; signal a, b: std_logic_vector (7 downto 0); signal comando: std_logic; begin Latcha: Latch generic map (8) port map (a,comando,b); process begin a <= "00110011", "00001111" after 10 ns, "10101010" after 20 ns; comando <= '0', '1' after 5 ns, '0' after 15 ns, '1' after 30 ns; wait; end process; end testbench; MBR A especificação MBR (Memory Buffer Register) tem a função de guardar os valores corretos no barramento de dados por várias microinstruções. Se WR é ativado libera-se o valor guardado no barramento e se RD é ativado carrega-se a informação no MBR. Código estrutural do componente library ieee ; use ieee.std_logic_1164.all; entity MBR is port(barramento: inout std_logic_vector(15 downto 0); toCPU: out std_logic_vector(15 downto 0); fromCPU: in std_logic_vector(15 downto 0); clock,rd,wr,controle : in bit); end MBR; architecture algoritmica of MBR is begin process(controle, clock, rd,wr) begin if (clock='1' and clock'event) then if (controle = '1' ) then if ( wr ='1') then barramento <= fromCPU; else barramento<="ZZZZZZZZZZZZZZZZ"; end if; elsif (rd = '1') then toCPU <= barramento; end if; end if; end process; end algoritmica; Testbench do código estrutural do componente library ieee; use ieee.std_logic_1164.all; entity teste_MBR is end teste_MBR; architecture testbench of teste_MBR is component MBR is port(barramento: inout std_logic_vector(15 downto 0); toCPU: out std_logic_vector(15 downto 0); fromCPU: in std_logic_vector(15 downto 0); clock ,rd,wr,controle: in bit); end component; signal sigClk,sigRD,sigCTRL,sigWR: bit; signal sigBarramento,sigtoCPU,sigfromCPU: std_logic_vector (15 downto 0); begin comp: MBR port map (sigBarramento,sigtoCPU,sigfromCPU,sigCLK,sigRD,sigWR,sigCTRL); process begin sigClk <= not (sigClk) after 1 ns; wait for 2 ns; end process; process begin sigCTRL <= '1','0' after 6 ns; sigRD <= '0','1'after 5 ns,'0' after 10 ns; sigWR <= '1','0' after 6 ns; sigfromCPU <= "1010101010101010","1111111111111111" after 5 ns; wait; end process; end testbench; MAR A especificação MAR (Memory Address Register) tem a função de guardar os valores corretos no barramento de endereço por várias microinstruções. É carregado quando a linha de controle é ativada e sua saída para as linhas de endereço está sempre habilitada. Código estrutural do componente library ieee; use ieee.std_logic_1164.all ; entity MAR is port (Entrada : in std_logic_vector(15 downto 0); CLK,Flag:in bit; Saida: out std_logic_vector(15 downto 0) ); end MAR; architecture algo_MAR of MAR is begin process (CLK,Flag) begin if (Flag = '1' and CLK = '1' and CLK'event) then Saida <= Entrada; end if; end process; end algo_MAR; Testbench do código estrutural do componente library ieee ; use ieee.std_logic_1164.all ; entity teste_mar is end teste_mar; architecture teste of teste_mar is component MAR port(Entrada : in std_logic_vector(15 downto 0); CLK,Flag:in bit; Saida: out std_logic_vector(15 downto 0) ); end component; signal sigIN, sigOUT: std_logic_vector(15 downto 0); signal sigCLK, sigF: bit; begin comp: MAR port map (sigIN,sigCLK,sigF,sigOUT); process begin sigCLK <= not(sigClk) after 1 ns; wait for 2 ns; end process; process begin sigF <= '1', '0' after 3 ns, '1' after 5 ns ; sigIN <= "1010001010001011","0001000100001101" after 3 ns ,"0000001111010111" after 6 ns ; wait; end process; end teste; MIR A especificação Te a função de guardar a próxima microinstrução a ser executada. Código estrutural do componente library ieee; use ieee.std_logic_1164.all; entity MIR is port(RST,CLK:in bit; D: in std_logic_vector(31 downto 0); Q,NQ: out std_logic_vector(31 downto 0)); end MIR; architecture estru_MIR of MIR is component ffD port(RST,CLK:in bit; D: in std_logic; Q,NQ: out std_logic); end component; begin GEN:for I in 31 downto 0 generate ff : ffD port map (RST, CLK, D(I), Q(I),NQ(I)); end generate ; end estru_MIR; Testbench do código estrutural do componente library ieee; use ieee.std_logic_1164.all; entity teste_MIR is end teste_MIR; architecture teste of teste_MIR is component MIR port(RST,CLK:in bit; D: in std_logic_vector(31 downto 0); Q,NQ: out std_logic_vector(31 downto 0)); end component; signal sigRST, sigCLK: bit; signal sigD,sigQ,sigNQ :std_logic_vector(31 downto 0) ; begin comp:MIR port map (sigRST, sigCLK, sigD,sigQ,sigNQ); process begin sigCLK <='0', not (sigCLK) after 1 ns; wait for 2 ns; end process; process begin sigD<="10111000101110011011100010111001","01000010000010000100001000001000" after 2 ns,"00000010000100010000001000010001" after 10 ns; sigRST<='0', '1' after 4 ns; wait ; end process; end teste; GSC Código estrutural do componente library ieee; use ieee.std_logic_1164.all; entity GSC is port(T1,T2,T3,T4: out std_logic); end GSC; architecture comportamental of GSC is signal clock: std_logic:='1'; signal sigT1: std_logic:='1'; signal sigT2: std_logic:='1'; signal sigT3: std_logic:='1'; signal sigT4: std_logic:='1'; begin process begin clock <= not clock after 5 ns; wait for 5 ns; end process; process(clock) begin if clock'event and clock='1' then sigT1<='1', '0' after 2.5 ns; end if; end process; process(sigT1) begin if sigT1'event and sigT1='0' then sigT2<='1', '0' after 2.5 ns; end if; end process; process(sigT2) begin if sigT2'event and sigT2='0' then sigT3<='1', '0' after 2.5 ns; end if; end process; process(sigT3) begin if sigT3'event and sigT3='0' then sigT4<='1', '0' after 2.5 ns; end if; end process; T1 <= sigT1; T2 <= sigT2; T3 <= sigT3; T4 <= sigT4; end comportamental; Somador Código estrutural do componente library ieee; use ieee.std_logic_1164.all; entity somador is port (A, B, vem1: in std_logic; resultado, vai1: out std_logic); end somador; architecture fluxo of somador is signal somando: std_logic_vector (8 downto 0); begin somando(0) <= a xor b; somando(1) <= vem1 xor somando(0); somando(2) <= a and b; somando(3) <= vem1 and somando(0); vai1 <= somando(2) or somando(3); resultado <= somando(1); end fluxo; Testbench do código estrutural do componente library ieee; use ieee.std_logic_1164.all; entity testbench_somador is end testbench_somador; architecture testbench of testbench_somador is component somador is port (A, B, vem1: in std_logic; resultado, vai1: out std_logic); end component; signal sigA,sigB,sigVem1,sigResultado,sigVai1: std_logic; begin somador1: somador port map(sigA,sigB,sigVem1,sigResultado,sigVai1); process begin sigA <= '0', '1' after 10 ns, '0' after 20 ns; sigB <= '1', '0' after 5 ns, '0' after 20 ns; sigVem1 <= '0', '1' after 10 ns, '0' after 15 ns; wait; end process; end testbench; Incrementador Código estrutural do componente library ieee; use ieee.std_logic_1164.all; entity incrementadorGen is generic (tam: integer); port (A: in std_logic_vector (tam - 1 downto 0); resultado: out std_logic_vector(tam - 1 downto 0)); end incrementadorGen; architecture estrutura of incrementadorGen is component somador is port (A, B, vem1: in std_logic; resultado, vai1: out std_logic); end component; signal result: std_logic_vector (tam - 1 downto 0); signal b: std_logic_vector (31 downto 0); signal vem1: std_logic_vector (tam + 1 downto 0); begin b <= "00000000000000000000000000000000"; vem1(0)<='1'; som: for i in tam - 1 downto 0 generate somn: somador port map (a(i),b(i),vem1(i),result(i),vem1(i+1)); end generate; resultado <= result; end estrutura; Testbench do código estrutural do componente library ieee; use ieee.std_logic_1164.all; entity testbench_incrementadorGen is end testbench_incrementadorGen; architecture testbench of testbench_incrementadorGen is component incrementadorGen is generic (tam: integer); port (A: in std_logic_vector (tam - 1 downto 0); resultado: out std_logic_vector(tam - 1 downto 0)); end component; signal sigA,sigResultado: std_logic_vector (3 downto 0); begin incrementadorX: incrementadorGen generic map (4) port map (sigA,sigResultado); process begin sigA<= "0000", "0001" after 5 ns, "0010" after 10 ns, "1111" after 20 ns; wait; end process; end testbench; TriState Código estrutural do componente library ieee; use ieee.std_logic_1164.all; -- Tristate 16 bits entity tristate is port ( entrada: in std_logic_vector (15 downto 0); oe: in std_logic; saida: out std_logic_vector (15 downto 0)); end tristate ; architecture estrutura of tristate is signal entrada_tri, saida_tri: std_logic_vector (15 downto 0); begin saida <= entrada when oe = '1' else "ZZZZZZZZZZZZZZZZ"; end estrutura; Testbench do código estrutural do componente library ieee; use ieee.std_logic_1164.all; entity testbench_tristate is end testbench_tristate; architecture teste of testbench_tristate is component tristate is port ( entrada: in std_logic_vector (15 downto 0); oe: in std_logic; saida: out std_logic_vector (15 downto 0)); end component; signal ent, sai: std_logic_vector (15 downto 0); signal sinal:std_logic; begin a1: tristate port map (ent,sinal,sai); process begin ent <="1010101010101010", "1111111111111111" after 12 ns; sinal <= '0', '1' after 5 ns, '0' after 13 ns, '1' after 20 ns; wait; end process; end teste; Memoria principal Código estrutural do componente libraryieee; use ieee.std_logic_1164.all; use ieee.std_logic_unsigned.all; entity memoriaPrincipal is generic(tamEnd: natural :=16; tamPal: natural :=16); port( endereco: in std_logic_vector(tamEnd-1 downto 0); dado: inout std_logic_vector(tamPal-1 downto 0); rd : in std_logic; wr : in std_logic ); end memoriaPrincipal; architecture comportamental of memoriaPrincipal is constant memTamanho : integer := 512; type vetorMemoria is array(0 to memTamanho-1) of std_logic_vector(tamEnd-1 downto 0); signal dadosNaMemoria : vetorMemoria := ( "0000000000001001", -- x00 "0001000000000100", -- x01 "0010000000001000", -- x02 "0011000000000111", -- x03 others=>(others=>'0') ); signal saida_tmp: std_logic_vector(tamPal-1 downto 0); begin process(endereco,dado,rd,wr) begin if (rd='1') then saida_tmp <= dadosNaMemoria(conv_integer(endereco)); end if; if (wr='1') then dadosNaMemoria(conv_integer(endereco)) <= dado; saida_tmp <= (saida_tmp'range => 'X'); end if; end process; dado <= saida_tmp; end comportamental; MPC Código estrutural do componente library ieee; use ieee.std_logic_1164.all; entity Mpc is port(entrada: in bit_vector(7 downto 0); clock: in bit; saidaInc: out bit_vector(7 downto 0); saidaMC: out bit_vector(7 downto 0)); end Mpc; architecture algoritmica of Mpc is begin process(entrada, clock) begin if clock = '1' and clock'event then saidaInc <= entrada; saidaMC <= entrada; end if; end process; end algoritmica; AMUX Código estrutural do componente library ieee; use ieee.std_logic_1164.all; entity Amux is port(entradaMBR: in std_logic_vector(15 downto 0); -- 16 bits vindos do MBR entradaLa: in std_logic_vector(15 downto 0); -- 16 bits vindos do Latch A op: in std_logic;--1 bit vindos MIR saidaAMUX: out std_logic_vector(15 downto 0));--16 bits de saida end Amux; architecture algoritmica of Amux is begin process (entradaMBR,entradaLa,op) begin if op = '0' then saidaAMUX <= entradaLa; else saidaAMUX <= entradaMBR; end if; end process; end algoritmica; MemoriaT3 Código estrutural do componente library ieee; use ieee.std_logic_1164.all; entity memoriaT3 is port (signal bc, csa, csb, csc: in std_logic_vector(15 downto 0); signal sclock4: in std_logic; signal ba, bb: out std_logic_vector(15 downto 0)); end memoriaT3; architecture estrutura of memoriaT3 is component tristate is port ( entrada: in std_logic_vector (15 downto 0); oe: in std_logic; saida: out std_logic_vector (15 downto 0)); end component ; component registrador is generic (nbits: integer); port ( dado: in std_logic_vector (nbits - 1 downto 0); clk: in std_logic; saida: out std_logic_vector (nbits - 1 downto 0)); end component; signal barramentoA, barramentoB, clk_reg: std_logic_vector (15 downto 0); signal comando, rd: std_logic; signal saida0, saida1, saida2, saida3, saida4, saida5, saida6, saida7, saida8, saida9, saida10, saida11, saida12, saida13, saida14, saida15: std_logic_vector (15 downto 0); signal s_0:std_logic_vector(15 downto 0):=x"0000"; signal s_1:std_logic_vector(15 downto 0):=x"0001"; signal s_11:std_logic_vector(15 downto 0):=x"FFFF"; signal s_amask:std_logic_vector(15 downto 0):=x"03FF"; signal s_smask:std_logic_vector(15 downto 0):=x"00FF"; begin clkreg: for i in 0 to 15 generate clk_reg (i) <= csc(i) and sclock4; end generate; PC: registrador generic map (16) port map (bc,clk_reg(0),saida0); tripca: tristate port map (saida0,csa(0),barramentoA); tripcb: tristate port map (saida0,csb(0),barramentoB); AC: registrador generic map (16) port map (bc,clk_reg(1),saida1); triaca: tristate port map (saida1,csa(1),barramentoA); triacb: tristate port map (saida1,csb(1),barramentoB); SP: registrador generic map (16) port map (bc,clk_reg(2),saida2); trispa: tristate port map (saida2,csa(2),barramentoA); trispb: tristate port map (saida2,csb(2),barramentoB); IR: registrador generic map (16) port map (bc,clk_reg(3),saida3); triIRa: tristate port map (saida3,csa(3),barramentoA); triirb: tristate port map (saida3,csb(3),barramentoB); TIR: registrador generic map (16) port map (bc,clk_reg(4),saida4); tritIRa: tristate port map (saida4,csa(4),barramentoA); tritirb: tristate port map (saida4,csb(4),barramentoB); REG0: registrador generic map (16) port map (s_0,sclock4,saida5); tri0a: tristate port map (saida5,csa(5),barramentoA); tri0b: tristate port map (saida5,csb(5),barramentoB); REGM1: registrador generic map (16) port map (s_1,sclock4,saida6); triM1a: tristate port map (saida6,csa(6),barramentoA); triM1b: tristate port map (saida6,csb(6),barramentoB); REGm11: registrador generic map (16) port map (s_11,sclock4,saida7); trim11a: tristate port map (saida7,csa(7),barramentoA); trim11b: tristate port map (saida7,csb(7),barramentoB); AMASK: registrador generic map (16) port map (s_amask,sclock4,saida8); triAMASKa: tristate port map (saida8,csa(8),barramentoA); triAMASKb: tristate port map (saida8,csb(8),barramentoB); SMASK: registrador generic map (16) port map (s_smask,sclock4,saida9); triSMASKa: tristate port map (saida9,csa(9),barramentoA); triSMASKb: tristate port map (saida9,csb(9),barramentoB); A: registrador generic map (16) port map (bc,clk_reg(10),saida10); triAa: tristate port map (saida10,csa(10),barramentoA); triAb: tristate port map (saida10,csb(10),barramentoB); B: registrador generic map (16) port map (bc,clk_reg(11),saida11); triBa: tristate port map (saida11,csa(11),barramentoA); triBb: tristate port map (saida11,csb(11),barramentoB); C: registrador generic map (16) port map (bc,clk_reg(12),saida12); triCa: tristate port map (saida12,csa(12),barramentoA); triCb: tristate port map (saida12,csb(12),barramentoB); D: registrador generic map (16) port map (bc,clk_reg(13),saida13); triDa: tristate port map (saida13,csa(13),barramentoA); triDb: tristate port map (saida13,csb(13),barramentoB); E: registrador generic map (16) port map (bc,clk_reg(14),saida14); triEa: tristate port map (saida14,csa(14),barramentoA); triEb: tristate port map (saida14,csb(14),barramentoB); F: registrador generic map (16) port map (bc,clk_reg(15),saida15); triFa: tristate port map (saida15,csa(15),barramentoA); triFb: tristate port map (saida15,csb(15),barramentoB); ba <= barramentoA; bb <= barramentoB; end estrutura; Processador Código estrutural do componente library ieee; use ieee.std_logic_1164.all; entity memoriaT3 is port (signal bc, csa, csb, csc: in std_logic_vector(15 downto 0); signal sclock4: in std_logic; signal ba, bb: out std_logic_vector(15 downto 0)); end memoriaT3; architecture estrutura of memoriaT3 is component tristate is port ( entrada: in std_logic_vector (15 downto 0); oe: in std_logic; saida: out std_logic_vector (15 downto 0)); end component ; component registrador is generic (nbits: integer); port ( dado: in std_logic_vector (nbits - 1 downto 0); clk: in std_logic; saida: out std_logic_vector (nbits - 1 downto 0)); end component; signal barramentoA, barramentoB, clk_reg: std_logic_vector (15 downto 0); signal comando, rd: std_logic; signal saida0, saida1, saida2, saida3, saida4, saida5, saida6, saida7, saida8, saida9, saida10, saida11, saida12, saida13, saida14, saida15: std_logic_vector (15 downto 0); signal s_0:std_logic_vector(15 downto 0):=x"0000"; signal s_1:std_logic_vector(15 downto 0):=x"0001"; signal s_11:std_logic_vector(15 downto 0):=x"FFFF"; signal s_amask:std_logic_vector(15 downto 0):=x"03FF"; signal s_smask:std_logic_vector(15 downto 0):=x"00FF"; begin clkreg: for i in 0 to 15 generate clk_reg (i) <= csc(i) and sclock4; end generate; PC: registrador generic map (16) port map (bc,clk_reg(0),saida0); tripca: tristate port map (saida0,csa(0),barramentoA);tripcb: tristate port map (saida0,csb(0),barramentoB); AC: registrador generic map (16) port map (bc,clk_reg(1),saida1); triaca: tristate port map (saida1,csa(1),barramentoA); triacb: tristate port map (saida1,csb(1),barramentoB); SP: registrador generic map (16) port map (bc,clk_reg(2),saida2); trispa: tristate port map (saida2,csa(2),barramentoA); trispb: tristate port map (saida2,csb(2),barramentoB); IR: registrador generic map (16) port map (bc,clk_reg(3),saida3); triIRa: tristate port map (saida3,csa(3),barramentoA); triirb: tristate port map (saida3,csb(3),barramentoB); TIR: registrador generic map (16) port map (bc,clk_reg(4),saida4); tritIRa: tristate port map (saida4,csa(4),barramentoA); tritirb: tristate port map (saida4,csb(4),barramentoB); REG0: registrador generic map (16) port map (s_0,sclock4,saida5); tri0a: tristate port map (saida5,csa(5),barramentoA); tri0b: tristate port map (saida5,csb(5),barramentoB); REGM1: registrador generic map (16) port map (s_1,sclock4,saida6); triM1a: tristate port map (saida6,csa(6),barramentoA); triM1b: tristate port map (saida6,csb(6),barramentoB); REGm11: registrador generic map (16) port map (s_11,sclock4,saida7); trim11a: tristate port map (saida7,csa(7),barramentoA); trim11b: tristate port map (saida7,csb(7),barramentoB); AMASK: registrador generic map (16) port map (s_amask,sclock4,saida8); triAMASKa: tristate port map (saida8,csa(8),barramentoA); triAMASKb: tristate port map (saida8,csb(8),barramentoB); SMASK: registrador generic map (16) port map (s_smask,sclock4,saida9); triSMASKa: tristate port map (saida9,csa(9),barramentoA); triSMASKb: tristate port map (saida9,csb(9),barramentoB); A: registrador generic map (16) port map (bc,clk_reg(10),saida10); triAa: tristate port map (saida10,csa(10),barramentoA); triAb: tristate port map (saida10,csb(10),barramentoB); B: registrador generic map (16) port map (bc,clk_reg(11),saida11); triBa: tristate port map (saida11,csa(11),barramentoA); triBb: tristate port map (saida11,csb(11),barramentoB); C: registrador generic map (16) port map (bc,clk_reg(12),saida12); triCa: tristate port map (saida12,csa(12),barramentoA); triCb: tristate port map (saida12,csb(12),barramentoB); D: registrador generic map (16) port map (bc,clk_reg(13),saida13); triDa: tristate port map (saida13,csa(13),barramentoA); triDb: tristate port map (saida13,csb(13),barramentoB); E: registrador generic map (16) port map (bc,clk_reg(14),saida14); triEa: tristate port map (saida14,csa(14),barramentoA); triEb: tristate port map (saida14,csb(14),barramentoB); F: registrador generic map (16) port map (bc,clk_reg(15),saida15); triFa: tristate port map (saida15,csa(15),barramentoA); triFb: tristate port map (saida15,csb(15),barramentoB); ba <= barramentoA; bb <= barramentoB; end estrutura; Componentes And, or e Nor library ieee; use ieee.std_logic_1164.all; entity AND2 is port (E1,E2: in std_logic; S: out std_logic); end AND2; architecture fluxo of AND2 is begin S <= E1 AND E2; end fluxo; library ieee; use ieee.std_logic_1164.all; entity INV is port (E:in std_logic; S: out std_logic); end INV; architecture fluxo of INV is begin S <= not (E); end fluxo; library ieee; use ieee.std_logic_1164.all; entity OR2 is port (E1,E2: in std_logic; S: out std_logic); end OR2; architecture fluxo of OR2 is begin S <= E1 OR E2; end fluxo; library ieee; use ieee.std_logic_1164.all; entity AND5 is port (E1,E2,E3,E4,E5: in std_logic; S: out std_logic); end AND5; architecture fluxo of AND5 is begin S <= E1 AND E2 AND E3 AND E4 and E5; end fluxo; 3. Observações Em alguns casos a simulação só foi possível escolhendo o teste na Library após inicializar o simulador. Um exemplo se encontra abaixo. No caso do TestBenchDecodificador4X16_Estrutural ao selecionar o teste através da tela Start Simulation e mandar executar a simulação o programa exibi a seguinte mensagem como mostra as telas abaixo Escolhendo o teste na Library temos o mesmo rodava sem problema como mostra as telas abaixo: 4. Conclusão Não há conclusões ainda. 5. Referências [1] Tanenbaum, A. S., “Organização Estruturada de Computadores”, 3a. Edição, Pearson/Prentice Hall. [2] Ashenden, Peter J., “The VHDL Cookbook”, 1st Edition, Department of Computer Science, University of Adelaide, South Australia, http://tams-www.informatik.unihamburg.de/vhdl/doc/cookbook/VHDL-Cookbook.pdf. [3] Mentor Graphics, http://www.model.com.
Compartilhar