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.

77 lines
2.7 KiB

  1. DESIGN_NAME := uart_aes
  2. AES_DIR := ../../cryptocores/aes/rtl/vhdl
  3. CRYPTO_SRC := \
  4. $(AES_DIR)/aes_pkg.vhd \
  5. $(AES_DIR)/aes_enc.vhd \
  6. $(AES_DIR)/../../../ctraes/rtl/vhdl/ctraes.vhd
  7. WORK_FILES := \
  8. ../rtl/uart_aes_types.vhd \
  9. ../rtl/uart_tx.vhd \
  10. ../rtl/uart_rx.vhd \
  11. ../rtl/uart_ctrl.vhd \
  12. ../rtl/${DESIGN_NAME}.vhd
  13. GM_FILES := ../../lib/rtl_components.vhd
  14. GHDL_FLAGS := --std=08 --workdir=build -Pbuild
  15. ICARUSFLAGS := -Wall -Winfloop -g2012 -gspecify -Ttyp
  16. YOSYSPIPE := -nomx8
  17. # yosys -nomx8 option has to be used as GM FPGA hasn't any (working?) MUX8 cells (in contrast to documentation)
  18. # yosys -retime option causes design AES unit misbehavior (wrong results)
  19. # yosys -dff option can be used without risk (but leads to 2.5 mhz less fmax)
  20. PNRTOOL := $(shell which p_r)
  21. PNRFLAGS := -om 3 -cCP off
  22. # p_r +cCP option causes design AES unit misbehavior (wrong results != retime results)
  23. # p_r +sp option causes design AES unit misbehavior (wrong results != retime results != cCP results)
  24. # p_r +cCP with +gCP also breaks UART
  25. .PHONY: all syn imp prog syn_sim imp_sim
  26. all: imp
  27. syn: ${DESIGN_NAME}.v
  28. imp: ${DESIGN_NAME}.bit
  29. build/work-obj08.cf: ${WORK_FILES} build/gatemate-obj08.cf build/cryptocores-obj08.cf
  30. ghdl -a ${GHDL_FLAGS} --work=work ${WORK_FILES}
  31. build/cryptocores-obj08.cf: ${CRYPTO_SRC}
  32. ghdl -a $(GHDL_FLAGS) --work=cryptocores ${CRYPTO_SRC}
  33. build/gatemate-obj08.cf: ${GM_FILES}
  34. mkdir -p build
  35. ghdl -a ${GHDL_FLAGS} --work=gatemate ${GM_FILES}
  36. # Synthesis target for implementation
  37. ${DESIGN_NAME}.v: build/work-obj08.cf
  38. yosys -m ghdl -p 'ghdl ${GHDL_FLAGS} --warn-no-binding --no-formal ${DESIGN_NAME}; synth_gatemate -top $(DESIGN_NAME) ${YOSYSPIPE} -vlog $@' \
  39. 2>&1 | tee build/yosys-report.txt
  40. # Implementation target for FPGA
  41. ${DESIGN_NAME}.bit: ${DESIGN_NAME}.v ${DESIGN_NAME}.ccf
  42. cd build && \
  43. ${PNRTOOL} -i ../${DESIGN_NAME}.v -o $@ --ccf ../${DESIGN_NAME}.ccf $(PNRFLAGS) \
  44. 2>&1 | tee p_r-report.txt && \
  45. mv ${DESIGN_NAME}*.bit ../$@
  46. # Post-synthesis simulation target
  47. syn_sim: ${DESIGN_NAME}.v
  48. iverilog ${ICARUSFLAGS} -o tb_${DESIGN_NAME}_syn.vvp ${DESIGN_NAME}.v tb_${DESIGN_NAME}.v /usr/local/share/yosys/gatemate/cells_sim.v
  49. vvp -N tb_${DESIGN_NAME}_syn.vvp -fst
  50. # Post-implementation simulation target
  51. imp_sim: ${DESIGN_NAME}.bit
  52. iverilog ${ICARUSFLAGS} -o tb_${DESIGN_NAME}_imp.vvp build/${DESIGN_NAME}_00.v tb_${DESIGN_NAME}.v /opt/cc-toolchain-linux/bin/p_r/cpelib.v
  53. vvp -N tb_${DESIGN_NAME}_imp.vvp -fst
  54. # FPGA FW load per JTAG
  55. prog: ${DESIGN_NAME}.bit
  56. openFPGALoader -b gatemate_evb_jtag $<
  57. clean :
  58. echo "# Cleaning files"
  59. rm -rf build ${DESIGN_NAME}.v ${DESIGN_NAME}_sim.v ${DESIGN_NAME}.vhd ${DESIGN_NAME}.bit *.vvp *.fst