|
| 1 | +{# |
| 2 | +# |
| 3 | +# Copyright (C) 2015-2024 PyFPGA Project |
| 4 | +# |
| 5 | +# SPDX-License-Identifier: GPL-3.0-or-later |
| 6 | +# |
| 7 | +#} |
| 8 | + |
| 9 | +{% if 'cfg' in steps %}# Project configuration ------------------------------------------------------- |
| 10 | + |
| 11 | +prj_project new -name {{ project }} -dev {{ part }} |
| 12 | + |
| 13 | +# For now, let's enforce Synplify as LSE (the default) has broken top level generic handling |
| 14 | +prj_syn set synplify |
| 15 | + |
| 16 | +{% if hooks %}{{ hooks.precfg | join('\n') }}{% endif %} |
| 17 | + |
| 18 | +{% if files %}# Files inclusion |
| 19 | +{% for name, attr in files.items() %} |
| 20 | +prj_src add {% if 'lib' in attr %}-work {{ attr.lib }}{% else %}{% endif %} {{ name }} |
| 21 | +{% endfor %} |
| 22 | +{% endif %} |
| 23 | + |
| 24 | +{% if constraints %} |
| 25 | +# Constraints inclusion |
| 26 | +# Diamond only supports one constraints file, so we need to combine them into the default diamond.lpf. |
| 27 | +# We can't just do `prj_src add <constraints-file>` multiple times. |
| 28 | +set fileId [open diamond.lpf "w"] |
| 29 | +{% for name, attr in constraints.items() %} |
| 30 | +set fp [open "{{ name }}" r] |
| 31 | +set file_data [read $fp] |
| 32 | +close $fp |
| 33 | +puts -nonewline $fileId $file_data |
| 34 | +{% endfor %} |
| 35 | +close $fileId |
| 36 | +{% endif %} |
| 37 | + |
| 38 | +{% if top %}# Top-level specification |
| 39 | +prj_impl option top "{{ top }}" |
| 40 | +{% endif %} |
| 41 | + |
| 42 | +{% if includes %}# Verilog Includes |
| 43 | +{% for include in includes %} |
| 44 | +prj_impl option -append {include path} {{ "{"+include+"}" }} |
| 45 | +{% endfor %} |
| 46 | +{% endif %} |
| 47 | + |
| 48 | +{% if defines %}# Verilog Defines |
| 49 | +{% for key, value in defines.items() %} |
| 50 | +prj_impl option -append VERILOG_DIRECTIVES {{ key }}={{ value }} |
| 51 | +{% endfor %} |
| 52 | +{% endif %} |
| 53 | + |
| 54 | +{% if params %}# Verilog Parameters / VHDL Generics |
| 55 | +{% for key, value in params.items() %} |
| 56 | +prj_impl option -append HDL_PARAM {{ key }}={{ value }} |
| 57 | +{% endfor %} |
| 58 | +{% endif %} |
| 59 | + |
| 60 | +{% if hooks %}{{ hooks.postcfg | join('\n') }}{% endif %} |
| 61 | + |
| 62 | +prj_project save |
| 63 | +prj_project close |
| 64 | + |
| 65 | +{% endif %} |
| 66 | + |
| 67 | +{% if 'syn' in steps or 'par' in steps or 'bit' in steps %}# Design flow ----------------------------------------------------------------- |
| 68 | + |
| 69 | +prj_project open {{ project }}.ldf |
| 70 | + |
| 71 | +{% if 'syn' in steps %}# Synthesis |
| 72 | + |
| 73 | +{% if hooks %}{{ hooks.presyn | join('\n') }}{% endif %} |
| 74 | + |
| 75 | +prj_run Synthesis -forceOne |
| 76 | + |
| 77 | +{% if hooks %}{{ hooks.postsyn | join('\n') }}{% endif %} |
| 78 | + |
| 79 | +{% endif %} |
| 80 | + |
| 81 | +{% if 'par' in steps %} # Translate, Map, and Place and Route |
| 82 | +{% if hooks %}{{ hooks.prepar | join('\n') }}{% endif %} |
| 83 | + |
| 84 | +prj_run Translate -forceOne |
| 85 | +prj_run Map -forceOne |
| 86 | +prj_run PAR -forceOne |
| 87 | + |
| 88 | +{% if hooks %}{{ hooks.postpar | join('\n') }}{% endif %} |
| 89 | + |
| 90 | +{% endif %} |
| 91 | + |
| 92 | +{% if 'bit' in steps %}# Bitstream generation |
| 93 | + |
| 94 | +{% if hooks %}{{ hooks.prebit | join('\n') }}{% endif %} |
| 95 | + |
| 96 | +prj_run Export -task Bitgen -forceOne |
| 97 | + |
| 98 | +{% if hooks %}{{ hooks.postbit | join('\n') }}{% endif %} |
| 99 | + |
| 100 | +{% endif %} |
| 101 | + |
| 102 | +prj_project save |
| 103 | +prj_project close |
| 104 | + |
| 105 | +{% endif %} |
0 commit comments