Restoring Minority Game with Evolution
Download
Report
Transcript Restoring Minority Game with Evolution
Targeting Handel-C
for the DE2 Board
Presented by
Vincent Lai
Supervised by
Professor Cheung
Aim
Program the DE2 board in a C-based
language
A Library of drivers that support the
hardware on the DE2 board
A Manual and instructions for using the
Library
2
Achievements
FPGA design framework
Program
in Handel-C
Hardware synthesis in Quartus II
A library targeting the DE2 system
Drivers:
PS/2, RAM, VGA
Interface with VHDL components
3
Contents
Hardware & Software
Development
Demonstration
Summary
| Hardware & Software | Development | Demonstration | Summary |
4
Hardware and Software
Hardware
Altera
DE2 board
Software
Quartus
II
DK Design Suite
Programming Language
Handel-C
VHDL
| Hardware & Software | Development | Demonstration | Summary |
5
Altera DE2 Board
A Development board with a Cyclone II FPGA
Memory
Flash
memory
SRAM
SDRAM
VGA
Switches
PS/2 Mouse
16x2 LCD module
7-Segment Displays & LEDs
| Hardware & Software | Development | Demonstration | Summary |
6
What is Handel-C?
a C-based language
not a hardware description language: it supports
abstractions common for software programmers
Reasonably complex system can be design
easily
High level yet allow description of sequential and
parallel logic
| Hardware & Software | Development | Demonstration | Summary |
7
Contents
Hardware & Software
Development
Demonstration
Summary
| Hardware & Software | Development | Demonstration | Summary |
8
Development Timeline
Week 1 – Getting familiar with the DE2 board and Handel-C
Week 2 – Research in building a library in Handel-C and writing simple VHDL functions
Week 3 – Use Handel-C to program the board
Week 4 to week 8 – Developing Drivers (writing and testing)
Week 9 – Writing the Manual and Instructions
Week 10 – Preparing the Demos and finishing off the Manual
Week 11 – Trying to add a camera to the DE2 board with the written drivers
| Hardware & Software | Development | Demonstration | Summary |
9
Library Components
Library file: .hcl
Header file: .hch
VHDL Functions Components
PS/2
mouse
Video Driver
LCD module
| Hardware & Software | Development | Demonstration | Summary |
10
Library file .hcl
Generated by using DK Library project
Create a .hcc file containing macros
Compile the project to obtain the .hcl file
Example macro procedure:
macro proc DE2SetLEDGs(mask)
{
interface bus_out() LEDG(mask)
with {data={"Y12","Y18","AA20","U17","U18","V18","W19","AF22","AE22"}};
}
| Hardware & Software | Development | Demonstration | Summary |
11
Header file .hch
Describe the macros in the library
Example:
typedef signal unsigned 9 DE2_LEDG_MASK;
extern macro proc DE2SetLEDGs(mask);
| Hardware & Software | Development | Demonstration | Summary |
12
Interfacing with VHDL
Some functions are written in VHDL
It is useful to interface with VHDL code
Example:
interface LCD_DISPLAY(unsigned 1 LCD_RS, unsigned 1 LCD_E,
unsigned 1 LCD_RW, unsigned 8 DATA_BUS)
LCD(unsigned 1 re_set=key0.in, unsigned 1 clk_50Mhz = clk_in.in,
unsigned 256 Hex_Display_Data=line)
with {vhdl_type="std_logic_vector"};
| Hardware & Software | Development | Demonstration | Summary |
13
Example User’s Program
in the “sample code” folder
set clock = external "N2";
#include "DE2.hch"
void main(void)
{
DE2_SW_MASK SW;
do
{
DE2SW(SW);
//read inputs from the toggle switches
DE2SetLEDRs(SW); //shows the status of the switches on LEDs
} while(1);
}
| Hardware & Software | Development | Demonstration | Summary |
14
Designing with the Library?
Include the DE2 Library
Program in Handel-C
Compile in DK – Outputs: EDIF file & tcl script
Run the tcl script and Compile the EDIF file in Quartus II
Simulate or Download the design on to the DE2 board
| Hardware & Software | Development | Demonstration | Summary |
15
Difficulties
Timing of the RAM
Using the SRAM as a frame buffer
24-bit colour – 921600 byte
640x480 16-bit colour – 614400 byte
640x480 8-bit grayscale – 307200 byte
640x480
Storing a raw image in the 1M-byte Flash
memory
| Hardware & Software | Development | Demonstration | Summary |
16
Results
A library with the desired drivers
A detailed Manual and instructions
Sample codes
| Hardware & Software | Development | Demonstration | Summary |
17
Contents
Hardware & Software
Development
Demonstration
Summary
| Hardware & Software | Development | Demonstration | Summary |
18
Contents
Hardware & Software
Development
Demonstration
Summary
| Hardware & Software | Development | Demonstration | Summary |
19
Future Development
Complete the development of drivers for
the DE2 board
Portable between Devices
Useful functions
Image
processing
FIFO for the SDRAM
| Hardware & Software | Development | Demonstration | Summary |
20
Achievements
FPGA design framework
Program
in Handel-C
Hardware synthesis in Quartus II
A library targeting the DE2 system
Drivers:
PS/2, RAM, VGA
Interface with VHDL components
| Hardware & Software | Development | Demonstration | Summary |
21