Simple blinking LED

From ArmadeusWiki
Revision as of 19:17, 9 March 2009 by FabienM (Talk | contribs) (New page: Category: FPGA This design introduce FPGA usage on APF. The design will allow you to synthesize a design and configure the FGPA to blink led. LED wiring is describe on figure 1. [[im...)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

This design introduce FPGA usage on APF. The design will allow you to synthesize a design and configure the FGPA to blink led. LED wiring is describe on figure 1.

figure 1 - LED wiring

The design

The VHDL code above describe a clock divider by 48000000 to generate a 0.5 Hz clock that will blink the LED.

 library IEEE;
 use IEEE.STD_LOGIC_1164.ALL;
 use IEEE.numeric_std.all;
 
 entity Clk_div_led is
    Port ( 
           Clk             : in  std_logic;
           led_cathode     : out std_logic;
           led_anode       : out std_logic
    );
 end Clk_div_led;
 
 architecture RTL of Clk_div_led is
   constant max_count : natural := 48000000;
   signal Rst_n : std_logic;
 begin
 
    Rst_n <= '1';
    led_cathode <= '0';
 
    -- compteur de 0 à max_count
    compteur : process(Clk)
        variable count : natural range 0 to max_count;
    begin
        if Rst_n = '0' then
            count := 0;
            led_anode <= '1';
        elsif rising_edge(Clk) then
            if count < max_count/2 then
                led_anode    <='1';
                count := count + 1;
            elsif count < max_count then
                led_anode    <='0';
                count := count + 1;
            else
                count := 0;
                led_anode    <='1';
            end if;
        end if;
    end process compteur; 
 end RTL;

To synthesize this code, use Xilinx Web Pack, create a new project and add this VHDL module.

ISE need to know where to branch LED pins on its IO, this pinout is describe in constraint file with extension .ucf.

NET "Clk" LOC = "P55";
NET "Clk" TNM_NET = "Clk";
TIMESPEC "TS_Clk" = PERIOD "Clk" 10 ns HIGH 50 %;
NET "led_cathode" LOC = "P118"| IOSTANDARD = LVCMOS33 ;
NET "led_anode"   LOC = "P116"| IOSTANDARD = LVCMOS33 ;

Some constraint files example can be found in armadeus firmware directory.

Generate bitstream

Once these two files are wrote, FPGA configuration file also name "bitstream" can be generate clicking on Synthetize - XST then Implement Design and finally Generate Programming File. If all this operation correctly done, a file with ".bit" extension is generated.

Configure FPGA

To configure FGPA the bitstream must be downloaded from host to apf card then from apf card to FGPA.

HOST to APF

C'est à partir de maintenant que les ennuis commencent (ou les choses intéressante c'est selon). Il faut télécharger le bitstream dans le FPGA. Pour cela j'ai utilisé UBoot, en ayant bien pris soin de configurer le réseau correctement comme expliqué sur la page Connection_with_U-Boot_on_Linux.

Downloading Bitstream from Host to APF can be done in different way : with tftp from U-Boot, with tftp from Linux, with serial from U-Boot or with nfs from linux. Here the file is downloaded with tftp in U-Boot:

  • First copy bitstream in the host tftp directory:
 cp Clk_div_led.bit /tftpboot
  • Then download it in apf ram (address 0x08000000) with U-Boot command :
 BIOS> tftpboot 08000000 Clk_div_led.bit
 dm9000 i/o: 0x15c00000, id: 0x90000a46 
 MAC: 00:0e:32:00:00:01
 operating at 10M half duplex mode
 TFTP from server 192.168.0.143; our IP address is 192.168.0.10
 Filename 'Clk_div_led.bit'.
 Load address: 0x8000000
 Loading: T ##########################
 done
 Bytes transferred = 131029 (1ffd5 hex)

APF to FPGA

Finally, to download bitstream in FGPA (to configure the FGPA) use the U-Boot fpga command:

 BIOS>fpga load 0 08000000 1ffd5

FPGA configuration can also be done in Linux.

Enjoy the beauty of blinking LED =

Whaah !