Created
August 27, 2025 11:03
-
-
Save cyring/75eba6678a754a62c508bfa0fbd788b5 to your computer and use it in GitHub Desktop.
FPGA
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Tang Nano 20K |
Author
Author
Gowin for ArchLinux
Gowin IDE
- Register or Login at Gowin
- In Support download latest Education version for Linux: Gowin V1.9.11.03 Education (Linux x64)
- Untar the archive in
/opt/gowinfor two sub-directoriesIDEandProgrammer
mkdir /opt/gowin
cd /opt/gowin
tar -zxvf Gowin\_V1.9.11.03\_Education\_Linux.tar.gz- Set the
rootuser to the whole directory
chown -R root:root /opt/gowin- Make sure of the prerequisite packages:
pacman -S fontconfig freetype2 qt5-base- IDE is failing to start with a library issue. Remove it:
rm -i /opt/gowin/IDE/lib/libfreetype.so.6- Create a shell script to start the IDE with those environment variables.
For example:gowin.sh
nano ${HOME}/bin/gowin.shQT_QPA_PLATFORM_PLUGIN_PATH=/usr/lib/qt/plugins QT_QPA_PLATFORM=xcb QT_XCB_GL_INTEGRATION=none gw_ide "$@"
- Update your PATH, preferably in your session
.profile
PATH=$PATH:$HOME/bin:/opt/gowin/IDE/bin
- Add a desktop shortcut.
For example${HOME}/.local/share/applications/gowin-ide.desktop
[Desktop Entry]
Type=Application
Version=1.0
Name=Gowin FPGA Designer
Comment=Gowin IDE: FPGA Designer
Exec=gowin.sh %U
Path=/opt/gowin/IDE/
Categories=Development;- I'm using XFCE and I now have a
Gowin FPGA Designericon in theDevelopmentmenu to start the Gowin IDE
Gowin Programmer
1- Update the udev rules to let Programmer query the USB cable
cp -v /opt/gowin/Programmer/Driver/50-programmer_usb.rules /etc/udev/rules.d/2- In your session .profile add the Programmer path
PATH=$PATH:$HOME/bin:/opt/gowin/IDE/bin:/opt/gowin/Programmer/bin
3- Reboot the system to apply all those changes
4- Start the Gowin IDE and go to menu Tools > Programmer
- The cable should be detected with the following settings:
( if not go to Programmer menuEdit > Cable Setting > USB Cable Setting)
Cable [ USB Debugger A ]Port [ USB Debugger A/0/4129/null ]Frequency [ 2.5MHz ][x] using ftd2xx driver
6- Go to Programmer menu Edit > Configure Device and Save these settings:
Access Mode [ External Flash Mode ]Operation [ exFlash Erase,Program thru GAO-Bridge ]File name [ YourBitStream.fs ]Device [ Generic Flash ]Start Address [ 0x000000 ]
7- Now program the FPGA from menu Program/Configure
Litex
- Based on TangNano-20K-example
Build
- Go to the Litex directory
cd linux-on-litex-vexriscv
QT_QPA_PLATFORM_PLUGIN_PATH=/usr/lib/qt/plugins QT_QPA_PLATFORM=xcb QT_XCB_GL_INTEGRATION=none \
python -m litex_boards.targets.sipeed_tang_nano_20k --buildProgram
openFPGALoader -b tangnano20k -f build/sipeed_tang_nano_20k/gateware/sipeed_tang_nano_20k.fs empty
write to flash
Jtag frequency : requested 6.00MHz -> real 6.00MHz
Parse file Parse build/sipeed_tang_nano_20k/gateware/sipeed_tang_nano_20k.fs:
Done
DONE
after program flash: displayReadReg 00006020
Memory Erase
Done Final
Security Final
Erase SRAM DONE
Jtag probe limited to %d MHz6000000
Jtag frequency : requested 10.00MHz -> real 6.00MHz
JEDEC ID: 0xef4017
Detected: Winbond W25Q64 128 sectors size: 64Mb
JEDEC ID: 0xef4017
Detected: Winbond W25Q64 128 sectors size: 64Mb
RDSR : 0x00
WIP : 0
WEL : 0
BP : 0
TB : 0
SRWD : 0
00000000 00000000 00000000 00
start addr: 00000000, end_addr: 000e0000
Erasing: [==================================================] 100.00%
Done
Writing: [==================================================] 100.00%
Done
Author
Author
Gowin Analyzer Oscilloscope
TangNano-20K-example
- Clone the examples from the repository
git clone [email protected]:sipeed/TangNano-20K-example.gitFPGA Designer
- Start the Gowin FPGA Designer and load the project
TangNano-20K-example/led/blink_led/blink_led.gprj
Analyzer Oscilloscope
- Create a GAO Config File from menu
File > New > GAO Config File - Choose the default Setting:
[o] For RTL Design[o] Standard
- Keep the suggested GAO Name as
blink_led- and the sub-directory to
TangNano-20K-example/led/blink_led/src - button
[Next >]will addsrc/blink_led.raoto the current project
- and the sub-directory to
Signals
- Back to the Design tree, double click the GAO file
blink_led.rao
Trigger
- From the
Trigger Optionstab - Double click
Trigger Port 0 - Click
(+)to add a signal- Click
[Search]button to popup theNetswindow - Select
count_1s[23:0]and add it to the right panel with button[>] - Validate with
[OK] - You will get
count_1s[23:0]assigned to thePort 0
- Click
- In the middle column
Match Units, double click theM0- You are in the
Match Unit 0where you selectTrigger Port 0from the drop-down box - With
count_1s[23:0]selected, enter the decimal value13500000 - This matches condition in the Verilog code
blink_led.vwhere( count_1s < 27000000/2 ) - Validate with
[OK] - The match unit
[x] M0should be ticked
- You are in the
- In the right column, add an expression
- In the empty panel, right-click mouse button to choose menu
[Add] - In the Expression calculator, click button
M0 - Validate with
[OK] - Expression
M0should be listed
- In the empty panel, right-click mouse button to choose menu
Capture
- Choose the
Capture Optionstab - Click the 3-dots buttons to assign a sample clock
- In the
Netspopup window click[Search]to populate the left panel with signals - Select
clkand add it to the right panel with[>] button - In the
Capture Signalspanel add two signals[Search]forcount_1s[23:0]andcount_1s_flag- Click
[>]to add both to theCapture Signalspanel
Build
- The GAO is all set up, save it from menu
File > "Save blink_led.rao" - Back to the Process tree of the FPGA Designer, select
Place & Route - Right-click mouse button to choose
Clean&Rerun All - Accept to remove the previous results
Oscilloscope
- Plug the TN20K to the PC from its USB-C cable
- If
ftdi_siomodule present then unload it withsudo modprobe -r ftdi_sio - Choose menu
Tools > Gowin Analyzer Oscilloscope - You should see all settings made so far:
exp0: M0trigger expressionM0match unit condition
Program fs
- Tick option
[o] Enable Programmer - Select the row which targets the
GW2AR-18device - Click button to program the
TN20k - Once FPGA programmed, it will auto reset with the
blink_ledbitstream
...
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment


Litex for Tang Nano 20K
Prerequisities
ArchLinux
Prepare Litex
(1)
Build