Skip to content

Commit a08bd26

Browse files
fabric_files:template_vhdl: Fix VHDL simulation and synthesis + add Makefile.
Fix the broken VHDL simulation and VHDL user design synthesis. Replace old simulation scripts with a Makefile. Add README for `Test`. Add .gitignore in `Test`. Update testbench, user_design and top_wrapper for simulation. Remove old floorplaning information from fabric.csv Signed-off-by: Jonas K. <[email protected]>
1 parent 7f1d7d0 commit a08bd26

File tree

10 files changed

+389
-149
lines changed

10 files changed

+389
-149
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
load_fabric
2+
run_FABulous_fabric
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1+
tmp
2+
build
13
*.csv
24
*.fasm
35
*.json
46
*.bit
57
*.bin
68
*.txt
79
*.vh
8-
*.vhd
910
*.hex
1011
*.cf
1112
*.vcd
Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
MAX_BITBYTES=16384
2+
FAB_PROJ_ROOT=..
3+
BUILD_DIR=build
4+
DESIGN=sequential_16bit_en
5+
TESTBENCH=${DESIGN}_tb
6+
TOP_WRAPPER=top_wrapper
7+
8+
USER_DESIGN_DIR=${FAB_PROJ_ROOT}/user_design
9+
USER_DESIGN_VHDL=${USER_DESIGN_DIR}/${DESIGN}.vhdl
10+
TOP_WRAPPER_VERILOG=${USER_DESIGN_DIR}/${TOP_WRAPPER}.v # Still needs to be verilog, since it is more like a constraint file for yosys
11+
FAB_TILE_FOLDER=${FAB_PROJ_ROOT}/Tile
12+
FAB_FABRIC_FOLDER=${FAB_PROJ_ROOT}/Fabric
13+
14+
GHDL=ghdl
15+
GHDL_FLAGS=--std=08 -O2 --workdir=${BUILD_DIR}
16+
17+
.PHONY: all run_FABulous_demo full build_test_design run_simulation mkdir_build clean
18+
19+
sim: build_test_design run_simulation clean
20+
21+
full_sim: run_FABulous_demo build_test_design run_simulation clean
22+
23+
build_test_design: run_yosys run_nextpnr run_bitgen
24+
25+
run_FABulous_demo:
26+
# Runs FABulous, generates the default fabric.
27+
FABulous ${FAB_PROJ_ROOT} -fs ${FAB_PROJ_ROOT}/FABulous.tcl
28+
29+
run_yosys: mkdir_build
30+
yosys -m ghdl -p "ghdl ${USER_DESIGN_VHDL} -e ${DESIGN}; read_verilog ${TOP_WRAPPER_VERILOG}; synth_fabulous -top ${TOP_WRAPPER} -json ${BUILD_DIR}/${DESIGN}.json;"
31+
32+
run_nextpnr: mkdir_build
33+
FAB_ROOT=${FAB_PROJ_ROOT} nextpnr-generic --uarch fabulous --json ${BUILD_DIR}/${DESIGN}.json -o fasm=${BUILD_DIR}/${DESIGN}.fasm
34+
35+
run_bitgen: mkdir_build
36+
bit_gen -genBitstream ${BUILD_DIR}/${DESIGN}.fasm ${FAB_PROJ_ROOT}/.FABulous/bitStreamSpec.bin ${BUILD_DIR}/${DESIGN}.bin
37+
python3 makehex.py ${BUILD_DIR}/${DESIGN}.bin ${MAX_BITBYTES} ${BUILD_DIR}/${DESIGN}.hex
38+
39+
mkdir_build:
40+
mkdir -p ${BUILD_DIR}
41+
42+
run_GTKWave:
43+
gtkwave ${BUILD_DIR}/${DESIGN}.fst
44+
45+
clean:
46+
rm -rf ${BUILD_DIR}
47+
48+
run_simulation: mkdir_build
49+
ulimit -s unlimited && \
50+
${GHDL} -a ${GHDL_FLAGS} ${FAB_FABRIC_FOLDER}/my_lib.vhdl && \
51+
${GHDL} -a ${GHDL_FLAGS} ${FAB_TILE_FOLDER}/LUT4AB/LUT4AB_switch_matrix.vhdl \
52+
${FAB_TILE_FOLDER}/LUT4AB/LUT4AB_ConfigMem.vhdl \
53+
${FAB_TILE_FOLDER}/LUT4AB/LUT4c_frame_config.vhdl \
54+
${FAB_TILE_FOLDER}/LUT4AB/MUX8LUT_frame_config.vhdl \
55+
${FAB_TILE_FOLDER}/LUT4AB/LUT4AB.vhdl && \
56+
${GHDL} -a ${GHDL_FLAGS} ${FAB_TILE_FOLDER}/RAM_IO/RAM_IO_switch_matrix.vhdl \
57+
${FAB_TILE_FOLDER}/RAM_IO/RAM_IO_ConfigMem.vhdl \
58+
${FAB_TILE_FOLDER}/RAM_IO/InPass4_frame_config.vhdl \
59+
${FAB_TILE_FOLDER}/RAM_IO/OutPass4_frame_config.vhdl \
60+
${FAB_TILE_FOLDER}/RAM_IO/RAM_IO.vhdl && \
61+
${GHDL} -a ${GHDL_FLAGS} ${FAB_TILE_FOLDER}/RegFile/RegFile_switch_matrix.vhdl \
62+
${FAB_TILE_FOLDER}/RegFile/RegFile_ConfigMem.vhdl \
63+
${FAB_TILE_FOLDER}/RegFile/RegFile_32x4.vhdl \
64+
${FAB_TILE_FOLDER}/RegFile/RegFile.vhdl && \
65+
${GHDL} -a ${GHDL_FLAGS} ${FAB_TILE_FOLDER}/W_IO/W_IO_switch_matrix.vhdl \
66+
${FAB_TILE_FOLDER}/W_IO/W_IO_ConfigMem.vhdl \
67+
${FAB_TILE_FOLDER}/W_IO/IO_1_bidirectional_frame_config_pass.vhdl \
68+
${FAB_TILE_FOLDER}/W_IO/Config_access.vhdl \
69+
${FAB_TILE_FOLDER}/W_IO/W_IO.vhdl && \
70+
${GHDL} -a ${GHDL_FLAGS} ${FAB_TILE_FOLDER}/DSP/DSP_top/DSP_top_switch_matrix.vhdl \
71+
${FAB_TILE_FOLDER}/DSP/DSP_top/DSP_top_ConfigMem.vhdl \
72+
${FAB_TILE_FOLDER}/DSP/DSP_top/DSP_top.vhdl && \
73+
${GHDL} -a ${GHDL_FLAGS} ${FAB_TILE_FOLDER}/DSP/DSP_bot/DSP_bot_switch_matrix.vhdl \
74+
${FAB_TILE_FOLDER}/DSP/DSP_bot/DSP_bot_ConfigMem.vhdl \
75+
${FAB_TILE_FOLDER}/DSP/DSP_bot/MULADD.vhdl \
76+
${FAB_TILE_FOLDER}/DSP/DSP_bot/DSP_bot.vhdl && \
77+
${GHDL} -a ${GHDL_FLAGS} ${FAB_TILE_FOLDER}/DSP/DSP_top/DSP_top.vhdl \
78+
${FAB_TILE_FOLDER}/DSP/DSP_bot/DSP_bot.vhdl \
79+
${FAB_TILE_FOLDER}/DSP/DSP.vhdl && \
80+
${GHDL} -a ${GHDL_FLAGS} ${FAB_TILE_FOLDER}/N_term_DSP/N_term_DSP_switch_matrix.vhdl \
81+
${FAB_TILE_FOLDER}/N_term_DSP/N_term_DSP.vhdl && \
82+
${GHDL} -a ${GHDL_FLAGS} ${FAB_TILE_FOLDER}/S_term_DSP/S_term_DSP_switch_matrix.vhdl \
83+
${FAB_TILE_FOLDER}/S_term_DSP/S_term_DSP.vhdl && \
84+
${GHDL} -a ${GHDL_FLAGS} ${FAB_TILE_FOLDER}/N_term_RAM_IO/N_term_RAM_IO_switch_matrix.vhdl \
85+
${FAB_TILE_FOLDER}/N_term_RAM_IO/N_term_RAM_IO.vhdl && \
86+
${GHDL} -a ${GHDL_FLAGS} ${FAB_TILE_FOLDER}/S_term_RAM_IO/S_term_RAM_IO_switch_matrix.vhdl \
87+
${FAB_TILE_FOLDER}/S_term_RAM_IO/S_term_RAM_IO.vhdl && \
88+
${GHDL} -a ${GHDL_FLAGS} ${FAB_TILE_FOLDER}/N_term_single/N_term_single_switch_matrix.vhdl \
89+
${FAB_TILE_FOLDER}/N_term_single/N_term_single.vhdl && \
90+
${GHDL} -a ${GHDL_FLAGS} ${FAB_TILE_FOLDER}/S_term_single/S_term_single_switch_matrix.vhdl \
91+
${FAB_TILE_FOLDER}/S_term_single/S_term_single.vhdl && \
92+
${GHDL} -a ${GHDL_FLAGS} ${FAB_TILE_FOLDER}/N_term_single2/N_term_single2_switch_matrix.vhdl \
93+
${FAB_TILE_FOLDER}/N_term_single2/N_term_single2.vhdl && \
94+
${GHDL} -a ${GHDL_FLAGS} ${FAB_TILE_FOLDER}/S_term_single2/S_term_single2_switch_matrix.vhdl \
95+
${FAB_TILE_FOLDER}/S_term_single2/S_term_single2.vhdl && \
96+
${GHDL} -a ${GHDL_FLAGS} ${FAB_FABRIC_FOLDER}/config_UART.vhdl && \
97+
${GHDL} -a ${GHDL_FLAGS} ${FAB_FABRIC_FOLDER}/bitbang.vhdl && \
98+
${GHDL} -a ${GHDL_FLAGS} ${FAB_FABRIC_FOLDER}/ConfigFSM.vhdl && \
99+
${GHDL} -a ${GHDL_FLAGS} ${FAB_FABRIC_FOLDER}/eFPGA_Config.vhdl && \
100+
${GHDL} -a ${GHDL_FLAGS} ${FAB_FABRIC_FOLDER}/Frame_Data_Reg.vhdl && \
101+
${GHDL} -a ${GHDL_FLAGS} ${FAB_FABRIC_FOLDER}/Frame_Select.vhdl && \
102+
${GHDL} -a ${GHDL_FLAGS} ${FAB_FABRIC_FOLDER}/BlockRAM_1KB.vhdl && \
103+
${GHDL} -a ${GHDL_FLAGS} ${FAB_FABRIC_FOLDER}/eFPGA.vhdl && \
104+
${GHDL} -a ${GHDL_FLAGS} ${FAB_FABRIC_FOLDER}/eFPGA_top.vhdl && \
105+
${GHDL} -a ${GHDL_FLAGS} ${USER_DESIGN_DIR}/${DESIGN}.vhdl && \
106+
${GHDL} -a ${GHDL_FLAGS} ${TESTBENCH}.vhdl && \
107+
${GHDL} -e ${GHDL_FLAGS} -fexplicit ${TESTBENCH} && \
108+
${GHDL} -r ${GHDL_FLAGS} ${TESTBENCH} --stats --ieee-asserts=disable --fst=${BUILD_DIR}/${TESTBENCH}.fst
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# FABulous simulation
2+
3+
This assumes FABulous is installed properly and the default instructions were followed to build the default fabric.
4+
FABulous provides a simulation environment to test the fabric and the bitstream generated for it.
5+
For simple use cases, there is the `run_simulation command` in the FABulous shell.
6+
For more complex use cases it can be useful to create an own flow, like the following example `make` based flow.
7+
8+
9+
Please make sure to use recent versions of (Yosys)[https://github.com/YosysHQ/yosys], (nextpnr-generic)[https://github.com/YosysHQ/nextpnr] (_not_ the old FABulous nextpnr fork)
10+
and (ghdl)[https://github.com/ghdl/ghdl] or use the (OSS-CAD-Suite)[https://github.com/YosysHQ/oss-cad-suite-build] which provides nightly builds of the necessary dependencies.
11+
12+
Also, make sure you have the `make` package installed:
13+
```
14+
$ sudo apt-get install make
15+
```
16+
17+
Type `make build_test_design` to create the bitstream and `make run_simulation` to compare a simulation
18+
of the fabric running the bitstream against the design.
19+
20+
Other useful make targets are:
21+
- `make` or `make sim` to build the bitstream, run simulation and remove all generated files afterward.
22+
- `make clean` to remove all generated files
23+
- `make build_test_design` to build the bitstream
24+
- `make run_simulation` to run the simulation
25+
- `make run_FABulous_demo` to run the default FABulous flow
26+
- `make run_GTKWave` to run the GTKWave waveform viewer with the generated simulation waveform
27+
28+
Take a look into the Makefile to build your own flow.

FABulous/fabric_files/FABulous_project_template_vhdl/Test/build_test_design.sh

Lines changed: 0 additions & 11 deletions
This file was deleted.

FABulous/fabric_files/FABulous_project_template_vhdl/Test/run_simulation_vhdl.sh

Lines changed: 0 additions & 114 deletions
This file was deleted.

0 commit comments

Comments
 (0)