Skip to content

Commit

Permalink
Libero - Add flexible TCL script hooks
Browse files Browse the repository at this point in the history
This allow adding TCL scripts on pre-synthesize, pre-pnr and
pre-bistream generation for the Libero backend.

In the .core file, this would be defined like:

```yaml
  polarfireeval:
    files:
      - rtl/corescore_polarfire_eval_clock_gen.v: { file_type: verilogSource }
      - rtl/corescore_polarfire.v: { file_type: verilogSource }
      - data/polarfire_eval.pdc: { file_type: PDC }
      - data/script_pre_synth.tcl: { file_type: tclSourcePresynth }
      - data/script_pre_pnr.tcl: { file_type: tclSourcePrepnr }
      - data/script_pre_bitstream.tcl: { file_type: tclSourcePrebistream }
```

Signed-off-by: Carlos de Paula <me@carlosedp.com>
  • Loading branch information
carlosedp committed Sep 20, 2021
1 parent f4b3cc5 commit 5b68802
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 2 deletions.
7 changes: 5 additions & 2 deletions edalize/libero.py
Expand Up @@ -157,12 +157,15 @@ def src_file_filter(self, f):
return file_types[_file_type] + f.name
return ''

def tcl_file_filter(self, f):
def tcl_file_filter(self, f, type='tclSource'):
file_types = {
'tclSource': 'source ',
'tclSourcePresynth': 'source ',
'tclSourcePrepnr': 'source ',
'tclSourcePrebistream': 'source ',
}
_file_type = f.file_type.split('-')[0]
if _file_type in file_types:
if _file_type in file_types and _file_type == type:
return file_types[_file_type] + f.name
return ''

Expand Down
17 changes: 17 additions & 0 deletions edalize/templates/libero/libero-run.tcl.j2
Expand Up @@ -4,8 +4,25 @@

source {{op}}{{name}}-project.tcl{{cl}}

# Source user defined TCL scripts
{% for src_file in src_files if src_file|tcl_file_filter('tclSourcePresynth')%}
puts "---------- Executing User pre-synth TCL script: {{src_file|tcl_file_filter('tclSourcePresynth')|replace("source", "")|trim}} ----------"
{{src_file|tcl_file_filter('tclSourcePresynth')}}
{% endfor %}
run_tool -name {SYNTHESIZE}

# Source user defined TCL scripts
{% for src_file in src_files if src_file|tcl_file_filter('tclSourcePrepnr')%}
puts "---------- Executing User pre-pnr TCL script: {{src_file|tcl_file_filter('tclSourcePrepnr')|replace("source", "")|trim}} ----------"
{{src_file|tcl_file_filter('tclSourcePrepnr')}}
{% endfor %}
run_tool -name {PLACEROUTE}

# Source user defined TCL scripts
{% for src_file in src_files if src_file|tcl_file_filter('tclSourcePrebistream')%}
puts "---------- Executing User pre-bitstream TCL script: {{src_file|tcl_file_filter('tclSourcePrebistream')|replace("source", "")|trim}} ----------"
{{src_file|tcl_file_filter('tclSourcePrebistream')}}
{% endfor %}
run_tool -name {GENERATEPROGRAMMINGDATA}

puts "To program the FPGA and SPI-Flash, run the 'Run PROGRAM Action' and 'Run PROGRAM_SPI_IMAGE Action' tools in the Design Flow menu."
Expand Down
3 changes: 3 additions & 0 deletions tests/edalize_common.py
Expand Up @@ -187,6 +187,9 @@ def _setup_backend(name, tool, paramtypes, files,
{"name": "ucf_file.ucf", "file_type": "UCF"},
{"name": "user_file", "file_type": "user"},
{"name": "tcl_file.tcl", "file_type": "tclSource"},
{"name": "tcl_file_presynth.tcl", "file_type": "tclSourcePresynth"},
{"name": "tcl_file_prepnr.tcl", "file_type": "tclSourcePrepnr"},
{"name": "tcl_file_prebitstream.tcl", "file_type": "tclSourcePrebistream"},
{"name": "waiver_file.waiver", "file_type": "waiver"},
{"name": "vlog_file.v", "file_type": "verilogSource"},
{"name": "vlog05_file.v", "file_type": "verilogSource-2005"},
Expand Down
12 changes: 12 additions & 0 deletions tests/test_libero/libero-test-all-run.tcl
Expand Up @@ -4,8 +4,20 @@

source {libero-test-all-project.tcl}

# Source user defined TCL scripts
puts "---------- Executing User pre-synth TCL script: tcl_file_presynth.tcl ----------"
source tcl_file_presynth.tcl
run_tool -name {SYNTHESIZE}

# Source user defined TCL scripts
puts "---------- Executing User pre-pnr TCL script: tcl_file_prepnr.tcl ----------"
source tcl_file_prepnr.tcl
run_tool -name {PLACEROUTE}

# Source user defined TCL scripts
puts "---------- Executing User pre-bitstream TCL script: tcl_file_prebitstream.tcl ----------"
source tcl_file_prebitstream.tcl

run_tool -name {GENERATEPROGRAMMINGDATA}

puts "To program the FPGA and SPI-Flash, run the 'Run PROGRAM Action' and 'Run PROGRAM_SPI_IMAGE Action' tools in the Design Flow menu."
Expand Down
12 changes: 12 additions & 0 deletions tests/test_libero/libero-test-run.tcl
Expand Up @@ -4,8 +4,20 @@

source {libero-test-project.tcl}

# Source user defined TCL scripts
puts "---------- Executing User pre-synth TCL script: tcl_file_presynth.tcl ----------"
source tcl_file_presynth.tcl
run_tool -name {SYNTHESIZE}

# Source user defined TCL scripts
puts "---------- Executing User pre-pnr TCL script: tcl_file_prepnr.tcl ----------"
source tcl_file_prepnr.tcl
run_tool -name {PLACEROUTE}

# Source user defined TCL scripts
puts "---------- Executing User pre-bitstream TCL script: tcl_file_prebitstream.tcl ----------"
source tcl_file_prebitstream.tcl

run_tool -name {GENERATEPROGRAMMINGDATA}

puts "To program the FPGA and SPI-Flash, run the 'Run PROGRAM Action' and 'Run PROGRAM_SPI_IMAGE Action' tools in the Design Flow menu."
Expand Down

0 comments on commit 5b68802

Please sign in to comment.