2022-11-11 22:42:06 -05:00
|
|
|
# Makefile for tests and hardware verification.
|
|
|
|
|
2023-03-15 14:30:08 -04:00
|
|
|
.PHONY: test clean codegen all
|
|
|
|
|
|
|
|
all: test codegen
|
2022-11-21 21:41:50 -05:00
|
|
|
|
|
|
|
####### Tests ########
|
|
|
|
|
2022-11-11 22:42:06 -05:00
|
|
|
COMMON_CPP = control_loop_math_implementation.cpp
|
|
|
|
COMMON= ${COMMON_CPP} control_loop_math_implementation.h
|
2023-03-15 14:30:08 -04:00
|
|
|
control_loop_math_verilog = control_loop_math.v boothmul.v intsat.v sign_extend.v
|
2022-11-11 22:42:06 -05:00
|
|
|
|
2022-11-13 18:03:55 -05:00
|
|
|
CONSTS_FRAC=43
|
2022-11-18 19:27:29 -05:00
|
|
|
E_WID=21
|
2022-11-11 22:42:06 -05:00
|
|
|
|
2022-11-21 21:41:50 -05:00
|
|
|
test: obj_dir/Vcontrol_loop_sim_top obj_dir/Vcontrol_loop_math
|
|
|
|
# obj_dir/Vcontrol_loop_math
|
2022-11-11 22:42:06 -05:00
|
|
|
|
2022-11-13 18:03:55 -05:00
|
|
|
obj_dir/Vcontrol_loop_math.mk: control_loop_math_sim.cpp ${COMMON} \
|
2023-03-15 14:30:08 -04:00
|
|
|
${control_loop_math_verilog}
|
2022-11-11 22:42:06 -05:00
|
|
|
verilator --cc --exe -Wall --trace --trace-fst \
|
2022-11-13 18:03:55 -05:00
|
|
|
--top-module control_loop_math \
|
|
|
|
-GCONSTS_FRAC=${CONSTS_FRAC} -DDEBUG_CONTROL_LOOP_MATH \
|
|
|
|
-CFLAGS -DCONSTS_FRAC=${CONSTS_FRAC} \
|
|
|
|
-CFLAGS -DE_WID=${E_WID} \
|
|
|
|
control_loop_math.v control_loop_math_sim.cpp ${COMMON_CPP}
|
|
|
|
|
|
|
|
obj_dir/Vcontrol_loop_math: obj_dir/Vcontrol_loop_math.mk
|
|
|
|
cd obj_dir && make -f Vcontrol_loop_math.mk
|
2022-11-11 22:42:06 -05:00
|
|
|
|
2022-11-21 21:41:50 -05:00
|
|
|
obj_dir/Vcontrol_loop_sim_top.mk: control_loop_sim.cpp ${COMMON} \
|
|
|
|
adc_sim.v dac_sim.v \
|
|
|
|
../spi/spi_master_ss.v \
|
|
|
|
../spi/spi_slave_no_write.v \
|
2023-03-15 14:30:08 -04:00
|
|
|
control_loop_sim_top.v control_loop_sim_top.v \
|
|
|
|
control_loop_cmds.vh control_loop.v \
|
|
|
|
${control_loop_math_verilog}
|
2022-11-21 21:41:50 -05:00
|
|
|
verilator --cc --exe -Wall --trace --trace-fst \
|
|
|
|
--top-module control_loop_sim_top \
|
|
|
|
-GCONSTS_FRAC=${CONSTS_FRAC} \
|
|
|
|
-CFLAGS -DCONSTS_FRAC=${CONSTS_FRAC} \
|
|
|
|
-CFLAGS -DE_WID=${E_WID} -I../spi \
|
|
|
|
control_loop_sim_top.v control_loop.v control_loop_sim.cpp \
|
|
|
|
${COMMON_CPP} adc_sim.v dac_sim.v ../spi/spi_master_ss.v \
|
|
|
|
../spi/spi_slave_no_read.v ../spi/spi_slave.v
|
|
|
|
obj_dir/Vcontrol_loop_sim_top: obj_dir/Vcontrol_loop_sim_top.mk control_loop_cmds.h
|
|
|
|
cd obj_dir && make -f Vcontrol_loop_sim_top.mk
|
|
|
|
|
|
|
|
####### Codegen ########
|
|
|
|
|
2023-03-15 14:30:08 -04:00
|
|
|
include ../common.makefile
|
2023-05-11 14:36:49 -04:00
|
|
|
CODEGEN_FILES=control_loop_cmds.h boothmul_preprocessed.v control_loop_math.v control_loop.v control_loop_cmds.vh
|
2023-03-15 17:08:55 -04:00
|
|
|
codegen: ${CODEGEN_FILES}
|
2023-03-15 14:30:08 -04:00
|
|
|
control_loop_cmds.vh: control_loop_cmds.m4
|
|
|
|
m4 -P control_loop_cmds.vh.m4 > control_loop_cmds.vh
|
|
|
|
control_loop_cmds.h: control_loop_cmds.m4
|
2022-11-21 21:41:50 -05:00
|
|
|
echo '#pragma once' > control_loop_cmds.h
|
2023-03-15 14:30:08 -04:00
|
|
|
m4 -P control_loop_cmds.h.m4 >> control_loop_cmds.h
|
2023-03-15 17:08:55 -04:00
|
|
|
|
|
|
|
clean:
|
|
|
|
rm -rf obj_dir *.fst ${CODEGEN_FILES}
|