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

Infrastructure updates and fixes for Lattice tools version 2023.2 #1547

Open
wants to merge 6 commits 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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -110,3 +110,8 @@ _build
library/**/.lock
library/**/interfaces/*.sv
.backstage_yaml
.setting.ini
MachXO3D_Template01
ipcfg
_bld
radiantc.*
18 changes: 9 additions & 9 deletions docs/user_guide/build_hdl.rst
Original file line number Diff line number Diff line change
Expand Up @@ -751,7 +751,7 @@ i2c_controller I2C Controller 2.0.1
axi_interconnect AXI4 Interconnect 1.2.2
axi2ahb_bridge AXI4 to AHB-Lite Bridge 1.1.1
axi2apb_bridge AXI4 to APB Bridge 1.1.1
gp_timer Timer-Counter 1.3.0
gp_timer Timer-Counter 1.3.1
==================== ============================= =======

.. shell:: bash
Expand Down Expand Up @@ -788,17 +788,17 @@ This contains the most relevant information that you need to provide.

~/hdl
$ls -ltr <ADI_carrier_proj_dir>
$ls -ltr <ADI_carrier_proj_dir>/<project_name>
$ls -ltr <ADI_carrier_proj_dir>/<project_name>/<project_name>
$tail <ADI_carrier_proj_dir>/<project_name>_propel_builder.log
$tail <ADI_carrier_proj_dir>/<project_name>_radiant.log
$ls -ltr <ADI_carrier_proj_dir>/_bld/<project_name>
$ls -ltr <ADI_carrier_proj_dir>/_bld/<project_name>/<project_name>
$tail <ADI_carrier_proj_dir>/_bld/<project_name>_propel_builder.log
$tail <ADI_carrier_proj_dir>/_bld/<project_name>_radiant.log

Note that if the **Propel Builder** project fails to build, the
**$(PROJECT_NAME)_radiant.log** may not exist.

If the Propel Builder project was built successfully, the **sge**
folder should appear in the **<ADI_carrier_proj_dir>/** or in the
**<ADI_carrier_proj_dir>/<project_name>**.
**<ADI_carrier_proj_dir>/_bld/<project_name>**.
The **sge** folder contains the **bsp** folder (Base Support
Package) and the SoC configuration files.

Expand Down Expand Up @@ -826,15 +826,15 @@ The **system_pb.tcl** is sourced in **adi_project_pb** procedure.
The **system_project.tcl** runs second. This file is used to create and build
the **HDL project** (Radiant). Here we use the output of the Propel Builder
project as the **configured IPs** that can be found in the
*<ADI_carrier_proj_dir>/<project_name>/<project_name>/lib* folder and the
*<ADI_carrier_proj_dir>/_bld/<project_name>/<project_name>/lib* folder and the
**default block design wrapper** that is the
*<ADI_carrier_proj_dir>/<project_name>/<project_name>/<project_name>.v*.
*<ADI_carrier_proj_dir>/_bld/<project_name>/<project_name>/<project_name>.v*.

We add them to the Radiant project, then add our **system_top.v** wrapper,
the **constraint files** and build the project.

The output is a **.bit** file that by default will appear in the
**<ADI_carrier_proj_dir>/<project_name>/impl_1** folder if the project was
**<ADI_carrier_proj_dir>/_bld/<project_name>/impl_1** folder if the project was
successfully built.

Supported targets of ``make`` command
Expand Down
2 changes: 2 additions & 0 deletions projects/common/lfcpnx/lfcpnx_system_constr.pdc
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@

ldc_set_sysconfig {JTAG_PORT=ENABLE MASTER_SPI_PORT=SERIAL DONE_PORT=ENABLE INITN_PORT=ENABLE PROGRAMN_PORT=ENABLE MCCLK_FREQ=112.5 CONFIG_IOSLEW=FAST BOOTMODE=SINGLE CONFIGIO_VOLTAGE_BANK0=1.8 CONFIGIO_VOLTAGE_BANK1=3.3}

set_clock_uncertainty 0.002 [all_clocks]

#gpio LEDs 0-7
ldc_set_location -site {N5} [get_ports {leds_0_to_23[0]}]
ldc_set_location -site {N6} [get_ports {leds_0_to_23[1]}]
Expand Down
10 changes: 5 additions & 5 deletions projects/common/lfcpnx/lfcpnx_system_pb.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ sbp_assign_addr_seg -offset 'h00000000 "$project_name/cpu0_inst/LOCAL_BUS_M_INST
"$project_name/tcm0_inst/LOCAL_BUS_IF_S1"

if {$timer_en == 1} {
adi_ip_update -vlnv {latticesemi.com:ip:axi_interc0:1.2.2} \
adi_ip_update $project_name -vlnv {latticesemi.com:ip:axi_interc0:1.2.2} \
-meta_vlnv {latticesemi.com:ip:axi_interconnect:1.2.2} \
-cfg_value {
TOTAL_EXTMAS_CNT: 1,
Expand All @@ -270,13 +270,13 @@ if {$timer_en == 1} {
} \
-ip_iname "axi_interc0_inst"

adi_ip_instance -vlnv {latticesemi.com:ip:axi_apb3:1.1.0} \
-meta_vlnv {latticesemi.com:ip:axi2apb_bridge:1.1.0} \
adi_ip_instance -vlnv {latticesemi.com:ip:axi_apb3:1.1.1} \
-meta_vlnv {latticesemi.com:ip:axi2apb_bridge:1.1.1} \
-cfg_value {} \
-ip_iname "axi_apb3_inst"

adi_ip_instance -vlnv {latticesemi.com:ip:timer0:1.3.0} \
-meta_vlnv {latticesemi.com:ip:gp_timer:1.3.0} \
adi_ip_instance -vlnv {latticesemi.com:ip:timer0:1.3.1} \
-meta_vlnv {latticesemi.com:ip:gp_timer:1.3.1} \
-cfg_value {
t1_cnt_up: count-up,
T1_PERIOD_WIDTH: 32,
Expand Down
20 changes: 10 additions & 10 deletions projects/scripts/adi_project_lattice.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ proc adi_project {project_name args} {
puts "\nadi_project:\n"

array set opt [list -dev_select "auto" \
-ppath "./$project_name" \
-ppath "./_bld/$project_name" \
-device "" \
-speed "" \
-board "" \
Expand Down Expand Up @@ -94,7 +94,7 @@ proc adi_project {project_name args} {
proc adi_project_create {project_name args} {
puts "\nadi_project_create:\n"

array set opt [list -ppath "./$project_name" \
array set opt [list -ppath "./_bld/$project_name" \
-device "" \
-performance "" \
-board "" \
Expand Down Expand Up @@ -195,8 +195,8 @@ proc adi_project_files_auto {project_name args} {
puts "\nadi_project_files_auto:\n"

array set opt [list -exts {*.ipx} \
-spath ./$project_name/$project_name/lib \
-ppath "./$project_name" \
-spath ./_bld/$project_name/$project_name/lib \
-ppath "./_bld/$project_name" \
-sdepth "6" \
-opt_args "" \
{*}$args]
Expand Down Expand Up @@ -287,7 +287,7 @@ proc adi_project_files_auto {project_name args} {
proc adi_project_files {project_name args} {
puts "\nadi_project_files:\n"

array set opt [list -ppath "./$project_name" \
array set opt [list -ppath "./_bld/$project_name" \
-flist "" \
-opt_args "" \
{*}$args]
Expand Down Expand Up @@ -374,11 +374,11 @@ proc add_update_constraint_file {pfile project_dir ext radiant_project opt_args}
# Adds the default project files to the Radiant project ($project_name.rdf)
proc adi_project_files_default {project_name} {
adi_project_files_auto $project_name -exts {*.ipx} \
-spath "./$project_name/$project_name/lib" \
-ppath "./$project_name" \
-spath "./_bld/$project_name/$project_name/lib" \
-ppath "./_bld/$project_name" \
-sdepth "6"
adi_project_files $project_name \
-flist [list ./$project_name/$project_name/$project_name.v]
-flist [list ./_bld/$project_name/$project_name/$project_name.v]
}

###############################################################################
Expand Down Expand Up @@ -447,7 +447,7 @@ proc adopt_path {full_path_flist base_to_cut {base_to_add ""}} {
proc adi_project_run {project_name args} {
puts "\nadi_project_run:\n"

array set opt [list -ppath "./$project_name" \
array set opt [list -ppath "./_bld/$project_name" \
-mode "export" \
-impl "impl_1" \
-top "system_top" \
Expand Down Expand Up @@ -516,7 +516,7 @@ proc adi_project_run_cmd {project_name args} {
puts "\nadi_project_run_cmd:\n"
set dir [pwd]

array set opt [list -ppath "./$project_name" -cmd_list "" {*}$args]
array set opt [list -ppath "./_bld/$project_name" -cmd_list "" {*}$args]
set ppath $opt(-ppath)
set cmd_list $opt(-cmd_list)

Expand Down
125 changes: 73 additions & 52 deletions projects/scripts/adi_project_lattice_pb.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,12 @@ proc adi_project_pb {project_name args} {
set preinst_ip_mod_dir ${env(TOOLRTF)}

array set opt [list -dev_select "auto" \
-ppath "." \
-ppath "./_bld" \
-device "" \
-board "" \
-speed "" \
-language "verilog" \
-psc "" \
-psc "${env(TOOLRTF)}/../../templates/MachXO3D_Template01/MachXO3D_Template01.psc" \
-cmd_list {{source ./system_pb.tcl}} \
{*}$args]

Expand All @@ -58,6 +58,11 @@ proc adi_project_pb {project_name args} {
set cmd_list $opt(-cmd_list)
set psc $opt(-psc)

if {$psc == "${env(TOOLRTF)}/../../templates/MachXO3D_Template01/MachXO3D_Template01.psc"} {
update_template
set psc ./MachXO3D_Template01/MachXO3D_Template01.psc
}

global ad_hdl_dir

if { [string match "auto" $dev_select] } {
Expand Down Expand Up @@ -93,7 +98,7 @@ proc adi_project_pb {project_name args} {
proc adi_project_create_pb {project_name args} {
puts "\nadi_project_create_pb:\n"

array set opt [list -ppath "." \
array set opt [list -ppath "./_bld" \
-device "" \
-board "" \
-speed "" \
Expand Down Expand Up @@ -156,37 +161,19 @@ proc adi_project_create_pb {project_name args} {
set preinst_ip_mod_dir ${env(TOOLRTF)}
set propel_builder_project_dir "$ppath/$project_name/$project_name"

if {$psc == ""} {
file mkdir $propel_builder_project_dir

# Creating the necessary .socproject file for being able to open the Radiant
# and Propel SDK from Propel Builder if needed.
set file [open "$ppath/$project_name/.socproject" w]
puts $file [format {<?xml version="1.0" encoding="UTF-8"?>
<propelProject>
<builder-resource>
<socProject sbxfile="./%s/%s.sbx"/>
</builder-resource>
</propelProject>} $project_name $project_name]
close $file
if {[file exists $ppath] != 1} {
file mkdir $ppath
}

sbp_design new -name $project_name \
-path $propel_builder_project_dir/$project_name.sbx \
-device $device \
-speed $speed \
-language $language \
-board $board
} else {
sbp_create_project -name "$project_name" \
-path $ppath \
-device $device \
-speed $speed \
-language $language \
-psc $psc

foreach port [sbp_get_ports *] {
sbp_delete $port -type port
}
sbp_create_project -name "$project_name" \
-path $ppath \
-device $device \
-speed $speed \
-language $language \
-psc $psc

foreach port [sbp_get_ports *] {
sbp_delete $port -type port
}

sbp_design save
Expand All @@ -197,25 +184,9 @@ proc adi_project_create_pb {project_name args} {
eval $cmd
}

# Workaround for keeping the configured IP folders in Propel Builder 2023.2
# command line version.
# The 'sbp_design save' doesn't saves the temporary .lib folder to lib folder,
# instead deletes if there is anything in lib folder.
# I am copying the content of .lib (the configured IP cores) to lib after save
# to keep the configured IP cores for the Radiant project.
# Also generating the bsp after copying the configured IP cores to lib folder
# because that's also based on the content of lib folder.
#
# Update: - If the psc default template file exists then the save works fine
# and we do not need to generate the bsp separately also.
sbp_design save
sbp_design generate

if {$psc == ""} {
file copy "$propel_builder_project_dir/.lib/latticesemi.com" \
"$propel_builder_project_dir/lib"
}

# Generating the bsp.
sbp_design pge sge \
-i "$propel_builder_project_dir/$project_name.sbx" \
Expand Down Expand Up @@ -335,7 +306,7 @@ proc adi_ip_instance {args} {
# \opt[ip_iname] -ip_iname cpu0_inst
# \opt[ip_niname] -ip_niname new_name_inst
###############################################################################
proc adi_ip_update {args} {
proc adi_ip_update {project_name args} {
array set opt [list -cfg_path "./ipcfg" \
-vlnv "" \
-ip_path "" \
Expand All @@ -354,11 +325,61 @@ proc adi_ip_update {args} {

adi_ip_config {*}$args

global project_name

if {$ip_niname == ""} {
sbp_replace -vlnv $vlnv -name $ip_iname -component $project_name/$ip_iname
} else {
sbp_replace -vlnv $vlnv -name $ip_niname -component $project_name/$ip_iname
}
}

proc update_template {args} {
global env
array set opt [list -dpath "./" \
-template "${env(TOOLRTF)}/../../templates/MachXO3D_Template01" \
]

set dpath $opt(-dpath)
set template $opt(-template)

if {[file exist $dpath] != 1} {
file mkdir $dpath
}
if {[file exist $dpath/MachXO3D_Template01] == 1} {
exec rm -r $dpath/MachXO3D_Template01
}
file copy -force "${env(TOOLRTF)}/../../templates/MachXO3D_Template01" $dpath

set regx {\s+file\s+copy\s+}

puts [pwd]
if {[file exist $dpath/MachXO3D_Template01/MachXO3D_Template01.tcl] == 1} {
set file [open $dpath/MachXO3D_Template01/MachXO3D_Template01.tcl r]
set fdata [read $file]
close $file
set file [open $dpath/MachXO3D_Template01/MachXO3D_Template01.tcl w]
foreach line [split $fdata "\n"] {
if {[regexp $regx $line]} {
puts $file { if {[file exist $targetDir] != 1} {file mkdir $targetDir}}
puts { if {[file exist $targetDir] != 1} {file mkdir $targetDir}}
}
puts $file $line
puts $line
}
close $file
}
if {[file exist $dpath/MachXO3D_Template01/verification/MachXO3D_Template01_v.tcl] == 1} {
set file [open $dpath/MachXO3D_Template01/verification/MachXO3D_Template01_v.tcl r]
set fdata [read $file]
close $file
set file [open $dpath/MachXO3D_Template01/verification/MachXO3D_Template01_v.tcl w]
foreach line [split $fdata "\n"] {
if {[regexp $regx $line]} {
puts $file { if {[file exist $targetDir] != 1} {file mkdir $targetDir}}
puts { if {[file exist $targetDir] != 1} {file mkdir $targetDir}}
}
puts $file $line
puts $line
}
close $file
}
}
Loading
Loading