安装依赖
sudo apt-get install build-essential clang bison flex libreadline-dev \
gawk tcl-dev libffi-dev git mercurial graphviz \
xdot pkg-config python python3 libftdi-dev \
qt5-default python3-dev libboost-all-dev cmake libeigen3-dev
#Installing the IceStorm Tools (icepack, icebox, iceprog, icetime, chip databases):
git clone https://github.com/cliffordwolf/icestorm.git icestorm
cd icestorm
make -j$(nproc)
sudo make install
#Installing Arachne-PNR (place&route tool, predecessor to NextPNR):
git clone https://github.com/cseed/arachne-pnr.git arachne-pnr
cd arachne-pnr
make -j$(nproc)
sudo make install
#Installing NextPNR (place&route tool, Arachne-PNR replacement):
sudo apt-get install libeigen3-dev
git clone https://github.com/YosysHQ/nextpnr nextpnr
cd nextpnr
cmake . -DARCH=ice40 -DCMAKE_INSTALL_PREFIX=/usr/local
make -j$(nproc)
sudo make install
#Installing Yosys (Verilog synthesis):
git clone https://github.com/cliffordwolf/yosys.git yosys
cd yosys
make config-clang
make config-gcc
make -j$(nproc)
sudo make install
中国本地 icesugar
https://gitee.com/xiaoerlang0359/icesugar?_from=gitee_search
$sudo apt-get install libhidapi-dev
$sudo apt-get install libusb-1.0-0-dev
$ yosys -p "synth_ice40 -blif test.blif" led.v
$ arachne-pnr -d 5k -P sg48 -p led.pcf led.blif -o led.txt
$ icepack led.txt led.bin
$ iceprog led.bin
Makefile
# Makefile if条件语句内的语句每行尾要加分号";" 但后台运行的语句除外
filename=led
ICELINK_DIR=$(shell df | grep iCELink | awk '{print $$6}')
$(filename).bin:$(filename).txt
icepack $(filename).txt $(filename).bin
$(filename).txt:$(filename).pcf $(filename).blif
arachne-pnr -d 5k -P sg48 -p $(filename).pcf $(filename).blif -o $(filename).txt
$(filename).blif:$(filename).v
yosys -p "synth_ice40 -blif $(filename).blif" $(filename).v
write:
@if [ -d '$(ICELINK_DIR)' ]; \
then \
cp $(filename).bin $(ICELINK_DIR); \
else \
echo "iCELink not found"; \
exit 1; \
fi
//icesprog -o 0x100000 $(filename).bin
test:
iverilog $(filename).v $(filename)_test.v -o $(filename)_test.out #也可以使用`include "xxx.v" 包含多个文件
./$(filename)_test.out
@if [ -f "$(filename)_test.vcd" ]; \
then \
gtkwave $(filename)_test.vcd $(filename)_test.gtkw & \
else \
echo "$(filename)_test.vcd 未找到。"; \
fi
使用Makefile
make #生成bin文件
make write #烧写bin文件
make test #模拟验证
#查看FPGA逻辑电路连接情况
#nextpnr-ice40 --up5k --pcf led.pcf --asc led.txt --gui
sudo apt install libboost-python1.65.1
sudo apt install libboost-program-options1.65.1
#打开Makefile并把第1行使用filename=prescaler内容替换
sed -i '1c filename=prescaler' Makefile