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.

126 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.gatemate.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. ../rtl/neorv32_top.vhd
  51. # $(NEORV32_CORE_DIR)/neorv32_top.vhd
  52. NEORV32_SRC := ${NEORV32_PKG} ${NEORV32_APP_SRC} ${NEORV32_MEM_ENTITIES} \
  53. ${NEORV32_MEM_SRC} ${NEORV32_CORE_SRC}
  54. AES_DIR := ../../cryptocores/aes/rtl/vhdl
  55. CRYPTO_SRC := \
  56. $(AES_DIR)/aes_pkg.vhd \
  57. $(AES_DIR)/aes_enc.vhd \
  58. $(AES_DIR)/aes_dec.vhd \
  59. $(AES_DIR)/aes.vhd \
  60. $(AES_DIR)/../../../ctraes/rtl/vhdl/ctraes.vhd
  61. WORK_FILES := ../rtl/${DESIGN_NAME}.vhd
  62. GM_FILES := ../../lib/rtl_components.vhd
  63. GHDL_FLAGS := --std=08 --workdir=build -Pbuild
  64. ICARUSFLAGS := -Wall -Winfloop -g2012 -gspecify -Ttyp
  65. YOSYSPIPE := -nomx8 -nobram
  66. PNRFLAGS := -om 3 -cCP on
  67. PNRTOOL := $(shell which p_r)
  68. .PHONY: all syn imp prog syn_sim imp_sim
  69. all: imp
  70. syn: ${DESIGN_NAME}.v
  71. imp: ${DESIGN_NAME}.bit
  72. build/work-obj08.cf: ${WORK_FILES} build/gatemate-obj08.cf build/neorv32-obj08.cf
  73. ghdl -a ${GHDL_FLAGS} --work=work ${WORK_FILES}
  74. build/neorv32-obj08.cf: build/gatemate-obj08.cf build/cryptocores-obj08.cf ${NEORV32_SRC}
  75. ghdl -a $(GHDL_FLAGS) --work=neorv32 ${NEORV32_SRC}
  76. build/cryptocores-obj08.cf: ${CRYPTO_SRC}
  77. ghdl -a $(GHDL_FLAGS) --work=cryptocores ${CRYPTO_SRC}
  78. build/gatemate-obj08.cf: ${GM_FILES}
  79. mkdir -p build
  80. ghdl -a ${GHDL_FLAGS} --work=gatemate ${GM_FILES}
  81. # Synthesis target for implementation
  82. ${DESIGN_NAME}.v: build/work-obj08.cf
  83. yosys -m ghdl -p 'ghdl ${GHDL_FLAGS} --warn-no-binding --no-formal ${DESIGN_NAME}; synth_gatemate -top $(DESIGN_NAME) ${YOSYSPIPE} -vlog $@' \
  84. 2>&1 | tee build/yosys-report.txt
  85. # Implementation target for FPGA
  86. ${DESIGN_NAME}.bit: ${DESIGN_NAME}.v ${DESIGN_NAME}.ccf
  87. cd build && \
  88. ${PNRTOOL} -i ../${DESIGN_NAME}.v -o $@ --ccf ../${DESIGN_NAME}.ccf $(PNRFLAGS) \
  89. 2>&1 | tee p_r-report.txt && \
  90. mv ${DESIGN_NAME}*.bit ../$@
  91. # Post-synthesis simulation target
  92. syn_sim: ${DESIGN_NAME}.v
  93. iverilog ${ICARUSFLAGS} -o tb_${DESIGN_NAME}_syn.vvp ${DESIGN_NAME}.v tb_${DESIGN_NAME}.v /usr/local/share/yosys/gatemate/cells_sim.v
  94. vvp -N tb_${DESIGN_NAME}_syn.vvp -fst
  95. # Post-implementation simulation target
  96. imp_sim: ${DESIGN_NAME}.bit
  97. 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
  98. vvp -N tb_${DESIGN_NAME}_imp.vvp -fst
  99. # FPGA FW load per JTAG
  100. prog: ${DESIGN_NAME}.bit
  101. openFPGALoader -b gatemate_evb_jtag $<
  102. clean :
  103. echo "# Cleaning files"
  104. rm -rf build ${DESIGN_NAME}.v ${DESIGN_NAME}_sim.v ${DESIGN_NAME}.vhd ${DESIGN_NAME}.bit *.vvp *.fst