Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Libero - Add flexible TCL script hooks #268

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 5 additions & 2 deletions edalize/libero.py
Expand Up @@ -177,12 +177,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 ",
"tclSourcePreBitstream": "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}}

{% for src_file in src_files if src_file|tcl_file_filter('tclSourcePreSynth')%}
# Source user defined TCL scripts
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}

{% for src_file in src_files if src_file|tcl_file_filter('tclSourcePrePnR')%}
# Source user defined TCL scripts
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}

{% for src_file in src_files if src_file|tcl_file_filter('tclSourcePreBitstream')%}
# Source user defined TCL scripts
puts "---------- Executing User pre-bitstream TCL script: {{src_file|tcl_file_filter('tclSourcePreBitstream')|replace("source", "")|trim}} ----------"
{{src_file|tcl_file_filter('tclSourcePreBitstream')}}
{% 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 @@ -204,6 +204,9 @@ def _setup_backend(
{"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": "tclSourcePreBitstream"},
{"name": "waiver_file.waiver", "file_type": "waiver"},
{"name": "vlog_file.v", "file_type": "verilogSource"},
{"name": "vlog05_file.v", "file_type": "verilogSource-2005"},
Expand Down
11 changes: 11 additions & 0 deletions tests/test_libero/libero-test-all-run.tcl
Expand Up @@ -4,8 +4,19 @@

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
11 changes: 11 additions & 0 deletions tests/test_libero/libero-test-run.tcl
Expand Up @@ -4,8 +4,19 @@

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