ICE51 IP核模拟记录

上文提到了51内核ICE51(https://github.com/ashleyjr/ice51.git)

本文就来看看怎么编译C程序,仿真模拟运行在该IP软核上:

环境:MingW32、iverilog、yosys、arachne-pnr、icestorm(icetime)等

 

软核布线:(synth脚本)

#!/bin/bash
echo "========================================================"
echo "Running synth..."
rm -f syn.log
yosys -p 'synth_ice40 -top ice51_top -blif ice51.blif' rtl/ice51_top.v rtl/ice51.v rtl/mem_512x8b.v > syn.log
cat syn.log | grep -A20 statistics
echo "========================================================"
echo "Running place and route..."
rm -f blif.log
yosys -o ice51.syn.v ice51.blif > blif.log
arachne-pnr -d 5k -w etc/ice51.pcf ice51.blif -o ice51.asc 
echo "========================================================"
echo "Running Timing check..."
icetime -tmd hx1k ice51.asc > ice51.time
cat ice51.time | grep -A20 "Total path delay"

编译仿真:(run脚本)

#!/bin/bash
CMD="cd verif/src"
echo $CMD
$CMD

CMD="make"
echo $CMD
$CMD

CMD="cd ../.."
echo $CMD
$CMD

PRELOAD="preload"
if [[ "$2" == "$PRELOAD" ]]; then
   P_PRELOAD=" -D PRELOAD"
fi

#
#./run all preload
#
# Run all tests add check for pass fail
ALL="all"
if [[ "$1" == "$ALL" ]]; then
   echo ""
   echo "--- Simulation begins ---"
   for filename in verif/src/*.c; do
      echo $filename 
      echo -n -e " >\t\t\t"
      ext=".hex"
      cp -f ${filename/\.c/$ext} load_mem.hex
      ext=".checks"
      cp -f ${filename/\.c/$ext} checks.hex
      iverilog -o ice51.dat -D SIM $P_PRELOAD -c etc/filelist.txt
      vvp ice51.dat -vcd | grep "PASSED\|ERROR" 
   done
   echo "--- Simulation ends ---"
   exit
fi

# Run a single test
ext=".hex"
CMD="cp -f verif/src/${1/\.c/}$ext load_mem.hex"
echo $CMD
$CMD

ext=".checks"
CMD="cp -f verif/src/${1/\.c/}$ext checks.hex"
echo $CMD
$CMD

CMD="iverilog -o ice51.dat -D SIM $P_PRELOAD -c etc/filelist.txt"
echo $CMD
$CMD

CMD="vvp ice51.dat -vcd > /dev/null 2>&1"
echo $CMD
$CMD 

# Load waves for a single test
WAVES="w"
if [ "$2" == "$WAVES" ] || [ "$3" == "$WAVES" ]; then
   CMD="gtkwave -S etc/signals.tcl ice51.vcd"
   echo $CMD
   $CMD
fi

准备好环境,分别执行1、synth 2、run

仿真结果如下:

ICE51 IP核模拟记录_第1张图片

ICE51 IP核模拟记录_第2张图片

ICE51 IP核模拟记录_第3张图片

运行仿真结果:

ICE51 IP核模拟记录_第4张图片

ICE51 IP核模拟记录_第5张图片

一个CPU就制作出来了,神奇不?

 

记住,山外有山,很多时候,不是自己笨,而是自己的眼界没有被打开!!!

 

 

你可能感兴趣的:(ice51,cpu,fpga,synth,sim,机器学习,芯片折腾)