... | ... | @@ -182,8 +182,142 @@ gtkwave wave.vcd & |
|
|
|
|
|

|
|
|
|
|
|
## STEP5 (optional):pre-synthesize simulation
|
|
|
|
|
|
Add FPGA macro cell/primitive models to verify if it will work fine with FPGA implementation.
|
|
|
|
|
|
# TASK1
|
|
|
find `prim_sim.v` at `/where_your_gowin_installed/gowin_ide/IDE/simlib/gw2a/`
|
|
|
|
|
|
It should look like this:
|
|
|
|
|
|

|
|
|
|
|
|
## STEP6: Create a FPGA project, add PIN/Timing constraints, and synthesize design
|
|
|
|
|
|
Refer to:
|
|
|
|
|
|
[https://wiki.sipeed.com/hardware/en/tang/tang-primer-20k/primer-20k.html](https://wiki.sipeed.com/hardware/en/tang/tang-primer-20k/primer-20k.html)
|
|
|
|
|
|

|
|
|
|
|
|
When select device, choose "GW2A-LV18PG256C8/I7"
|
|
|
|
|
|

|
|
|
|
|
|
## STEP6: Create a FPGA project, add PIN/Timing constraints, and synthesize design
|
|
|
|
|
|

|
|
|
|
|
|
When adding source files, choose **NOT** to copy files into source directory.
|
|
|
|
|
|

|
|
|
|
|
|
Add new physical constraints file into project to define PINs
|
|
|
|
|
|

|
|
|
|
|
|
Edit “.cst” file to add PINs map info
|
|
|
|
|
|
```
|
|
|
//Refer to Sipeed Tang Primer 20K
|
|
|
//define location of signals
|
|
|
IO_LOC “clk_in” H11;
|
|
|
IO_LOC “rst_n” C7; //Key_5 on Primer 20K
|
|
|
|
|
|
//define I/O level property
|
|
|
IO_PORT “clk_in” IO_TYPE=LVCMOS33;
|
|
|
IO_PORT “rst _n” IO_TYPE=LVCMOS33;
|
|
|
|
|
|
//define I/O pull-up/down property
|
|
|
IO_PORT “clk_in” PULL_MODE=UP;
|
|
|
IO_PORT “rst _n” PULL_MODE=UP;
|
|
|
|
|
|
```
|
|
|
|
|
|
If you have a multiple module project, you need to designate “TOP MODULE” in Hierarchy tab before synthesize
|
|
|
|
|
|

|
|
|
|
|
|
## STEP7(optional): Post synthesize simulation
|
|
|
|
|
|

|
|
|
|
|
|
Right click “Place & Route”, select “Configuration”, modify “Generate Post-PnR Verilog Simulation Model file” to “True” to ask GW_IDE to generate post PnR model
|
|
|
|
|
|

|
|
|
|
|
|
## STEP7(optional): Post synthesize simulation
|
|
|
|
|
|
After finished PnR, the post-synthesize model called “*.vo” should be found under
|
|
|
“/prj/your_project_name/impl/pnr” folder
|
|
|
|
|
|

|
|
|
|
|
|
The file should look like this
|
|
|
|
|
|

|
|
|
|
|
|
Substitute your original module file with this file in “run_sim.sh” . There is no need to copy, just modify the file path in script
|
|
|
|
|
|
## STEP8: Place and Route
|
|
|
|
|
|

|
|
|
|
|
|
## STEP9: Download bitstream
|
|
|
|
|
|
### 1. Connect board with USB type-C data cable.
|
|
|
|
|
|
### 2. If you have installed openFPGALoader, try detecting board with:
|
|
|
|
|
|
```shell
|
|
|
openFPGALoader --detect
|
|
|
```
|
|
|
The result should look like this:
|
|
|
|
|
|

|
|
|
|
|
|
### 3. Enter the folder where *.fs file is, run following command
|
|
|
|
|
|
```shell
|
|
|
openFPGALoader –b tangprimer20k your_design.fs
|
|
|
```
|
|
|
**NOTE: as design always changes, there is no need to download into FLASH, DO NOT add “-f” param.**
|
|
|
|
|
|
## STEP10: Function validation
|
|
|
|
|
|
---
|
|
|
|
|
|
# TASK1:
|
|
|
|
|
|
**Using Sipeed Tang Primer 20K to implement running LEDs.**
|
|
|
|
|
|
## TIPS:
|
|
|
|
|
|
- Find LED pins from dock schematics
|
|
|
- Using FPGA internal OSC
|
|
|
refer to: [https://www.gowinsemi.com/upload/database_doc/1844/document/65c0a2ec8d029.pdf](https://www.gowinsemi.com/upload/database_doc/1844/document/65c0a2ec8d029.pdf)
|
|
|
|
|
|
before simulating, copy prim_sim.v from “/where_your_gowin_installed/gowin_ide/IDE/simlib/gw2a/” folder to your “/sim” folder.
|
|
|
|
|
|
**NOTE that we need a very low frequency clock, design a clock divider to generate 1Hz clock**
|
|
|
|
|
|
- Sipeed examples for light an LED
|
|
|
[https://wiki.sipeed.com/hardware/en/tang/tang-nano-20k/example/led.html](https://wiki.sipeed.com/hardware/en/tang/tang-nano-20k/example/led.html)
|
|
|
|
|
|
|
|
|
# TASK2
|
|
|
|
|
|
**Connect 4-digit LED segment display to Sipeed Tang Primer 20K board to implement a counter increasing every 1 second.**
|
|
|
|
|
|
## TIPS:
|
|
|
|
|
|
### 1. Add a 220 Ohm resistor in serial between LED segment display and FPGA pins, to limit current through LEDs.
|
|
|
|
|
|

|
|
|
|
|
|
### 2. How to identify PINs
|
|
|
|
|
|

|
|
|
|
|
|
### 3. As the “digit select” signal (CC pins on LED segment display) should switch around at about 100Hz, an additional 400Hz clock signal should be given by system.
|
|
|
|
|
|
# TASK2 |