ParameterTypes Module
Types and nested modules
Functions and values
| Function or value | Description |
Full Usage:
addSlot slot exprSpec slots
Parameters:
ParamSlot
exprSpec : ConstrainedExpr
slots : ComponentSlotExpr
Returns: ComponentSlotExpr
|
|
|
|
|
|
Full Usage:
cLog2Name
Returns: string
|
|
Bits needed to index n things: ceil(log2 n), so clog2 8 = 3 and clog2 9 = 4. 0 and 1 both give 0, as Verilog's $clog2 does. The n <= 1 guard is load-bearing rather than tidiness: >>> on a negative bigint is an arithmetic shift and never reaches 0, so without it a negative argument would loop for ever. The evaluator rejects negatives before calling this, which is where the user-facing message lives. Computed by shifting rather than by System.Math.Log: the float version is wrong at exact powers of two, which is why the one in SheetCreator is commented out.
|
|
|
|
|
|
|
|
Full Usage:
evaluateParamExpression paramBindings paramExpr
Parameters:
ParamBindings
-
Map from parameter names to their bound expressions
paramExpr : ParamExpression
-
The parameter expression to evaluate
Returns: Result<ParamInt, ParamError>
Success: The evaluated integer value if all parameters can be resolved to constants
Error: A human-readable error message listing any unresolved parameters
|
This function recursively evaluates the expression tree, substituting parameter values from the bindings and performing arithmetic operations. Parameters are resolved to their bound expressions, which are then recursively evaluated. If any parameters remain unresolved after full evaluation, an error is returned listing them.
|
Full Usage:
exprContainsParams expression
Parameters:
ParamExpression
-
The expression to check
Returns: bool
True if the expression contains at least one PParameter, false if it only contains constants
|
This function recursively traverses the expression tree to find any PParameter nodes. Useful for determining if an expression can be fully evaluated without parameter bindings.
|
|
|
Full Usage:
intOfParamInt ifTooLarge value
Parameters:
int
value : ParamInt
Returns: int
|
The value as an int, falling back to `ifTooLarge` where it is not one. For the places that have no way to refuse: a component is being created, and its width has already passed the constraints on the box it was typed into - every one of which bounds the width at or below NumberHelpers.Constants.maxIssieBusWidth. So the fallback is a bug path, and the warning is there to say which bound went missing rather than to be read in normal use.
|
Full Usage:
isBuiltinFuncName name
Parameters:
string
Returns: bool
|
|
Full Usage:
isReservedParamName name
Parameters:
string
Returns: bool
|
|
Full Usage:
isValidParamName name
Parameters:
string
Returns: bool
|
The names a parameter may have: a letter, then letters and digits, and not a built-in function. This is exactly the parser's name token, exported so that the two cannot drift apart. They had: names were accepted as `[a-zA-Z0-9]+`, while the tokenizer split `W2X` into `W2` and `X` - so a parameter could be declared under a name and then never referred to. A leading digit is excluded for the same reason read the other way round: `123` would be a number. A built-in function name is excluded for the third form of the same reason: the parser reads `min` as the function, so a parameter of that name could be declared and then never referred to.
|
|
|
|
|
|
|
|
|
Full Usage:
paramBoxKey compId slot
Parameters:
string option
slot : CompSlotName
Returns: ParamSlot
|
|
|
|
|
|
Full Usage:
paramNamesOfExpr expression
Parameters:
ParamExpression
Returns: ParamName list
|
|
Full Usage:
paramNamesOfSlot exprSpec
Parameters:
ConstrainedExpr
Returns: ParamName list
|
|
|
|
Full Usage:
parseExpression text
Parameters:
string
-
The input string to parse
Returns: Result<ParamExpression, ParamError>
Success: The parsed parameter expression
Error: A human-readable error message describing the parsing failure
|
Supports arithmetic expressions with: - Integer constants of any size, which may be negated - Parameter names, which are a letter followed by letters and digits (see isValidParamName) - Binary operators: +, -, *, /, %, <<, >> - Built-in functions: clog2(x), min(x,y), max(x,y), written in any case - Unary minus - Parentheses for grouping Operator precedence (higher binds tighter): - a function call: atomic, being delimited by its own parentheses - unary -: binds tightest of the operators, being part of the operand it precedes - *, /, %: Higher precedence - +, -: Lower precedence - <<, >>: Loosest, as in Verilog and C, so that w+1<<2 shifts the sum The parser uses recursive descent with separate functions for each precedence level.
|
Full Usage:
removeSlot slot slots
Parameters:
ParamSlot
slots : ComponentSlotExpr
Returns: ComponentSlotExpr
|
|
Full Usage:
renderParamExpression expr precedence
Parameters:
ParamExpression
-
The parameter expression to render
precedence : int
-
The precedence context (higher values require more parentheses)
Returns: string
A string representation of the expression with minimal parentheses
|
Precedence levels, which are the parser's read from the other end: - Shifts: 1 - Addition/Subtraction: 2 - Multiplication/Division: 3 - Remainder: 4 (always parenthesized) Parentheses are added when the current operator has lower precedence than the context.
|
|
|
|
Whether two slot names refer to the same field of a component. The label in an `IO` slot is not part of its identity. It records the component's label as it was when the slot was created, and nothing rewrites it when the component is renamed - so a rename would otherwise orphan the slot and let a second one be created for the same field, with which of the two applied decided by Map key order. Every reader already ignores it (ComponentSlots.trySetSlotValue matches `IO _` in every case), so this is what "the same slot" has always meant in effect. The label is kept in the type because existing .dgm files store it, and it is repaired on save by CanvasExtractor.tidyParamSlots so that it stays worth displaying.
|
|
|
|
The value of `value>>places`: division by 2^places, rounding towards minus infinity, which is what makes the shift arithmetic. bigint division truncates towards zero instead, so `-1/2` is 0 where an arithmetic `-1>>1` is -1. Taking the truncating quotient and stepping it down where it threw something away is the same rounding for every value, and is again the same in both runtimes.
|
Full Usage:
slotsUsingParam name slots
Parameters:
ParamName
slots : ComponentSlotExpr
Returns: (ParamSlot * ConstrainedExpr) list
|
|
|
|
Full Usage:
tryFindSlot slot slots
Parameters:
ParamSlot
slots : ComponentSlotExpr
Returns: ConstrainedExpr option
|
|
|
The value as an int, or None when it is too large to be one. Every parameter value that reaches a component field narrower than a bigint goes through here. A width, an index and a bit position are all `int` in ComponentType, and silently wrapping a value that does not fit is how a nonsensical width would otherwise reach the canvas. NumberHelpers.convertBigintToInt32 masks with 0xffffffff instead, so is not this.
|