FPGA

From LHEP Wiki
Revision as of 09:49, 18 March 2015 by Lhep (talk | contribs) (1 revision imported)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

A 'Hello World' on an FPGA in VHDL

  1. Install Xilinx ISE
  2. Create a new project, choose the board you are working with and choose VHDL.
  3. Create a VHDL module and type in the following code:
    library IEEE;
    use IEEE.STD_LOGIC_1164.ALL;
    
    entity lhep_twiki_test_entity is
        Port ( a : in  STD_LOGIC;
               led0, led1 : out  STD_LOGIC);
    end lhep_twiki_test_entity;
    
    architecture lhep_twiki_test_arch of lhep_twiki_test_entity is
    begin
    
    	led0 <= a;
    	led1 <= (NOT a);
    
    end lhep_twiki_test_arch;
  4. In the processes window, synthesize the project. In the logic synthesis the software transforms the HDL constructs to generic gate-level components, such as simple logic gates and flip-flops.
  5. Now generate a user constraint file. Here you associate the ports on the FPGA with the pins on the board. You need to find some documentation about the board (this can be tricky). You need to have one input (not important) and two output pins for this example. Try to connect the outputs (led0, led1) with unbuffered (!) LED's and the input (a) with a button or a switch. If you have found the pins you can write the user constraint file, which may look like this in the end:
    NET "a" LOC = F3;
    
    NET "led0" LOC = D17;
    NET "led1" LOC = AB4;
    
    You can also use the Xilinx tool PlanAhead for this step which comes with ISE.
  6. In the processes window, implement the design. This will start three subprocesses: The translate process merges multiple design files to a single netlist. The map process maps the generic gates in the netlist to FPGA's logic cells and IOB's. The place and route process derives the physical layout inside the FPGA chip.
  7. In the processes window, generate the programming file. This will generate the bitstream file which subsequently will be transferred to the FPGA.
  8. Again in the processes window, configure target device. This will open the Xilinx tool iMPACT. Here, perform a boundary scan. If your FPGA is connected via JTAG to the computer you're working with, it should find the board. Bypass all chips except for the actual FPGA. Choose the binary file you generated before and upload it.
  9. Play around with the button and observe how the LED's change.


How to simulate a program on the FPGA

not implemented yet.


How to program the Flashcard

If you program the FPGA and switch off the power it will erase your program. The FPGA cannot store your program but it is able to download the program from a flashcard at every startup.

  1. To do this, generate an ACE file from your bitstream using iMPACT and SystemACE. You have to choose a configuration address. This means that you can put more than one program on the flashcard. You can chose which program should be loaded by setting the correct jumpers.
  2. Put the generate ACE file on the flashcard using a flashcard reader (this can't be done by the JTAG connector). On the flashcard there needs to be a top-level file called "xilinx.sys" and a folder called "XILINX" (can be changed). Write the following code in the xilinx.sys:
    dir = XILINX;
    cfgaddr0 = program0;
    [cfgaddr1 = program1;
    ...]
    

    In the XILINX folder you need to have a folder for every address you specified (i.e. program0, program1, etc.). The ACE file needs to be placed in the corresponding folder.

  3. Use iMPACT to check the correct implementation of the files on the flashcard.
  4. After reinstalling the flashcard on the board you have to set a jumper which enables to read from the flashcard and other jumpers to tell the flashcard which program it should write on the FPGA. Check the user guide. At every startup the corresponding program should be loaded now.


If you have further questions, ask Basil.