You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

64 lines
2.5 KiB

  1. DESIGN_NAME := blink
  2. WORK_FILES := ../../lib/user_components.vhd ../rtl/blink.vhd
  3. GM_FILES := ../../lib/rtl_components.vhd
  4. GHDL_FLAGS := --std=08 --workdir=build -Pbuild
  5. YOSYSPIPE := -nomx8 -retime
  6. # ATTENTION: -luttree option seems to mis-synthesize the design, broken with synth_gatemate?
  7. PNRFLAGS := -om 2
  8. PNRTOOL := $(shell which p_r)
  9. .PHONY: all syn imp prog syn_sim imp_sim
  10. all: imp
  11. syn: ${DESIGN_NAME}.v
  12. imp: ${DESIGN_NAME}.bit
  13. build/work-obj08.cf: ${WORK_FILES} build/gatemate-obj08.cf
  14. ghdl -a ${GHDL_FLAGS} --work=work ${WORK_FILES}
  15. build/gatemate-obj08.cf: ${GM_FILES}
  16. mkdir -p build
  17. ghdl -a ${GHDL_FLAGS} --work=gatemate ${GM_FILES}
  18. # Synthesis target for implementation
  19. ${DESIGN_NAME}.v: build/work-obj08.cf
  20. ghdl --synth ${GHDL_FLAGS} ${DESIGN_NAME} > ${DESIGN_NAME}.vhd
  21. yosys -m ghdl -p 'ghdl ${GHDL_FLAGS} --warn-no-binding --no-formal ${DESIGN_NAME}; synth_gatemate -top $(DESIGN_NAME) ${YOSYSPIPE} -vlog $@' \
  22. 2>&1 | tee build/yosys-report.txt
  23. # Synthesis target for post-syn/post-imp simulation
  24. ${DESIGN_NAME}_sim.v: build/work-obj08.cf
  25. ghdl --synth ${GHDL_FLAGS} ${DESIGN_NAME} > ${DESIGN_NAME}.vhd
  26. yosys -m ghdl -p 'ghdl ${GHDL_FLAGS} -gSIM=1 --warn-no-binding --no-formal ${DESIGN_NAME}; synth_gatemate -top $(DESIGN_NAME) ${YOSYSPIPE} -vlog $@' \
  27. 2>&1 | tee build/yosys-report.txt
  28. # Implementation target for FPGA
  29. ${DESIGN_NAME}.bit: ${DESIGN_NAME}.v ${DESIGN_NAME}.ccf
  30. cd build && \
  31. ${PNRTOOL} -i ../${DESIGN_NAME}.v -o $@ --ccf ../${DESIGN_NAME}.ccf $(PNRFLAGS) \
  32. 2>&1 | tee p_r-report.txt && \
  33. mv ${DESIGN_NAME}*.bit ../$@
  34. # Implementation target for post-implementation simulation
  35. build/${DESIGN_NAME}_00.v: ${DESIGN_NAME}_sim.v ${DESIGN_NAME}.ccf
  36. cd build && \
  37. ${PNRTOOL} -i ../${DESIGN_NAME}_sim.v -o ${DESIGN_NAME}.v --ccf ../${DESIGN_NAME}.ccf $(PNRFLAGS) \
  38. 2>&1 | tee p_r-report.txt
  39. # Post-synthesis simulation target
  40. syn_sim: ${DESIGN_NAME}_sim.v
  41. iverilog -g2012 -o tb_${DESIGN_NAME}_syn.vvp ${DESIGN_NAME}_sim.v tb_${DESIGN_NAME}.v /usr/local/share/yosys/gatemate/cells_sim.v
  42. vvp -N tb_${DESIGN_NAME}_syn.vvp -fst
  43. # Post-implementation simulation target
  44. imp_sim: build/${DESIGN_NAME}_00.v
  45. iverilog -g2012 -o tb_${DESIGN_NAME}_imp.vvp build/${DESIGN_NAME}_00.v tb_${DESIGN_NAME}.v /opt/cc-toolchain-linux/bin/p_r/cpelib.v
  46. vvp -N tb_${DESIGN_NAME}_imp.vvp -fst
  47. # FPGA FW load per JTAG
  48. prog: ${DESIGN_NAME}.bit
  49. openFPGALoader -b gatemate_evb_jtag $<
  50. clean :
  51. echo "# Cleaning files"
  52. rm -rf build ${DESIGN_NAME}.v ${DESIGN_NAME}_sim.v ${DESIGN_NAME}.vhd ${DESIGN_NAME}.bit *.vvp *.fst