Module 2

From Hamsterworks Wiki!

(Difference between revisions)
Jump to: navigation, search
(Step 4 - Downloading the design into the device)
(Ready to carry on?)
Line 128: Line 128:
* Press the program button, and ignore the warnings about the JTAG clock
* Press the program button, and ignore the warnings about the JTAG clock
* The design will be downloaded, and then the board will be configured with your design
* The design will be downloaded, and then the board will be configured with your design
 +
 +
== Viewing your design ==
 +
If you are keen you are able to view how your design is implemented within the FPGA. You can view the following:
 +
 +
[[image:m2s11.png]]
 +
 +
* A Register Transfer Level ('RTL') schematic, which shows how all your design level components are connected
 +
 +
[[image:m2s12.png]]
 +
 +
* A Technology Schematic, which shows how the individual components within the FPGA are connected
 +
 +
[[image:m2s13.png]]
 +
 +
* The Routed Design, which shows the physical locations and interconnections used on the FPGA chip.
 +
 +
[[image:m2s14.png]]
== Ready to carry on? ==
== Ready to carry on? ==
Click [[Module 3|here]] to carry on to the next module.
Click [[Module 3|here]] to carry on to the next module.

Revision as of 04:14, 2 January 2012

Welcome to the second part of the FPGA course!

Getting the first design to work is always the hardest part.

Contents

Aim of project

To wire two switches up to two LEDs.

Learning outcomes

  • Create a new project
  • Create a new VHDL module
  • Enter basic code
  • Implement the design
  • Create an implementation constraints file
  • Implement the design again
  • Use the hardware programming tool
  • Test the design in hardware
  • Build experience single wire inputs and outputs

Wow! That is a lot of learning for a second module

Step 1 - Create a new Project

- Click on "Xilinx ISE Design Suite 13.3" Studio Icon - From the "File" menu, choose "New Project" - Name the project "Switches+LEDs", and click on "Next".

M1p1.png

- This screen is where you say what FPGA you are using. Choose the following settings to tell the design tools what chip you are using, then press the "Next" button.

M1p2.png

- Click on the "Finish" button to create and open the new project

Step 2 - Create a new VHDL Module

- Right-click on the design window, on the FPGA device, and choose "New Source"

M1p3.png

- Highlight "VHDL module" and in the file name enter "Switches_LEDs", then press the "Next button". - This next dialog box allows you to define what connections the module has. We need four connections - two the the switches and two for the LEDs:

M1p4.png

- Click the "Next" button, then "Finish" to create the module and open it in the editor. To make things clearer, delete any line that starts with "--" - they are comments that do not influence the design.

 1: library IEEE;
 2: use IEEE.STD_LOGIC_1164.ALL;
 3:
 4: entity Switches_LEDs is
 5:    Port ( switch_0 : in  STD_LOGIC;
 6:           switch_1 : in  STD_LOGIC;
 7:           LED_0 : out  STD_LOGIC;
 8:           LED_1 : out  STD_LOGIC);
 9: end Switches_LEDs;
10:
11: architecture Behavioral of Switches_LEDs is
12: begin
13:
14: end Behavioral;

As you can see, it has created the definition for an entity called Switches_LEDs, with two inputs and two outputs - STD_LOGIC is used to indicate what values these inputs and outputs can have.

The architecture section is where you describe how the internal logic of the module actually works. For this project we use the "assignment" operator ("<=") to assign the LEDs the values of the switches:

 1: library IEEE;
 2: use IEEE.STD_LOGIC_1164.ALL;
 3:
 4: entity Switches_LEDs is
 5:   Port ( switch_0 : in  STD_LOGIC;
 6:          switch_1 : in  STD_LOGIC;
 7:          LED_0 : out  STD_LOGIC;
 8:          LED_1 : out  STD_LOGIC);
 9: end Switches_LEDs;
10:
11: architecture Behavioral of Switches_LEDs is
12: begin
13:   LED_0 <= switch_0;
14:   LED_1 <= switch_1;
15: end Behavioral;

If you press the green "play" arrow in the middle left of the design window the project should start building.

If your code has been entered successfully the project will build without any errors, and the design Window will now look like this:

M1p5.png

Great! You've built your first design! There is only one problem, and that is we haven't told the design tools which pin to connect these signals to.

Step 3 - Creating constraints

To tell the tools which pins to connect the signals to an "Implementation Constraints File" is needed.

  • From the "Project Menu" choose "New Source"
  • Select "Implemntation Constraints File" and call it "constraints":

M1p6.png

  • Click "Next" and "Finished".
  • In the design windows, a small '+' will appear by the Switches_LEDs module. Click that to show the new file:

M1p7.png

  • Double click "constraints.ucf" to open it in the editor window.
  • Add the following lines, which assign locations to the four wires, and instructs the tools to create a design that uses "Low Voltage Transistor Transistor Logic" signal levels:
NET LED_0    LOC="P75"  | IOSTANDARD=LVTTL;
NET LED_1    LOC="P67"  | IOSTANDARD=LVTTL; 
NET Switch_0 LOC="P74"  | IOSTANDARD=LVTTL; 
NET Switch_1 LOC="P95"  | IOSTANDARD=LVTTL; 

Save the changes to this file, and then once again click on the Green arrow to build the design.

If that is successful, double click on "Generate Programming file":

M1p8.png

You will now have a 'bit' file in the project directory that can be used to program the FPGA!

Step 4 - Downloading the design into the device

TBD - Waiting on hardware

From memory the walk-through is

  • For the Basys2, launch Adept.
  • If the device isn't automatically detected, click on the "Device manager" and add it to the device table. You will only need to do this once
  • Use the browse button to search for your project's .bit file
  • Press the program button, and ignore the warnings about the JTAG clock
  • The design will be downloaded, and then the board will be configured with your design

Viewing your design

If you are keen you are able to view how your design is implemented within the FPGA. You can view the following:

M2s11.png

  • A Register Transfer Level ('RTL') schematic, which shows how all your design level components are connected

M2s12.png

  • A Technology Schematic, which shows how the individual components within the FPGA are connected

M2s13.png

  • The Routed Design, which shows the physical locations and interconnections used on the FPGA chip.

M2s14.png

Ready to carry on?

Click here to carry on to the next module.

Personal tools