... | ... | @@ -182,8 +182,142 @@ gtkwave wave.vcd & |
|
|
|
|
|
![image](uploads/fd8d1d16546e1aa235390032451299e8/image.png)
|
|
|
|
|
|
## 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:
|
|
|
|
|
|
![image](uploads/f221844edf5de1e4d9774fbb0693c986/image.png)
|
|
|
|
|
|
## 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)
|
|
|
|
|
|
![image](uploads/3ccba74943c3fc18bd0fb283e00b3104/image.png)
|
|
|
|
|
|
When select device, choose "GW2A-LV18PG256C8/I7"
|
|
|
|
|
|
![image](uploads/2c4dee9471eb46415313c6e2fa4cc18a/image.png)
|
|
|
|
|
|
## STEP6: Create a FPGA project, add PIN/Timing constraints, and synthesize design
|
|
|
|
|
|
![image](uploads/5d31c29362e399de0b41886d4bf70a9e/image.png)
|
|
|
|
|
|
When adding source files, choose **NOT** to copy files into source directory.
|
|
|
|
|
|
![image](uploads/ad5df28daf447bf9144e43e559cf7104/image.png)
|
|
|
|
|
|
Add new physical constraints file into project to define PINs
|
|
|
|
|
|
![image](uploads/9010d00290391f46605f606da673d4cf/image.png)
|
|
|
|
|
|
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
|
|
|
|
|
|
![image](uploads/27d34cdb15de47bf0a1f162b42a207b7/image.png)
|
|
|
|
|
|
## STEP7(optional): Post synthesize simulation
|
|
|
|
|
|
![image](uploads/fb64dfaa252db239f663052c3401f286/image.png)
|
|
|
|
|
|
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
|
|
|
|
|
|
![image](uploads/722517fac72c47ad550de26e25415f94/image.png)
|
|
|
|
|
|
## 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
|
|
|
|
|
|
![image](uploads/ac32724bbe0ca97b69eef695303f90d1/image.png)
|
|
|
|
|
|
The file should look like this
|
|
|
|
|
|
![image](uploads/175e00f0e1941dea876d571eb00e96a2/image.png)
|
|
|
|
|
|
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
|
|
|
|
|
|
![image](uploads/f6c217d2ac93bb002d9abfe930e635eb/image.png)
|
|
|
|
|
|
## 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:
|
|
|
|
|
|
![image](uploads/d8213c6ae8c9b80d673bb5046beb4492/image.png)
|
|
|
|
|
|
### 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.
|
|
|
|
|
|
![image](uploads/4c0a17773920b40515b3d58ba0992c1f/image.png)
|
|
|
|
|
|
### 2. How to identify PINs
|
|
|
|
|
|
![image](uploads/543d4adb17f8ba305257a59d0b21bf0c/image.png)
|
|
|
|
|
|
### 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 |