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, utilizando a ferramenta gxssetclk
1º Exemplo Descodificador de 7- segmentos
1º Exemplo Criar um novo projecto Device Family: Spartan2 Device: XC2S50 Package property: tq144 speed grade: -5.
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 is begin process(inp_data) begin case inp_data is when "0000" => out_data <= " "; when "0001" => out_data <= " "; when "0010" => out_data <= " "; when "0011" => out_data <= " "; when "0100" => out_data <= " "; when "0101" => out_data <= " "; when "0110" => out_data <= " "; when "0111" => out_data <= " "; when "1000" => out_data <= " "; when "1001" => out_data <= " "; when others => out_data <= “ "; end case; end process; end Behavioral;
1º Exemplo Falta por isso indicarmos os pinos correctos da FPGA que ligam ao display de 7- segmentos e aos 4 interruptores LED inputFPGA pin S0P67 S1P39 S2P62 S3P60 S4P46 S5P57 S6P49 DPP44 switchsFPGA pin DIPSW1P54 DIPSW2P64 DIPSW3P63 DIPSW4P56 inputFPGA pin Botão SW2P93 CCLKP88
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 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;
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
Descodificador de Sete Segmentos 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 process(inp_data) begin case inp_data is when "0000" => out_data <= " "; when "0001" => out_data <= " "; when "0010" => out_data <= " "; when "0011" => out_data <= " "; when "0100" => out_data <= " "; when "0101" => out_data <= " "; when "0110" => out_data <= " "; when "0111" => out_data <= " "; when "1000" => out_data <= " "; when "1001" => out_data <= " "; when others => out_data <= “ "; end case; end process; end Behavioral;