Applying updates for Libero SoC support (#1855)

* Updated the new_project tcl function and removed set_device function.

* fixing tcl command set_root and adding in build_hierarchy command.

* Adding tcl command to export_prog_job file for FPExpress, saves in Libero SoC default location.

* Attempting error checking on Libero SoC installation, and typo clean up.

* Fixing -adv_options in new_project tcl command.

* Moving script_ext back to its original location.

* Commented out Libero environment variable.

* Removed Libero environment variable.
This commit is contained in:
CLappin 2024-05-30 07:56:27 +01:00 committed by GitHub
parent 94e6bb0247
commit 72cade55da
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 41 additions and 33 deletions

View File

@ -8,6 +8,7 @@ import os
import sys
import subprocess
import shutil
from shutil import which
from migen.fhdl.structure import _Fragment
@ -83,6 +84,7 @@ class MicrosemiLiberoSoCPolarfireToolchain(GenericToolchain):
def build_project(self):
tcl = []
die, package, speed = self.platform.device.split("-")
# Create project
tcl.append(" ".join([
"new_project",
@ -96,35 +98,16 @@ class MicrosemiLiberoSoCPolarfireToolchain(GenericToolchain):
"-use_enhanced_constraint_flow 1",
"-hdl {VERILOG}",
"-family {PolarFire}",
"-die {}",
"-package {}",
"-speed {}",
"-die_voltage {}",
"-part_range {}",
"-adv_options {}"
]))
die, package, speed = self.platform.device.split("-")
tcl.append(" ".join([
"set_device",
"-family {PolarFire}",
"-die {}".format(self.tcl_name(die)),
"-package {}".format(self.tcl_name(package)),
"-speed {}".format(self.tcl_name("-" + speed)),
# FIXME: common to all PolarFire devices?
"-die_voltage {1.0}",
"-part_range {EXT}",
"-adv_options {IO_DEFT_STD:LVCMOS 1.8V}",
"-adv_options {RESTRICTPROBEPINS:1}",
"-adv_options {RESTRICTSPIPINS:0}",
"-adv_options {TEMPR:EXT}",
"-adv_options {UNUSED_MSS_IO_RESISTOR_PULL:None}",
"-adv_options {VCCI_1.2_VOLTR:EXT}",
"-adv_options {VCCI_1.5_VOLTR:EXT}",
"-adv_options {VCCI_1.8_VOLTR:EXT}",
"-adv_options {VCCI_2.5_VOLTR:EXT}",
"-adv_options {VCCI_3.3_VOLTR:EXT}",
"-adv_options {VOLTR:EXT} "
"-part_range {IND}",
"-adv_options {VCCI_1.2_VOLTR:IND}",
"-adv_options {VCCI_1.5_VOLTR:IND}",
"-adv_options {VCCI_1.8_VOLTR:IND}",
"-adv_options {VCCI_2.5_VOLTR:IND}",
"-adv_options {VCCI_3.3_VOLTR:IND}"
]))
# Add sources
@ -132,13 +115,16 @@ class MicrosemiLiberoSoCPolarfireToolchain(GenericToolchain):
filename_tcl = "{" + filename + "}"
tcl.append("import_files -hdl_source " + filename_tcl)
# Building the design Hierarchy
tcl.append("build_design_hierarchy")
# Set top level
tcl.append("set_root -module {}".format(self.tcl_name(self._build_name)))
tcl.append("set_root -module {}".format(self.tcl_name(self._build_name + "::work")))
# Copy init files FIXME: support for include path on LiberoSoC?
for file in os.listdir(self._build_dir):
if file.endswith(".init"):
tcl.append("file copy -- {} impl/synthesis".format(file))
# Commenting out copy init file as this breaks the LiberoSoC flow.
# for file in os.listdir(self._build_dir):
# if file.endswith(".init"):
# tcl.append("file copy -- {} impl/synthesis".format(file))
# Import io constraints
tcl.append("import_files -io_pdc {}".format(self.tcl_name(self._build_name + "_io.pdc")))
@ -178,6 +164,23 @@ class MicrosemiLiberoSoCPolarfireToolchain(GenericToolchain):
tcl.append("run_tool -name {GENERATEPROGRAMMINGDATA}")
tcl.append("run_tool -name {GENERATEPROGRAMMINGFILE}")
# Export the FPExpress programming file to Libero SoC default location
tcl.append(" export_prog_job \
-job_file_name {top} \
-export_dir {./impl/designer/top/export} \
-bitstream_file_type {TRUSTED_FACILITY} \
-bitstream_file_components {FABRIC SNVM} \
-zeroization_likenew_action 0 \
-zeroization_unrecoverable_action 0 \
-program_design 1 \
-program_spi_flash 0 \
-include_plaintext_passkey 0 \
-design_bitstream_format {PPD} \
-prog_optional_procedures {} \
-skip_recommended_procedures {} \
-sanitize_snvm 0 ")
# Generate tcl
tools.write_to_file(self._build_name + ".tcl", "\n".join(tcl))
return self._build_name + ".tcl"
@ -221,6 +224,7 @@ class MicrosemiLiberoSoCPolarfireToolchain(GenericToolchain):
copy_stmt = "cp"
fail_stmt = " || exit 1"
script_contents += "libero script:" + self._build_name + ".tcl\n"
script_file = "build_" + self._build_name + script_ext
tools.write_to_file(script_file, script_contents,
force_unix=False)
@ -236,6 +240,10 @@ class MicrosemiLiberoSoCPolarfireToolchain(GenericToolchain):
else:
shell = ["bash"]
if which("libero") is None:
msg = "Unable to find or source Libero SoC toolchain, please make sure libero has been installed corectly.\n"
raise OSError(msg)
if subprocess.call(shell + [script]) != 0:
raise OSError("Subprocess failed")