FPGA笔记[1]-在macOS烧录码流到开发板

摘要

在macOS使用oss-cad-suite工具烧录fs码流到Sipeed-Tang-Primer-20k开发板.

关键信息

  • 系统macOS 14.4.1,Apple Silicon M2
  • 开发板:Sipeed-Tang-Primer-20k
  • FPGA芯片:GW2A-LV18PG256C8/I7(GW2A-18C-PBGA256)

原理简介

oss-cad-suite工具链简介

[https://gitcode.com/YosysHQ/oss-cad-suite-build/overview]
一个开源的数字逻辑设计软件套件,包含 RTL 合成、形式化硬件验证、FPGA 编程等工具,适合硬件开发和集成电路设计的工程师。

  • Yosys RTL synthesis with extensive Verilog 2005 support
  • Amaranth refreshed Python toolbox for building complex digital hardware
  • Migen Python toolbox for building complex digital hardware
  • ABC A System for Sequential Synthesis and Verification
  • GHDL VHDL 2008/93/87 simulator (linux-x64 and darwin-x64 platforms only)

Mac 开发Gowin FPGA简介

[https://blog.csdn.net/qq_33919450/article/details/130812566]
计算机械执行各种指令的本质是给一系列逻辑单元的引脚通电,然后经过逻辑电路之后输出新的电路信号。从软件的层面来说,每个引脚的输入就是一个常见到的一串二进制数字(比如01011101010)中的一位(一般使用的正逻辑中,1表示高电平,0表示低电平),早期的打孔板就是实体版的这种二进制数字。也就是说,最终我们需要的是一个存放二进制指令的文件,然后由 FPGA 执行。
开发 FPGA 就是编写两个文件:.v文件和.cst文件

  • .v文件里存放的是 Verilog 语言的代码,用来连接电路中的各种门、寄存器,以及一些硬 IP(hard intellectual property)。
  • .cst文件里存放的是引脚约束文件,用来表示 FPGA 开发板上每个引脚的作用和电压。

然后再通过一些工具,最后将其转换成存放了一堆位(bit)的文件,称之为比特流文件,来控制各部分的连接、工作等。

实现

  1. 安装oss-cad-suite
    [https://github.com/YosysHQ/oss-cad-suite-build/releases/latest]
    可选下载:
oss-cad-suite-darwin-arm64-20240516.tgz
358 MB
oss-cad-suite-darwin-x64-20240516.tgz
382 MB
oss-cad-suite-linux-arm64-20240516.tgz
498 MB
oss-cad-suite-linux-x64-20240516.tgz
574 MB
oss-cad-suite-windows-x64-20240516.exe
267 MB
Source code
(zip)
Source code
(tar.gz)

我用夸克网盘分享了「oss-cad-suite_darwin_arm64.zip」,点击链接即可保存。
链接:[https://pan.quark.cn/s/bd7fffd1c878]
提取码:fSU8

然后:

# 解压到/Applications文件夹
echo 'export PATH=$PATH:/Applications/oss-cad-suite/bin' >> ~/.zshrc
source ~/.zshrc
# 或者仅安装Gowin相关工具
pip3 install -i https://pypi.tuna.tsinghua.edu.cn/simple apycula 
  1. 烧录码流到开发板
    [https://gitcode.com/sipeed/TangPrimer-20K-example/blob/main/Litex/sipeed_tang_primer_20k.fs]
使能底板
wget https://raw.gitcode.com/sipeed/TangPrimer-20K-example/raw/main/Litex/sipeed_tang_primer_20k.fs
openFPGALoader -b tangprimer20k sipeed_tang_primer_20k_litex.fs

输出:

empty
Jtag frequency : requested 6.00MHz   -> real 6.00MHz  
Parse file Parse sipeed_tang_primer_20k_litex.fs: 
Done
DONE
Load SRAM: [==================================================] 100.00%
Done
DONE

效果

流水灯
posted @ 2024-05-16 18:00  qsBye  阅读(20)  评论(0编辑  收藏  举报