Skip to content

Commit

Permalink
Applying updates for Libero SoC support (#1855)
Browse files Browse the repository at this point in the history
* 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.
  • Loading branch information
CLappin committed May 30, 2024
1 parent 94e6bb0 commit 72cade5
Showing 1 changed file with 41 additions and 33 deletions.
74 changes: 41 additions & 33 deletions litex/build/microsemi/libero_soc.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import sys
import subprocess
import shutil
from shutil import which

from migen.fhdl.structure import _Fragment

Expand Down Expand Up @@ -83,6 +84,7 @@ def build_placement_constraints(self):
def build_project(self):
tcl = []

die, package, speed = self.platform.device.split("-")
# Create project
tcl.append(" ".join([
"new_project",
Expand All @@ -96,49 +98,33 @@ def build_project(self):
"-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)),
"-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
for filename, language, library, *copy in self.platform.sources:
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")))
Expand Down Expand Up @@ -177,6 +163,23 @@ def build_project(self):
tcl.append("run_tool -name {PLACEROUTE}")
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))
Expand Down Expand Up @@ -208,7 +211,7 @@ def build_timing_constraints(self, vns):
return (self._build_name + ".sdc", "SDC")

# Script ---------------------------------------------------------------------------------------

def build_script(self):
if sys.platform in ("win32", "cygwin"):
script_ext = ".bat"
Expand All @@ -221,6 +224,7 @@ def build_script(self):
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)
Expand All @@ -236,8 +240,12 @@ def run_script(self, script):
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")
raise OSError("Subprocess failed")

def add_false_path_constraint(self, platform, from_, to):
if (to, from_) not in self.false_paths:
Expand Down

0 comments on commit 72cade5

Please sign in to comment.