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.

51 lines
1.9 KiB

  1. DESIGN_NAME := uart_reg
  2. WORK_FILES := ../rtl/uart_ctrl.vhd ../rtl/uart_tx.vhd ../rtl/uart_rx.vhd ../rtl/uart_reg.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. yosys -m ghdl -p 'ghdl ${GHDL_FLAGS} --warn-no-binding --no-formal ${DESIGN_NAME}; synth_gatemate -top $(DESIGN_NAME) ${YOSYSPIPE} -vlog $@' \
  21. 2>&1 | tee build/yosys-report.txt
  22. # Implementation target for FPGA
  23. ${DESIGN_NAME}.bit: ${DESIGN_NAME}.v ${DESIGN_NAME}.ccf
  24. cd build && \
  25. ${PNRTOOL} -i ../${DESIGN_NAME}.v -o $@ --ccf ../${DESIGN_NAME}.ccf $(PNRFLAGS) \
  26. 2>&1 | tee p_r-report.txt && \
  27. mv ${DESIGN_NAME}*.bit ../$@
  28. # Post-synthesis simulation target
  29. syn_sim: ${DESIGN_NAME}.v
  30. iverilog -g2012 -o tb_${DESIGN_NAME}_syn.vvp ${DESIGN_NAME}.v tb_${DESIGN_NAME}.v /usr/local/share/yosys/gatemate/cells_sim.v
  31. vvp -N tb_${DESIGN_NAME}_syn.vvp -fst
  32. # Post-implementation simulation target
  33. imp_sim: ${DESIGN_NAME}.bit
  34. 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
  35. vvp -N tb_${DESIGN_NAME}_imp.vvp -fst
  36. # FPGA FW load per JTAG
  37. prog: ${DESIGN_NAME}.bit
  38. openFPGALoader -b gatemate_evb_jtag $<
  39. clean :
  40. echo "# Cleaning files"
  41. rm -rf build ${DESIGN_NAME}.v ${DESIGN_NAME}_sim.v ${DESIGN_NAME}.vhd ${DESIGN_NAME}.bit *.vvp *.fst