Skip to content

Commit 5296e76

Browse files
committed
Add Xcelium script format
Add Cadence Xcelium as a new script format target. The template generates -makelib/-endlib blocks per dependency package with per-group incdirs and defines, while root package files are emitted as bare entries. - Add Xcelium variant to ScriptFormat with --relative-path option - Default targets: xcelium, simulation - Add name field to TplSrcStruct (package name from source group) - Add root_package to template context for root vs library distinction - Add xcelium_f.tera template with hyphen-to-underscore library name sanitization
1 parent fe5de32 commit 5296e76

2 files changed

Lines changed: 42 additions & 0 deletions

File tree

src/cmd/script.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,12 @@ pub enum ScriptFormat {
183183
#[arg(long, action = ArgAction::Append, alias = "vcom-arg")]
184184
vcom_args: Vec<String>,
185185
},
186+
/// Cadence Xcelium script
187+
Xcelium {
188+
/// Use relative paths
189+
#[arg(long)]
190+
relative_path: bool,
191+
},
186192
/// Cadence Genus script
187193
Genus,
188194
/// Xilinx Vivado synthesis script
@@ -250,6 +256,7 @@ pub fn run(sess: &Session, args: &ScriptArgs) -> Result<()> {
250256
ScriptFormat::Synopsys { .. } => vec!["synopsys", "synthesis"],
251257
ScriptFormat::Formality => vec!["synopsys", "synthesis", "formality"],
252258
ScriptFormat::Riviera { .. } => vec!["riviera", "simulation"],
259+
ScriptFormat::Xcelium { .. } => vec!["xcelium", "simulation"],
253260
ScriptFormat::Genus => vec!["genus", "synthesis"],
254261
ScriptFormat::Vivado { .. } => concat(vivado_targets, &["synthesis"]),
255262
ScriptFormat::VivadoSim { .. } => concat(vivado_targets, &["simulation"]),
@@ -370,6 +377,10 @@ pub fn run(sess: &Session, args: &ScriptArgs) -> Result<()> {
370377
tera_context.insert("vcom_args", vcom_args);
371378
include_str!("../script_fmt/riviera_tcl.tera")
372379
}
380+
ScriptFormat::Xcelium { relative_path } => {
381+
tera_context.insert("relativize_path", relative_path);
382+
include_str!("../script_fmt/xcelium_f.tera")
383+
}
373384
ScriptFormat::Genus => include_str!("../script_fmt/genus_tcl.tera"),
374385
ScriptFormat::Vivado { no_simset, only } | ScriptFormat::VivadoSim { no_simset, only } => {
375386
only_args = only.clone();
@@ -443,6 +454,7 @@ fn emit_template(
443454
) -> Result<()> {
444455
tera_context.insert("HEADER_AUTOGEN", HEADER_AUTOGEN);
445456
tera_context.insert("root", sess.root);
457+
tera_context.insert("root_package", &sess.manifest.package.name);
446458
// tera_context.insert("srcs", &srcs);
447459
tera_context.insert("abort_on_error", &!args.no_abort_on_error);
448460

@@ -516,6 +528,7 @@ fn emit_template(
516528
},
517529
|src, ty, files| {
518530
split_srcs.push(TplSrcStruct {
531+
name: src.package.map(|s| s.to_string()),
519532
metadata: {
520533
let package = src.package.unwrap_or("None");
521534
let target = src.target.reduce().to_string();
@@ -607,6 +620,7 @@ fn emit_template(
607620

608621
#[derive(Debug, Serialize)]
609622
struct TplSrcStruct {
623+
name: Option<String>,
610624
metadata: String,
611625
defines: IndexSet<(String, Option<String>)>,
612626
incdirs: IndexSet<PathBuf>,

src/script_fmt/xcelium_f.tera

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# {{ HEADER_AUTOGEN }}
2+
{%- for group in srcs %}
3+
{%- if group.name and group.name != root_package %}
4+
{#- Sanitize library name for Xcelium (avoid hyphens) -#}
5+
{% set safe_name = group.name | replace(from="-", to="_") %}
6+
-makelib {{ safe_name }}
7+
{%- for incdir in group.incdirs %}
8+
+incdir+{% if relativize_path and incdir is starting_with(root) %}{{ incdir | replace(from=root, to='$ROOT') }}{% else %}{{ incdir }}{% endif %}
9+
{%- endfor %}
10+
{%- for define in group.defines %}
11+
+define+{{ define.0 }}{% if define.1 %}={{ define.1 }}{% endif %}
12+
{%- endfor %}
13+
{%- for file in group.files %}
14+
{% if relativize_path and file is starting_with(root) %}{{ file | replace(from=root, to='$ROOT') }}{% else %}{{ file }}{% endif %}
15+
{%- endfor %}
16+
-endlib
17+
{%- else %}
18+
{%- for incdir in group.incdirs %}
19+
+incdir+{% if relativize_path and incdir is starting_with(root) %}{{ incdir | replace(from=root, to='$ROOT') }}{% else %}{{ incdir }}{% endif %}
20+
{%- endfor %}
21+
{%- for define in group.defines %}
22+
+define+{{ define.0 }}{% if define.1 %}={{ define.1 }}{% endif %}
23+
{%- endfor %}
24+
{%- for file in group.files %}
25+
{% if relativize_path and file is starting_with(root) %}{{ file | replace(from=root, to='$ROOT') }}{% else %}{{ file }}{% endif %}
26+
{%- endfor %}
27+
{%- endif %}
28+
{%- endfor %}

0 commit comments

Comments
 (0)