xlsynth_codegen/options.rs
1// SPDX-License-Identifier: Apache-2.0
2
3use serde::{Deserialize, Serialize};
4use xlsynth::vast_helpers_options::CodegenOptions;
5
6/// Controls whether a block is presented in register-delimited stage sections.
7#[derive(Clone, Copy, Debug, Default, Eq, PartialEq, Deserialize, Serialize)]
8#[serde(rename_all = "snake_case")]
9pub enum Layout {
10 /// Emit declarations and logic in ordinary dependency order.
11 #[default]
12 None,
13 /// Partition feed-forward logic into explicitly labeled pipeline stages.
14 Pipeline,
15}
16
17/// Configures faithful SystemVerilog emission of an existing block.
18#[derive(Clone, Debug, Deserialize, Serialize)]
19#[serde(default, deny_unknown_fields)]
20pub struct BlockCodegenOptions {
21 /// Overrides package top selection when present.
22 pub top: Option<String>,
23 /// Controls declaration and pipeline-stage layout.
24 pub layout: Layout,
25 /// Overrides the generated top module name when present.
26 pub module_name: Option<String>,
27 /// Clamps dynamic array reads to the last valid element when enabled.
28 pub array_index_bounds_checking: bool,
29 /// Emits every representable operation as its own named assignment.
30 pub separate_lines: bool,
31 /// Bounds expression nesting before introducing a named intermediate.
32 pub max_inline_depth: usize,
33 /// Preserves SystemVerilog type annotations on block ports.
34 pub emit_sv_types: bool,
35 /// Emits assert operations present in the input block.
36 pub emit_asserts: bool,
37 /// Supplies optional register-lowering templates and related options.
38 pub register_codegen_options: Option<CodegenOptions>,
39}
40
41impl Default for BlockCodegenOptions {
42 fn default() -> Self {
43 Self {
44 top: None,
45 layout: Layout::None,
46 module_name: None,
47 array_index_bounds_checking: true,
48 separate_lines: false,
49 max_inline_depth: 5,
50 emit_sv_types: true,
51 emit_asserts: true,
52 register_codegen_options: None,
53 }
54 }
55}
56
57/// Contains the emitted SystemVerilog source.
58#[derive(Clone, Debug, Eq, PartialEq)]
59pub struct BlockCodegenOutput {
60 /// Complete, deterministically ordered SystemVerilog source.
61 pub system_verilog: String,
62}