|
SILICON
|

Files | |
| silicon_bmux_case.cpp | |
| silicon_import.cpp | |
| silicon_legalize.cpp | |
| silicon_structure.cpp | |
elaborateHierarchy accepts raw Yosys JSON. It runs silicon_legalize after hierarchy/muxpack and writes SILICON-legalized Yosys JSON for deserialize. Direct deserialize callers must supply that legalized form. readVerilog resolves parameterized module instances while the frontend AST is available, lowers processes, and then returns raw JSON. serialize also emits raw Yosys cells and may need legalization before import.
The ordered entry point runs:
The expression passes only touch selected cells. Each changes raw cells to a canonical type once; a second invocation leaves those cells unchanged.
The importer accepts $and, $or, $xor, $not, $_NAND_, $_NOR_, $pos, $add, $sub, $neg, $mux, $bmux, $demux, scalar zero-reset $adffe, declared module instances, and the existing SILICON_* technology cells listed in cells.hpp, including SILICON_ROM. Native $mul, $div, $mod, $dff, $dffsr, $dffsre, and supported $dlatch cells are converted to technology cells before this boundary and are rejected by both silicon_validate and the direct importer if they remain. Native $add and $sub still reach the importer when their geometry is not covered by technology mapping; both sign extend only when both operands are signed and truncate the result to the output width. Vector $adffe cells map to SILICON_PIPO; only scalar zero-reset $adffe cells reach the native handler.
$neg cells map directly to the two's-complement Complementer component, which also exports as $neg. Zero-minus-operand $sub cells are lowered to $neg by the technology map, sign extending only when both subtraction operands are signed. Negation operands are sign or zero extended, or truncated, to the output width before negation.
$mul maps to SILICON_MULTIPLIER; $div and $mod map to the div and mod outputs of SILICON_DIVIDER, whose inputs are A and B. Like SILICON_ADDER, these technology cells use WIDTH and a single SIGNED parameter and have behavioral, black-box, and export mappings in silicon_cells.v. SILICON_ADDER requires SIGNED=0, matching the unsigned adder component. They round-trip directly to the Multiplier and Divider components. Both components expose size, delay, and signed properties. All component buses have size bits; multiplication keeps the low bits and signed division truncates toward zero. Division by zero drives unknown outputs. Import extends operands to the widest input/output width, using sign extension only when both inputs are signed, then truncates the result.
Declared module instances may omit unused output ports or connect them to empty arrays. Each unused output receives a private bus at its declared width. Inputs are required, and connected ports retain width and driver-ownership validation.
Additional expression contracts:
silicon_validate rejects any cell outside this subset, including writable memories and unsupported operators. The memory pass diagnoses unsupported ROM configuration before validation.
silicon_gates folds compatible AND/OR chains into gates with multiple inputs. Only selected gates whose complete output has one consumer are absorbed; shared outputs, bit taps, keep attributes, and feedback loops prevent contraction. The importer decodes the resulting canonical cells, and the editor expands gate symbols to fit their inputs.
silicon_mux combines mux trees when every branch is a private mux with the same child selector and data width. Combined selectors put the root bits first, which preserves UNKNOWN/ERROR precedence. Combined selectors are limited to eight bits. Priority chains, independent branch selectors and tapped intermediate outputs keep their original structure. Both structure passes respect selection and keep attributes and can be run repeatedly without further changes.
The mux pass also makes repeated lanes share a single data input. The optional selectionTable property lists data-port indices in binary selector order, for example 0,1,0,2 for a two-bit selector with three distinct choices. Empty uses the ordinary one-input-per-selection layout. Table indices must cover every selector value and use contiguous data-port indices starting at zero. Clear the table before changing the selector width. Native save/load preserves the compact layout; Yosys export expands it to a standard $bmux. Port tooltips list selector values.
Import keeps contiguous source slices as buses. One shared WireSplitter per source exposes only the requested slices, including overlapping slices; an ordinary part-select does not need a WireMerger. Concatenations use one merger input per contiguous source or literal run. Repeated sign bits and high zero padding of a contiguous source slice become Extender components.
WireSplitter retains its total input size. Its optional slices property is a comma-separated list of offset:width pairs in output-port order, for example 0:8,8:8,0:16 for two bytes and an overlapping half-word. An empty value retains the original individual-bit outputs. WireMerger has an optional widths property listing input widths in least-significant-first order, for example 8,8,16 for a 32-bit output. The widths must sum to size; an empty value retains individual-bit inputs. Both configurations survive native save/load and Verilog export. The editor labels bus ports with their bit ranges.