11
Introdução à Programação da FPGA João M. P. Cardoso

Introdução à Programação da FPGA

  • Upload
    arnie

  • View
    22

  • Download
    0

Embed Size (px)

DESCRIPTION

Introdução à Programação da FPGA. João M. P. Cardoso. Programa-ção da FPGA. Placa de Desenvolvimento. XSA-50 Board. Placa de Desenvolvi-mento. Frequência: 100 MHz Pode ser dividida por 1, 2, ... 2052 utilizando a ferramenta gxssetclk. 1º Exemplo. Descodificador de 7-segmentos. 1º Exemplo. - PowerPoint PPT Presentation

Citation preview

Page 1: Introdução à Programação da FPGA

Introdução à Programação da FPGA

João M. P. Cardoso

Page 2: Introdução à Programação da FPGA

Programa-ção da FPGA

Page 3: Introdução à Programação da FPGA

Placa de Desenvolvimento

XSA-50 Board

Page 4: Introdução à Programação da FPGA

Placa de Desenvolvi-mento Frequência: 100

MHz Pode ser dividida

por 1, 2, ... 2052 utilizando a ferramenta gxssetclk

Page 5: Introdução à Programação da FPGA

1º Exemplo

Descodificador de 7-segmentos

Page 6: Introdução à Programação da FPGA

1º Exemplo

Criar um novo projecto Device Family: Spartan2 Device: XC2S50 Package property: tq144 speed grade: -5.

Page 7: Introdução à Programação da FPGA

1º Exemplo Depois do circuito ser

sintetizado, o P&R ter sido feito, podemos verificar que

a ferramenta atribuiu aos sinais de entrada/saída da entidade pinos de I/O

architecture Behavioral of seven_seg isbegin

process(inp_data) begin case inp_data is when "0000" =>

out_data <= "11110111";

when "0001" =>out_data <= "10010010";

when "0010" =>out_data <= "11011101";

when "0011" =>out_data <= "11011011";

when "0100" =>out_data <= "10111010";

when "0101" =>out_data <= "11101011";

when "0110" =>out_data <= "11101111";

when "0111" =>out_data <= "11010010";

when "1000" =>out_data <= "11111111";

when "1001" =>out_data <= "11111011";

when others =>out_data <= “01111111";

end case; end process;

end Behavioral;

Page 8: Introdução à Programação da FPGA

1º Exemplo Falta por isso

indicarmos os pinos correctos da FPGA que ligam ao display de 7-segmentos e aos 4 interruptores

LED input FPGA pin

S0 P67

S1 P39

S2 P62

S3 P60

S4 P46

S5 P57

S6 P49

DP P44

switchs FPGA pin

DIPSW1 P54

DIPSW2 P64

DIPSW3 P63

DIPSW4 P56

input FPGA pin

Botão SW2 P93

CCLK P88

Page 9: Introdução à Programação da FPGA

1º Exemplo Atribuição de sinais aos

pinos do FPGA Definição de um ficheiro de

restrições (User-constraint file)

Especificação em VHDL Especificação em VHDL

attribute loc : string; Attribute loc of clk : signal is

“P88” Attribute loc of reset: signal

is “P93” ...

Ficheiro de restrições net reset loc=p93;

library IEEE;

use IEEE.STD_LOGIC_1164.ALL;

use IEEE.STD_LOGIC_ARITH.ALL;

use IEEE.STD_LOGIC_UNSIGNED.ALL;

entity seven_seg is

Port ( inp_data : in std_logic_vector(3 downto 0);

out_data : out std_logic_vector(7 downto 0));

end seven_seg;

architecture Behavioral of seven_seg is

attribute loc : string;

attribute loc of inp_data : signal is "P54, P64, P63, P56";

attribute loc of out_data : signal is " P44, P49,P57, P46, P60, P62, P39, P67";

begin …

end Behavioral;

Page 10: Introdução à Programação da FPGA

1º Exemplo Para programarmos a

FPGA na placa utilizamos a ferramenta: gxsload

O ficheiro da configuração (bitstream) que deve ser carregado tem extensão .bit

Page 11: Introdução à Programação da FPGA

Descodificador de Sete Segmentoslibrary IEEE;use IEEE.STD_LOGIC_1164.ALL;use IEEE.STD_LOGIC_ARITH.ALL;use IEEE.STD_LOGIC_UNSIGNED.ALL;

entity seven_seg is Port ( inp_data : in std_logic_vector(3 downto 0); out_data : out std_logic_vector(7 downto 0));end seven_seg;

architecture Behavioral of seven_seg is

attribute loc : string;attribute loc of inp_data : signal is "P54, P64, P63,

P56";attribute loc of out_data : signal is " P44, P49,P57,

P46, P60, P62, P39, P67";

begin process(inp_data) begin case inp_data is when "0000" =>

out_data <= "11110111";

when "0001" =>out_data <= "10010010";

when "0010" =>out_data <= "11011101";

when "0011" =>out_data <= "11011011";

when "0100" =>out_data <= "10111010";

when "0101" =>out_data <= "11101011";

when "0110" =>out_data <= "11101111";

when "0111" =>out_data <= "11010010";

when "1000" =>out_data <= "11111111";

when "1001" =>out_data <= "11111011";

when others =>out_data <= “01111111";

end case; end process;

end Behavioral;