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.

124 lines
4.5 KiB

  1. DESIGN_NAME := neorv32_aes
  2. NEORV32_CORE_DIR := ../../neorv32/rtl/core
  3. NEORV32_PKG := $(NEORV32_CORE_DIR)/neorv32_package.vhd
  4. NEORV32_APP_SRC := $(NEORV32_CORE_DIR)/neorv32_application_image.vhd
  5. NEORV32_TEMPLATES := ../../neorv32/rtl/processor_templates
  6. NEORV32_MEM_ENTITIES := \
  7. $(NEORV32_CORE_DIR)/neorv32_dmem.entity.vhd \
  8. $(NEORV32_CORE_DIR)/neorv32_imem.entity.vhd
  9. NEORV32_MEM_SRC := \
  10. $(NEORV32_CORE_DIR)/mem/neorv32_imem.default.vhd \
  11. $(NEORV32_CORE_DIR)/mem/neorv32_dmem.default.vhd
  12. NEORV32_CORE_SRC := \
  13. $(NEORV32_CORE_DIR)/neorv32_bootloader_image.vhd \
  14. $(NEORV32_CORE_DIR)/neorv32_boot_rom.vhd \
  15. $(NEORV32_CORE_DIR)/neorv32_bus_keeper.vhd \
  16. $(NEORV32_CORE_DIR)/neorv32_busswitch.vhd \
  17. $(NEORV32_CORE_DIR)/neorv32_cpu.vhd \
  18. $(NEORV32_CORE_DIR)/neorv32_cpu_alu.vhd \
  19. $(NEORV32_CORE_DIR)/neorv32_cpu_bus.vhd \
  20. $(NEORV32_CORE_DIR)/neorv32_cpu_control.vhd \
  21. $(NEORV32_CORE_DIR)/neorv32_cpu_cp_bitmanip.vhd \
  22. $(NEORV32_CORE_DIR)/neorv32_cpu_cp_cfu.vhd \
  23. $(NEORV32_CORE_DIR)/neorv32_cpu_cp_fpu.vhd \
  24. $(NEORV32_CORE_DIR)/neorv32_cpu_cp_muldiv.vhd \
  25. $(NEORV32_CORE_DIR)/neorv32_cpu_cp_shifter.vhd \
  26. $(NEORV32_CORE_DIR)/neorv32_cpu_decompressor.vhd \
  27. $(NEORV32_CORE_DIR)/neorv32_cpu_regfile.vhd \
  28. $(NEORV32_CORE_DIR)/neorv32_debug_dm.vhd \
  29. $(NEORV32_CORE_DIR)/neorv32_debug_dtm.vhd \
  30. $(NEORV32_CORE_DIR)/neorv32_fifo.vhd \
  31. $(NEORV32_CORE_DIR)/neorv32_gpio.vhd \
  32. $(NEORV32_CORE_DIR)/neorv32_gptmr.vhd \
  33. $(NEORV32_CORE_DIR)/neorv32_icache.vhd \
  34. $(NEORV32_CORE_DIR)/neorv32_mtime.vhd \
  35. $(NEORV32_CORE_DIR)/neorv32_neoled.vhd \
  36. $(NEORV32_CORE_DIR)/neorv32_onewire.vhd \
  37. $(NEORV32_CORE_DIR)/neorv32_pwm.vhd \
  38. $(NEORV32_CORE_DIR)/neorv32_slink.vhd \
  39. $(NEORV32_CORE_DIR)/neorv32_spi.vhd \
  40. $(NEORV32_CORE_DIR)/neorv32_sysinfo.vhd \
  41. $(NEORV32_CORE_DIR)/neorv32_trng.vhd \
  42. $(NEORV32_CORE_DIR)/neorv32_twi.vhd \
  43. $(NEORV32_CORE_DIR)/neorv32_uart.vhd \
  44. $(NEORV32_CORE_DIR)/neorv32_wdt.vhd \
  45. $(NEORV32_CORE_DIR)/neorv32_wishbone.vhd \
  46. $(NEORV32_CORE_DIR)/neorv32_xip.vhd \
  47. $(NEORV32_CORE_DIR)/neorv32_xirq.vhd \
  48. $(NEORV32_CORE_DIR)/neorv32_cfs.vhd \
  49. $(NEORV32_CORE_DIR)/neorv32_cfs_aes.vhd \
  50. $(NEORV32_CORE_DIR)/neorv32_top.vhd
  51. NEORV32_SRC := ${NEORV32_PKG} ${NEORV32_APP_SRC} ${NEORV32_MEM_ENTITIES} \
  52. ${NEORV32_MEM_SRC} ${NEORV32_CORE_SRC}
  53. AES_DIR := ../../cryptocores/aes/rtl/vhdl
  54. CRYPTO_SRC := \
  55. $(AES_DIR)/aes_pkg.vhd \
  56. $(AES_DIR)/aes_enc.vhd \
  57. $(AES_DIR)/aes_dec.vhd \
  58. $(AES_DIR)/aes.vhd \
  59. $(AES_DIR)/../../../ctraes/rtl/vhdl/ctraes.vhd
  60. WORK_FILES := ../rtl/${DESIGN_NAME}.vhd
  61. GM_FILES := ../../lib/rtl_components.vhd
  62. GHDL_FLAGS := --std=08 --workdir=build -Pbuild
  63. YOSYSPIPE := -nomx8
  64. # -retime
  65. PNRFLAGS := -om 3 -cCP on
  66. PNRTOOL := $(shell which p_r)
  67. .PHONY: all syn imp prog syn_sim imp_sim
  68. all: imp
  69. syn: ${DESIGN_NAME}.v
  70. imp: ${DESIGN_NAME}.bit
  71. build/work-obj08.cf: ${WORK_FILES} build/gatemate-obj08.cf build/neorv32-obj08.cf
  72. ghdl -a ${GHDL_FLAGS} --work=work ${WORK_FILES}
  73. build/neorv32-obj08.cf: build/gatemate-obj08.cf build/cryptocores-obj08.cf ${NEORV32_SRC}
  74. ghdl -a $(GHDL_FLAGS) --work=neorv32 ${NEORV32_SRC}
  75. build/cryptocores-obj08.cf: ${CRYPTO_SRC}
  76. ghdl -a $(GHDL_FLAGS) --work=cryptocores ${CRYPTO_SRC}
  77. build/gatemate-obj08.cf: ${GM_FILES}
  78. mkdir -p build
  79. ghdl -a ${GHDL_FLAGS} --work=gatemate ${GM_FILES}
  80. # Synthesis target for implementation
  81. ${DESIGN_NAME}.v: build/work-obj08.cf
  82. yosys -m ghdl -p 'ghdl ${GHDL_FLAGS} --warn-no-binding --no-formal ${DESIGN_NAME}; synth_gatemate -top $(DESIGN_NAME) ${YOSYSPIPE} -vlog $@' \
  83. 2>&1 | tee build/yosys-report.txt
  84. # Implementation target for FPGA
  85. ${DESIGN_NAME}.bit: ${DESIGN_NAME}.v ${DESIGN_NAME}.ccf
  86. cd build && \
  87. ${PNRTOOL} -i ../${DESIGN_NAME}.v -o $@ --ccf ../${DESIGN_NAME}.ccf $(PNRFLAGS) \
  88. 2>&1 | tee p_r-report.txt && \
  89. mv ${DESIGN_NAME}*.bit ../$@
  90. # Post-synthesis simulation target
  91. syn_sim: ${DESIGN_NAME}.v
  92. iverilog -g2012 -o tb_${DESIGN_NAME}_syn.vvp ${DESIGN_NAME}.v tb_${DESIGN_NAME}.v /usr/local/share/yosys/gatemate/cells_sim.v
  93. vvp -N tb_${DESIGN_NAME}_syn.vvp -fst
  94. # Post-implementation simulation target
  95. imp_sim: ${DESIGN_NAME}.bit
  96. 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
  97. vvp -N tb_${DESIGN_NAME}_imp.vvp -fst
  98. # FPGA FW load per JTAG
  99. prog: ${DESIGN_NAME}.bit
  100. openFPGALoader -b gatemate_evb_jtag $<
  101. clean :
  102. echo "# Cleaning files"
  103. rm -rf build ${DESIGN_NAME}.v ${DESIGN_NAME}_sim.v ${DESIGN_NAME}.vhd ${DESIGN_NAME}.bit *.vvp *.fst