CAL support on FPG-EYE

From ErikaWiki

(Difference between revisions)
Jump to: navigation, search
(How to Build a CAL Project with Diamond)
 
(27 intermediate revisions not shown)
Line 1: Line 1:
== Introduction ==
== Introduction ==
-
In this tutorial how to create a CAL's network inside the FPGA on Evidence board FPG-EYE is explained by using three system ACTORS developed for the FPG-EYE board. How to integrate an hardware CAL network with our system actor will be deeply explained.
+
This tutorial explains how to create a [[Brief introduction to the CAL language | CAL]] network for the FPGA on the Evidence's FPG-EYE board using three system actors developed for the FPG-EYE board. Also, it explains how to integrate a hardware CAL network with our system actors.  For more background information, see the [[Brief introduction to the CAL language]].
== Prerequisites ==
== Prerequisites ==
Line 9: Line 9:
=== OpenForge ===
=== OpenForge ===
-
OpenForge is xlim to hdl compiler. You can download it at [https://openforge.svn.sourceforge.net/svnroot/openforge https://openforge.svn.sourceforge.net/svnroot/openforge].
+
OpenForge is a XLIM to HDL compiler. You can download it at [https://openforge.svn.sourceforge.net/svnroot/openforge https://openforge.svn.sourceforge.net/svnroot/openforge].
=== OpenDf ===
=== OpenDf ===
-
OpenDf is a CAL simulator working as the front end for HDL generation. The OpenDf tool can even produce xlim code as intermediate format.
+
OpenDf is a CAL simulator working as the front end for HDL generation. The OpenDf tools can even produce XLIM code as intermediate format.
-
You can download it at [https://opendf.svn.sourceforge.net/svnroot/opendf https://opendf.svn.sourceforge.net/svnroot/opendf]. To install the plug-in in Eclipse you can follow [https://opendf.svn.sourceforge.net/svnroot/opendf/trunk/doc/Eclipse_Plugin_Install.txt those instructions].
+
You can download it at [https://opendf.svn.sourceforge.net/svnroot/opendf https://opendf.svn.sourceforge.net/svnroot/opendf]. To install the plug-in in Eclipse you can follow [https://opendf.svn.sourceforge.net/svnroot/opendf/trunk/doc/Eclipse_Plugin_Install.txt these instructions on the OpendDf site].
=== ispLEVER ===
=== ispLEVER ===
-
FPG-EYE board is based on a Lattice FPGA device so Lattice developer tools to compile CAL project can be used. In this tutorial the [http://www.latticesemi.com/products/designsoftware/isplever/index.cfm ispLEVER] is adopted. IspLEVER is an integrated software development environment able to control all aspects of the development work flow. It should be noticed that the free ispLEVER version cannot be used for this tutorial as is able to compile project containing only Verilog or VHDL files.  
+
FPG-EYE board is based on a Lattice FPGA, so Lattice developer tools must be used to compile CAL projects. In this tutorial [http://www.latticesemi.com/products/designsoftware/isplever/index.cfm Lattice ispLEVER] is adopted. ispLEVER is an integrated software development environment able to control all aspects of the development work flow. It should be noticed that the free ispLEVER version cannot be used for this tutorial as it is able to compile project containing only either Verilog or VHDL source files.  
-
In order to be able to proceed with this tutorial you a commercial version of ispLEVER from Lattice Semiconductor is required.
+
In order to be able to proceed with this tutorial you need a commercial license for ispLEVER from Lattice Semiconductor.
-
= FPG-EYE package =
+
=== Diamond ===
-
The FPG-EYE package contains the system actors source files in Verilog for three actors (Leds, Switches, and Camera), some examples their use, and  test bench to simulate each actor. To be used those examples have only to be compiled.
+
Diamond is the next generation replacement for ispLEVER featuring design exploration, ease of use, improved design flow, and numerous other enhancements. A free version is available on [http://www.latticesemi.com/products/designsoftware/diamond/downloads.cfm download Lattice page]. A free license can be requested from the Lattice website previous Lattice site registration.
 +
It should be noticed that the free Diamond version cannot be used for this tutorial as it is able to compile project containing only either Verilog or VHDL source files.
 +
In order to be able to proceed with this tutorial you need a commercial license for Diamond from Lattice Semiconductor.
 +
 
 +
== FPG-EYE package ==
 +
The FPG-EYE package contains the system actors source files in Verilog for three actors (LEDs, Switches, and Camera), some examples their use, and  test bench to simulate each actor. To be used those examples have only to be compiled.
-
== System Actors in FPG package ==
 
The system actors we have created for the FPG-EYE are:
The system actors we have created for the FPG-EYE are:
-
* <tt>Actor Leds</tt>.
+
* <tt>Leds</tt>.
-
* <tt>Actor Switches</tt>.
+
* <tt>Switches</tt>.
-
* <tt>Actor Camera</tt>.
+
* <tt>Camera</tt>.
-
=== System Actor Leds ===
+
=== LEDs System Actor ===
-
The <tt>System Actor Leds</tt>, written in Verilog, uses the eight <tt>LEDs</tt> on the boards (see <tt>DL0</tt>,...., <tt>DL7</tt> into <tt>ES-02610_SCH_main.pdf</tt> file) to display the input byte.
+
The <tt>LEDs System Actor</tt>, written in Verilog, uses the eight <tt>LEDs</tt> on the boards (see <tt>DL0</tt>,...., <tt>DL7</tt> into <tt>ES-02610_SCH_main.pdf</tt> file) to display the input byte.
-
The Actor input interface receives an 8 bit token from another actor in the system, one bit for each leds (<tt>data_0 => led0</tt>, <tt>data_1 => led1</tt>, <tt>etc...</tt>). When a <tt>data_bit</tt> is 0 the corresponding <tt>LED</tt> is off, when a <tt>data_bit</tt> is 1 logic, the corresponding <tt>LED</tt> is on.
+
The Actor input interface receives an 8 bit token from another actor in the system, one bit for each LEDs (<tt>data_0 => led0</tt>, <tt>data_1 => led1</tt>, <tt>etc...</tt>). When a <tt>data_bit</tt> is 0 the corresponding <tt>LED</tt> is off, when a <tt>data_bit</tt> is 1 logic, the corresponding <tt>LED</tt> is on.
-
The actor <tt>Leds</tt> consists of the following files:
+
The actor <tt>LEDs</tt> consists of the following files:
-
* <tt>leds.v</tt> (in the directory <tt>svn-cal\hw\trunk\hdl_actors\actor_led</tt>)
+
* <tt>LEDs.v</tt> (in the directory <tt>svn-cal\hw\trunk\hdl_actors\actor_led</tt>)
* <tt>arbiter2.v</tt> (in the directory <tt>svn-cal\hw\trunk\examples\arbiter2</tt>)
* <tt>arbiter2.v</tt> (in the directory <tt>svn-cal\hw\trunk\examples\arbiter2</tt>)
* <tt>serial_io.v</tt> (in the directory <tt>svn-cal\hw\trunk\examples\serial_io</tt>)
* <tt>serial_io.v</tt> (in the directory <tt>svn-cal\hw\trunk\examples\serial_io</tt>)
* <tt>wb_leds.v</tt> (in the directory <tt>svn-cal\hw\trunk\examples\examble1</tt>)
* <tt>wb_leds.v</tt> (in the directory <tt>svn-cal\hw\trunk\examples\examble1</tt>)
-
[[File:leds.png|center|thumb|200px|System Actors Leds structure]]
+
[[File:leds.png|center|thumb|200px|System Actors LEDs structure]]
-
==== leds.v ====
+
;leds.v
-
The <tt>leds.v</tt> file is a state machine <tt>leds</tt> (written in Verilog) that manages booth the <tt>Actors</tt> protocol,
+
: The <tt>leds.v</tt> file contains the module <tt>leds</tt> (a state machine written in Verilog) that manages both the <tt>Actors</tt> protocol, and the <tt>WishBone</tt> bus protocol.
-
and the <tt>WishBone</tt> bus protocol.
+
-
==== arbiter2.v ====
+
;arbiter2.v
-
The <tt>arbiter2.v</tt> file contains the <tt>arbiter</tt> module (written in Verilog), that  is a two way <tt>WishBone</tt> arbiter with two <tt>masters</tt> and a single <tt>slave</tt>. The actor <tt>leds</tt> uses the <tt>master bus 0</tt> (wb0), while the actors <tt>Switches</tt> uses the <tt>master bus 1</tt> (wb1).
+
: The <tt>arbiter2.v</tt> file contains the <tt>arbiter</tt> module (written in Verilog), a two-way <tt>WishBone</tt> arbiter with two <tt>masters</tt> and a single <tt>slave</tt>. The actor <tt>LEDs</tt> uses the <tt>master bus 0</tt> (wb0), while the actors <tt>Switches</tt> uses the <tt>master bus 1</tt> (wb1).
-
==== serial_io.v ====
+
;serial_io.v
-
The file <tt>serial_io.v</tt> contains a state machine <tt>serial_io</tt> (written in Verilog) managing the <tt>WishBone</tt> protocol, and a serial/parallel register, corresponding to the <tt>74hc595</tt> chip that drives the leds on the board.
+
: The file <tt>serial_io.v</tt> contains a state machine <tt>serial_io</tt> (written in Verilog) managing the <tt>WishBone</tt> protocol, and a serial/parallel register, interfacing with the <tt>74hc595</tt> chip that drives the LEDs on the board.
-
==== wb_leds.v ====
+
;wb_leds.v
-
The file <tt>wb_leds.v</tt> is a wrapper enclosing the component <tt>leds</tt>, <tt>arbiter</tt> and <tt>serial_io</tt> as their connections.
+
:The file <tt>wb_leds.v</tt> is a wrapper enclosing the component <tt>leds</tt>, <tt>arbiter</tt> and <tt>serial_io</tt> as their connections.
-
=== Example with System Actor Leds ===
+
An example of these actors and the related component could be located in <tt>svn-cal\hw\trunk\examples\example1</tt>, where a simple testbench of the <tt>leds</tt> actor is present (<tt>example1\active_hdl</tt>). A project example based on an 8-bit number generator and the <tt>LEDs</tt> actor can be find in the directory <tt>svn-cal\hw\trunk\examples\example3</tt>.
-
An example of those actors and the related component could be located in <tt>svn-cal\hw\trunk\examples\example1</tt>, where a simple testbench of the <tt>leds</tt> actor is present (<tt>example1\active_hdl</tt>). An project example based on an eight bits number generator and the <tt>leds</tt> actor could be find in the directory <tt>svn-cal\hw\trunk\examples\example3</tt>.
+
[[File:example3.png|center|thumb|200px|Example3: LEDs System Actor with eight bits number generator]]
-
[[File:example3.png|center|thumb|200px|Example3: System Actor Leds with eight bits number generator]]
+
-
=== System Actors Switches ===
+
=== Switches System Actor ===
-
The <tt>System Actor Switches</tt> is an actor for the FPG-EYE board written in Verilog.
+
The <tt>Switches System Actor</tt> is an actor for the FPG-EYE board written in Verilog.
-
This actor uses eight Switches on the boards (see <tt>SW0</tt>,...., <tt>SW7</tt> into <tt>ES-02610_SCH_main.pdf</tt> file) to read their status, and produce a token containing such status.
+
This actor uses eight Switches on the boards (see <tt>SW0</tt>,...., <tt>SW7</tt> into <tt>ES-02610_SCH_main.pdf</tt> file) to read their state, and produce a token containing such state.
The actor <tt>Switches</tt> consists of the following files:
The actor <tt>Switches</tt> consists of the following files:
* <tt>switches.v</tt> (in the directory <tt>svn-cal\hw\trunk\hdl_actors\actor_switches</tt>)
* <tt>switches.v</tt> (in the directory <tt>svn-cal\hw\trunk\hdl_actors\actor_switches</tt>)
Line 65: Line 67:
* <tt>wb_switches.v</tt> (in the directory <tt>svn-cal\hw\trunk\examples\examble2</tt>)
* <tt>wb_switches.v</tt> (in the directory <tt>svn-cal\hw\trunk\examples\examble2</tt>)
-
[[File:switches.png|center|thumb|200px|System Actors Switches structure]]
+
[[File:switches.png|center|thumb|200px|Switches System Actors structure]]
-
==== switches.v ====
+
; switches.v
-
The <tt>switches.v</tt> file consists of a state machine <tt>switches</tt> (written in Verilog) that manages booth the Actors and the WishBone protocols.
+
: The <tt>switches.v</tt> file consists of the state machine <tt>switches</tt> (written in Verilog) that manages both the Actors and the WishBone protocols.
-
==== arbiter2.v ====
+
; arbiter2.v
-
The <tt>arbiter2.v</tt> file contains the <tt>arbiter</tt> module (written in Verilog), that  is a two way <tt>WishBone</tt> arbiter with two <tt>masters</tt> and a single <tt>slave</tt>. The actor <tt>leds</tt> uses the <tt>master bus 0</tt> (wb0), while the actors <tt>Switches</tt> uses the <tt>master bus 1</tt> (wb1).
+
: The <tt>arbiter2.v</tt> file contains the <tt>arbiter</tt> module (written in Verilog), a two-way <tt>WishBone</tt> arbiter with two <tt>masters</tt> and a single <tt>slave</tt>. The actor <tt>LEDs</tt> uses the <tt>master bus 0</tt> (wb0), while the actors <tt>Switches</tt> uses the <tt>master bus 1</tt> (wb1).
-
==== serial_io.v ====
+
; serial_io.v
-
The file <tt>serial_io.v</tt> contains a state machine <tt>serial_io</tt> (written in Verilog) managing the <tt>WishBone</tt> protocol, and a serial/parallel register, corresponding to the <tt>74hc595</tt> chip that drives the leds on the board.
+
: The file <tt>serial_io.v</tt> contains a state machine <tt>serial_io</tt> (written in Verilog) managing the <tt>WishBone</tt> protocol, and a serial/parallel register, interfacing with the <tt>74hc595</tt> and <tt>74hc195</tt> chips that drive the LEDs and poll the switches.
-
==== wb_switches.v ====
+
; wb_switches.v
-
The file <tt>wb_switches.v</tt> is a wrapper enclosing the component <tt>switches</tt>, <tt>arbiter</tt> and <tt>serial_io</tt> as their connections.
+
: The file <tt>wb_switches.v</tt> is a wrapper enclosing the component <tt>switches</tt>, <tt>arbiter</tt> and <tt>serial_io</tt>.
-
=== Example with System Actor Switches ===
 
A simple testbench for this actors could be find in the directory <tt>svn-cal\hw\trunk\examples\example2</tt>.
A simple testbench for this actors could be find in the directory <tt>svn-cal\hw\trunk\examples\example2</tt>.
-
Moreover a simulation example where the actor <tt>switches</tt> is used along with the actor <tt>leds</tt> is contained in the directory <tt>svn-cal\hw\trunk\examples\example4</tt>. In this example when a switch is turned off/on its led is turned off/on (see fig: Example4), the related FPGA Lattice implementation could be find in the <tt>svn-cal\hw\trunk\examples\example5</tt> directory.
+
Moreover, a simulation example where the actor <tt>switches</tt> is used along
 +
with the actor <tt>LEDs</tt> is contained in the directory
 +
<tt>svn-cal\hw\trunk\examples\example4</tt>. In this example, when a switch is
 +
turned off/on the correspondent LED is turned off/on (see fig: Example4).  The related Lattice FPGA implementation can be found in the <tt>svn-cal\hw\trunk\examples\example5</tt> directory.
-
=== System Actors Camera ===
+
=== Camera System Actor ===
-
The <tt>System Actor Camera</tt> is an actor for the FPG-EYE board written in Verilog. The actor uses an hardware <tt>camera</tt> module that can be placed into the board (see <tt>ES-02310_SCH_camera.pdf</tt> file).
+
The <tt>Camera System Actor</tt> is an actor for the FPG-EYE board written in
 +
Verilog. The actor require a hardware <tt>camera</tt> module to be mounted on
 +
the board.
[[File:camera.png|center|thumb|200px|System Actors camera structure]]
[[File:camera.png|center|thumb|200px|System Actors camera structure]]
The actor <tt>Camera</tt> consists only of the file <tt>act_camera.v</tt> (in the directory <tt>svn-cal\hw\trunk\hdl_actors\actor_camera</tt>)
The actor <tt>Camera</tt> consists only of the file <tt>act_camera.v</tt> (in the directory <tt>svn-cal\hw\trunk\hdl_actors\actor_camera</tt>)
-
==== act_camera.v ====
+
; act_camera.v
-
The <tt>act_camera.v</tt> file consits of a state machine <tt>camera</tt> (written in Verilog) that manages the camera signals  
+
: The <tt>act_camera.v</tt> file consists of the state machine <tt>camera</tt> (written in Verilog) that manages the camera signals and the CAL protocol. The actor <tt>Camera</tt> has two CAL compatible output interfaces (sending tokens to other actors). The first CAL output has a data size of 8 bits and sends token containing the image pixel values, while the second CAL output, with a data size of 1 bit, sends a token whenever a new frame starts.
-
and the CAL's protocol. The actor <tt>Camera</tt> has two CAL compatible output interfaces (sending tokens to other actor). The first output CAL, having a data size of 8 bits, sends token related to the image pixel values, while the second output CAL, with a data size of 1 bit, sends a token when a new frame starts.
+
-
=== Example with System Actor Camera ===
+
A simple example for <tt>camera</tt> actor is located in the <tt>svn-cal\hw\trunk\examples\example7</tt> directory. All the three actors are used in this example: the LEDs act as a bar graph, whose length is proportional to the average image luminance.
-
A simple example for <tt>camera>/tt> actor is located the <tt>svn-cal\hw\trunk\examples\example7</tt> directory. All the three actors are used in this example: the LEDs are turned on or off proportionally to the average image luminance.
+
[[File:example7.png|center|thumb|200px|example7: Board LEDs are turned on or off proportionally to the average image luminance]]
-
[[File:example7.png|center|thumb|200px|example7: Board Leds are turned on or off proportionally to the average image luminance]]
+
-
== How to interface a CAL Netlist to the System Actor ==
+
== How to Interface a CAL Netlist to System Actors ==
To interface a CAL Netlist with an actor few steps are needed:
To interface a CAL Netlist with an actor few steps are needed:
-
* creation of a Netlist by the CAL environment with the needed number of input and output ports
+
* Create a Netlist in the CAL environment with the needed number of input and output ports
-
* building a wrapper to connect the netlist and the system actor
+
* Build a wrapper in Verilog (or VHDL) that connects the netlist with the required system actors
-
== How to create a CAL project under ispLEVER ==
+
== How to Build a CAL Project with ispLEVER or Diamond ==
-
To create an ispLEVER CAL project we have to:
+
First you must to have a Cal project with System Actors for FPG-EYE. See [[Create a Cal project with System Actors]] for instructions on how to do it.
 +
To build an ispLEVER CAL project we have to:
 +
* Open ispLEVER and click on new project. [[File:new_project.png|center|thumb|200px| Click on "Open Project"]]
 +
* In the following window choose the project name and the its destination path. Please remember to select "Mixed Verilog/VHDL" for the option "Design Entry Type". [[File:name_project.png|center|thumb|200px|Add "Name Project"]]
 +
* In the following window we have to select the device. For the FPG-EYE board we must use:
 +
** Family: LatticeXP2;
 +
** Device: LFXP2-17E;
 +
** Speed grade: 5;
 +
** Package type: PQFP208;
 +
** Operating conditions: Commercial;
 +
** PartName: LFXP2-17E-5QN208C. [[File:select_device.png|center|thumb|200px|"Select Device"]]
 +
* Finally by clicking the End button [[File:add_source.png|center|thumb|200px|"Add Source"]] the following window will be displayed: [[File:isp_lever.png|center|thumb|200px|ispLEVER]]
 +
* To import <tt>lattice_cal.vhdl</tt> the library (<tt>svn-cal/hw/trunk/lib_vhdl</tt>) we have to right click on device and select "Import...". [[File:import_file.png|center|thumb|200px|Import file]]
 +
* In the file window we can now select the file <tt>lattice_cal.vhdl</tt> [[File:lib_vhdl.png|center|thumb|200px|Import the file "lattice_cal.vhdl"]]
 +
* Now by right clicking the lattice_cal.vhdl we can select "Library Name" [[File:library_name.png|center|thumb|200px|Select "Library Name"]]
 +
* In the Box "VHDL Library Name" we can insert the namespace <tt>SystemBuilder</tt>[[File:system_builder.png|center|thumb|200px|Write: SystemBuilder]]
 +
* Each file created by the CAL compiler has an undefined module FD. This module is a D-FF (flip flop) declared in the xilinx library. This is part of a small reset synchronizer circuit. You have to remove this part because the Lattice software does not recognize it.<br/> There is a Perl script <tt>main_modify.pl</tt> that searches these FD instances in Verilog files and replaces them with a reset synchronizer. You can run this Perl script with the top level VHDL file as input. Before executing the Perl script, please check that all generated files are in the same folder. If the top level generated file name is <tt>main_nw.vhd</tt>, we can issue <tt>perl main_modify.pl main_nw</tt>.<br/> The script will produce a *_mod.v file for each parsed Verilog file.
 +
* After importing the files related to the various actors (LED, camera, and those related to our CAL netlist), a constraint file describing the connection between FPGA pins and logic blocks must be created. An example of these constraints can be found in "svn-cal\hw\trunk\examples\example7\isp_lever\example7.lpf"
 +
* We can finally compile the project, thus obtaining a binary JED file to program the FPG-EYE board.
-
* Open ispLEVER and click on new project.
+
== How to Build a CAL Project with Diamond ==
-
[[File:new_project.png|center|thumb|200px| Click on "Open Project"]]
+
First you must to have a Cal project with System Actors for FPG-EYE. See [[Create a Cal project with System Actors]] for instructions on how to do it.
-
 
+
To build a Diamond CAL project we have to:
-
* In the following window choose the project name and the its destination path. Please remember to select "Mixed Verilog/VHDL" for the options "Design Entry Type".
+
* Open Diamond and click on new project. [[File:new_project_diamond.png|center|thumb|200px| Click on "Open Project"]]
-
[[File:name_project.png|center|thumb|200px|Add "Name Project"]]
+
* In the following window choose the project name and the its destination path.[[File:name_project_diamond.png|center|thumb|200px|Add "Name Project"]]
-
 
+
* In the following window we have to select the device. For the FPG-EYE board we must use:
-
* In the following window we have to select the device. If adopting the FPG-EYE board we can use:
+
** Family: LatticeXP2;
** Family: LatticeXP2;
** Device: LFXP2-17E;
** Device: LFXP2-17E;
Line 117: Line 138:
** Package type: PQFP208;
** Package type: PQFP208;
** Operating conditions: Commercial;
** Operating conditions: Commercial;
-
** PartName: LFXP2-17E-5QN208C.
+
** PartName: LFXP2-17E-5QN208C. [[File:select_device_diamond.png|center|thumb|200px|"Select Device"]]
-
[[File:select_device.png|center|thumb|200px|"Select Device"]]
+
* Finally by clicking the End button the following window will be displayed: [[File:diamond.png|center|thumb|200px|Diamond]]
-
 
+
* To import <tt>lattice_cal.vhdl</tt> the library (<tt>svn-cal/hw/trunk/lib_vhdl</tt>) we have to right click on device and select "Add->Existing File". [[File:import_file_diamond.png|center|thumb|200px|Import file]]
-
* Finally by clicking the End button
+
* In the file window we can now select the file <tt>lattice_cal.vhdl</tt> [[File:lib_vhdl.png|center|thumb|200px|Import the file "lattice_cal.vhdl"]]
-
[[File:add_source.png|center|thumb|200px|"Add Source"]]
+
* Now by right clicking the lattice_cal.vhdl we can select "Properties" an then in the Box "VHDL Library Name" we can insert the namespace <tt>SystemBuilder</tt>[[File:system_builder_diamond.png|center|thumb|200px|Write: SystemBuilder]]
-
the following window will be displayed
+
* Each file created by the CAL compiler has an undefined module FD. This module is a D-FF (flip flop) declared in the xilinx library. This is part of a small reset synchronizer circuit. You have to remove this part because the Lattice software does not recognize it.<br/> There is a Perl script <tt>main_modify.pl</tt> that searches these FD instances in Verilog files and replaces them with a reset synchronizer. You can run this Perl script with the top level VHDL file as input. Before executing the Perl script, please check that all generated files are in the same folder. If the top level generated file name is <tt>main_nw.vhd</tt>, we can issue <tt>perl main_modify.pl main_nw</tt>.<br/> The script will produce a *_mod.v file for each parsed Verilog file.
-
[[File:isp_lever.png|center|thumb|200px|ispLEVER]]
+
* After importing the files related to the various actors (LED, camera, and those related to our CAL netlist), a constraint file describing the connection between FPGA pins and logic blocks must be created. An example of these constraints can be found in "svn-cal\hw\trunk\examples\example7\diamond\example7.lpf"
-
 
+
* We can finally compile the project, thus obtaining a binary JED file to program the FPG-EYE board.
-
* To import <tt>lattice_cal.vhdl</tt> the library (<tt>svn-cal/hw/trunk/lib_vhdl</tt>) we have to right click on device and select "Import...".
+
[[File:compile_diamond.png|center|thumb|200px| "Return All" for obtaining a binary JED file]]
-
[[File:import_file.png|center|thumb|200px|Import file]]
+
-
 
+
-
* In the file window we can now select <tt>lattice_cal.vhdl</tt> the file
+
-
[[File:lib_vhdl.png|center|thumb|200px|Import the file "lattice_cal.vhdl"]]
+
-
 
+
-
* Now by right clicking the lattice_cal.vhdl we can select "Library Name"
+
-
[[File:library_name.png|center|thumb|200px|Select "Library Name"]]
+
-
 
+
-
* In the Box "VHDL Library Name" we can insert the namespace <tt>SystemBuilder</tt>
+
-
[[File:system_builder.png|center|thumb|200px|Write: SystemBuilder]]
+
-
 
+
-
* Each file created by Cal has an undefined module FD. This module is a D-FF(flip flop) declared in the xilinx library. This is part of a small reset synchronizer circuit. You have to remove this part because the Lattice software does not recognize it.
+
-
There is a Perl script <tt>main_modify.pl</tt> that search and remove these FD instances in verilog and replace them with a reset synchronizer. You can run this perl script with top level VHD file as input. Before to execute the perl script please check that all generated files are in the same folder, e.g. the top level generated file name is <tt>main_nw.vhd</tt> we can run <tt>perl main_modify.pl main_nw</tt>.
+
-
The script will produce *_mod.v files for each verilog parsed file that can be compiled.
+
-
 
+
-
* After importing the files related to the various actors (LED, camera, and those related to our netlist CAL), a constraint file describing the connection between FPGA pins and logic block have to be created. An constraint example of these constraints could by found in "svn-cal\hw\trunk\examples\example7\isp_lever\example7.lpf"
+
-
* We can finally compile the project, thus obtaining a binary JED file that can be finally used to program the FPG-EYE board.
+
== How to Program the FPG-EYE board ==
 +
See [[Programming the FPG-EYE board]] for instructions on how to download the JED file onto the board

Latest revision as of 16:00, 14 November 2011

Contents

Introduction

This tutorial explains how to create a CAL network for the FPGA on the Evidence's FPG-EYE board using three system actors developed for the FPG-EYE board. Also, it explains how to integrate a hardware CAL network with our system actors. For more background information, see the Brief introduction to the CAL language.

Prerequisites

Before to start working with FPG-EYE board, you have to download and install the right developer tools.

Eclipse

Eclipse is designed to build integrated development environments (IDEs). It can be used to create various end-to-end computing solutions for multiple execution environments. You can download it at http://www.eclipse.org/.

OpenForge

OpenForge is a XLIM to HDL compiler. You can download it at https://openforge.svn.sourceforge.net/svnroot/openforge.

OpenDf

OpenDf is a CAL simulator working as the front end for HDL generation. The OpenDf tools can even produce XLIM code as intermediate format. You can download it at https://opendf.svn.sourceforge.net/svnroot/opendf. To install the plug-in in Eclipse you can follow these instructions on the OpendDf site.

ispLEVER

FPG-EYE board is based on a Lattice FPGA, so Lattice developer tools must be used to compile CAL projects. In this tutorial Lattice ispLEVER is adopted. ispLEVER is an integrated software development environment able to control all aspects of the development work flow. It should be noticed that the free ispLEVER version cannot be used for this tutorial as it is able to compile project containing only either Verilog or VHDL source files. In order to be able to proceed with this tutorial you need a commercial license for ispLEVER from Lattice Semiconductor.

Diamond

Diamond is the next generation replacement for ispLEVER featuring design exploration, ease of use, improved design flow, and numerous other enhancements. A free version is available on download Lattice page. A free license can be requested from the Lattice website previous Lattice site registration. It should be noticed that the free Diamond version cannot be used for this tutorial as it is able to compile project containing only either Verilog or VHDL source files. In order to be able to proceed with this tutorial you need a commercial license for Diamond from Lattice Semiconductor.

FPG-EYE package

The FPG-EYE package contains the system actors source files in Verilog for three actors (LEDs, Switches, and Camera), some examples their use, and test bench to simulate each actor. To be used those examples have only to be compiled.

The system actors we have created for the FPG-EYE are:

  • Leds.
  • Switches.
  • Camera.

LEDs System Actor

The LEDs System Actor, written in Verilog, uses the eight LEDs on the boards (see DL0,...., DL7 into ES-02610_SCH_main.pdf file) to display the input byte. The Actor input interface receives an 8 bit token from another actor in the system, one bit for each LEDs (data_0 => led0, data_1 => led1, etc...). When a data_bit is 0 the corresponding LED is off, when a data_bit is 1 logic, the corresponding LED is on. The actor LEDs consists of the following files:

  • LEDs.v (in the directory svn-cal\hw\trunk\hdl_actors\actor_led)
  • arbiter2.v (in the directory svn-cal\hw\trunk\examples\arbiter2)
  • serial_io.v (in the directory svn-cal\hw\trunk\examples\serial_io)
  • wb_leds.v (in the directory svn-cal\hw\trunk\examples\examble1)
System Actors LEDs structure
leds.v
The leds.v file contains the module leds (a state machine written in Verilog) that manages both the Actors protocol, and the WishBone bus protocol.
arbiter2.v
The arbiter2.v file contains the arbiter module (written in Verilog), a two-way WishBone arbiter with two masters and a single slave. The actor LEDs uses the master bus 0 (wb0), while the actors Switches uses the master bus 1 (wb1).
serial_io.v
The file serial_io.v contains a state machine serial_io (written in Verilog) managing the WishBone protocol, and a serial/parallel register, interfacing with the 74hc595 chip that drives the LEDs on the board.
wb_leds.v
The file wb_leds.v is a wrapper enclosing the component leds, arbiter and serial_io as their connections.

An example of these actors and the related component could be located in svn-cal\hw\trunk\examples\example1, where a simple testbench of the leds actor is present (example1\active_hdl). A project example based on an 8-bit number generator and the LEDs actor can be find in the directory svn-cal\hw\trunk\examples\example3.

Example3: LEDs System Actor with eight bits number generator

Switches System Actor

The Switches System Actor is an actor for the FPG-EYE board written in Verilog. This actor uses eight Switches on the boards (see SW0,...., SW7 into ES-02610_SCH_main.pdf file) to read their state, and produce a token containing such state. The actor Switches consists of the following files:

  • switches.v (in the directory svn-cal\hw\trunk\hdl_actors\actor_switches)
  • arbiter2.v (in the directory svn-cal\hw\trunk\examples\arbiter2)
  • serial_io.v (in the directory svn-cal\hw\trunk\examples\serial_io)
  • wb_switches.v (in the directory svn-cal\hw\trunk\examples\examble2)
Switches System Actors structure
switches.v
The switches.v file consists of the state machine switches (written in Verilog) that manages both the Actors and the WishBone protocols.
arbiter2.v
The arbiter2.v file contains the arbiter module (written in Verilog), a two-way WishBone arbiter with two masters and a single slave. The actor LEDs uses the master bus 0 (wb0), while the actors Switches uses the master bus 1 (wb1).
serial_io.v
The file serial_io.v contains a state machine serial_io (written in Verilog) managing the WishBone protocol, and a serial/parallel register, interfacing with the 74hc595 and 74hc195 chips that drive the LEDs and poll the switches.
wb_switches.v
The file wb_switches.v is a wrapper enclosing the component switches, arbiter and serial_io.

A simple testbench for this actors could be find in the directory svn-cal\hw\trunk\examples\example2. Moreover, a simulation example where the actor switches is used along with the actor LEDs is contained in the directory svn-cal\hw\trunk\examples\example4. In this example, when a switch is turned off/on the correspondent LED is turned off/on (see fig: Example4). The related Lattice FPGA implementation can be found in the svn-cal\hw\trunk\examples\example5 directory.

Camera System Actor

The Camera System Actor is an actor for the FPG-EYE board written in Verilog. The actor require a hardware camera module to be mounted on the board.

System Actors camera structure

The actor Camera consists only of the file act_camera.v (in the directory svn-cal\hw\trunk\hdl_actors\actor_camera)

act_camera.v
The act_camera.v file consists of the state machine camera (written in Verilog) that manages the camera signals and the CAL protocol. The actor Camera has two CAL compatible output interfaces (sending tokens to other actors). The first CAL output has a data size of 8 bits and sends token containing the image pixel values, while the second CAL output, with a data size of 1 bit, sends a token whenever a new frame starts.

A simple example for camera actor is located in the svn-cal\hw\trunk\examples\example7 directory. All the three actors are used in this example: the LEDs act as a bar graph, whose length is proportional to the average image luminance.

example7: Board LEDs are turned on or off proportionally to the average image luminance

How to Interface a CAL Netlist to System Actors

To interface a CAL Netlist with an actor few steps are needed:

  • Create a Netlist in the CAL environment with the needed number of input and output ports
  • Build a wrapper in Verilog (or VHDL) that connects the netlist with the required system actors

How to Build a CAL Project with ispLEVER or Diamond

First you must to have a Cal project with System Actors for FPG-EYE. See Create a Cal project with System Actors for instructions on how to do it. To build an ispLEVER CAL project we have to:

  • Open ispLEVER and click on new project.
    Click on "Open Project"
  • In the following window choose the project name and the its destination path. Please remember to select "Mixed Verilog/VHDL" for the option "Design Entry Type".
    Add "Name Project"
  • In the following window we have to select the device. For the FPG-EYE board we must use:
    • Family: LatticeXP2;
    • Device: LFXP2-17E;
    • Speed grade: 5;
    • Package type: PQFP208;
    • Operating conditions: Commercial;
    • PartName: LFXP2-17E-5QN208C.
      "Select Device"
  • Finally by clicking the End button
    "Add Source"
    the following window will be displayed:
    ispLEVER
  • To import lattice_cal.vhdl the library (svn-cal/hw/trunk/lib_vhdl) we have to right click on device and select "Import...".
    Import file
  • In the file window we can now select the file lattice_cal.vhdl
    Import the file "lattice_cal.vhdl"
  • Now by right clicking the lattice_cal.vhdl we can select "Library Name"
    Select "Library Name"
  • In the Box "VHDL Library Name" we can insert the namespace SystemBuilder
    Write: SystemBuilder
  • Each file created by the CAL compiler has an undefined module FD. This module is a D-FF (flip flop) declared in the xilinx library. This is part of a small reset synchronizer circuit. You have to remove this part because the Lattice software does not recognize it.
    There is a Perl script main_modify.pl that searches these FD instances in Verilog files and replaces them with a reset synchronizer. You can run this Perl script with the top level VHDL file as input. Before executing the Perl script, please check that all generated files are in the same folder. If the top level generated file name is main_nw.vhd, we can issue perl main_modify.pl main_nw.
    The script will produce a *_mod.v file for each parsed Verilog file.
  • After importing the files related to the various actors (LED, camera, and those related to our CAL netlist), a constraint file describing the connection between FPGA pins and logic blocks must be created. An example of these constraints can be found in "svn-cal\hw\trunk\examples\example7\isp_lever\example7.lpf"
  • We can finally compile the project, thus obtaining a binary JED file to program the FPG-EYE board.

How to Build a CAL Project with Diamond

First you must to have a Cal project with System Actors for FPG-EYE. See Create a Cal project with System Actors for instructions on how to do it. To build a Diamond CAL project we have to:

  • Open Diamond and click on new project.
    Click on "Open Project"
  • In the following window choose the project name and the its destination path.
    Add "Name Project"
  • In the following window we have to select the device. For the FPG-EYE board we must use:
    • Family: LatticeXP2;
    • Device: LFXP2-17E;
    • Speed grade: 5;
    • Package type: PQFP208;
    • Operating conditions: Commercial;
    • PartName: LFXP2-17E-5QN208C.
      "Select Device"
  • Finally by clicking the End button the following window will be displayed:
    Diamond
  • To import lattice_cal.vhdl the library (svn-cal/hw/trunk/lib_vhdl) we have to right click on device and select "Add->Existing File".
    Import file
  • In the file window we can now select the file lattice_cal.vhdl
    Import the file "lattice_cal.vhdl"
  • Now by right clicking the lattice_cal.vhdl we can select "Properties" an then in the Box "VHDL Library Name" we can insert the namespace SystemBuilder
    Write: SystemBuilder
  • Each file created by the CAL compiler has an undefined module FD. This module is a D-FF (flip flop) declared in the xilinx library. This is part of a small reset synchronizer circuit. You have to remove this part because the Lattice software does not recognize it.
    There is a Perl script main_modify.pl that searches these FD instances in Verilog files and replaces them with a reset synchronizer. You can run this Perl script with the top level VHDL file as input. Before executing the Perl script, please check that all generated files are in the same folder. If the top level generated file name is main_nw.vhd, we can issue perl main_modify.pl main_nw.
    The script will produce a *_mod.v file for each parsed Verilog file.
  • After importing the files related to the various actors (LED, camera, and those related to our CAL netlist), a constraint file describing the connection between FPGA pins and logic blocks must be created. An example of these constraints can be found in "svn-cal\hw\trunk\examples\example7\diamond\example7.lpf"
  • We can finally compile the project, thus obtaining a binary JED file to program the FPG-EYE board.
"Return All" for obtaining a binary JED file

How to Program the FPG-EYE board

See Programming the FPG-EYE board for instructions on how to download the JED file onto the board

Personal tools