Debugging cells¶
The $print cell is used to log the values of signals, akin to (and
translatable to) the $display and $write family of tasks in Verilog. It
has the following parameters:
FORMATThe internal format string. The syntax is described below.
ARGS_WIDTHThe width (in bits) of the signal on the
ARGSport.TRG_ENABLETrue if triggered on specific signals defined in
TRG; false if triggered wheneverARGSorENchange andENis 1.
If TRG_ENABLE is true, the following parameters also apply:
TRG_WIDTHThe number of bits in the
TRGport.TRG_POLARITYFor each bit in
TRG, 1 if that signal is positive-edge triggered, 0 if negative-edge triggered.PRIORITYWhen multiple
$printor$checkcells fire on the same trigger, they execute in descending priority order.
Ports:
TRGThe signals that control when this
$printcell is triggered.If the width of this port is zero and
TRG_ENABLEis true, the cell is triggered during initial evaluation (time zero) only.ENEnable signal for the whole cell.
ARGSThe values to be displayed, in format string order.
- yosys> help $check¶
- Simulation model (verilog)¶
2242module \$check (A, EN, TRG, ARGS); 2243 2244 parameter FLAVOR = ""; 2245 parameter PRIORITY = 0; 2246 2247 parameter FORMAT = ""; 2248 parameter ARGS_WIDTH = 0; 2249 2250 parameter TRG_ENABLE = 1; 2251 parameter TRG_WIDTH = 0; 2252 parameter TRG_POLARITY = 0; 2253 2254 input A; 2255 input EN; 2256 input [TRG_WIDTH-1:0] TRG; 2257 input [ARGS_WIDTH-1:0] ARGS; 2258 2259endmodule
- yosys> help $print¶
- Simulation model (verilog)¶
2222module \$print (EN, TRG, ARGS); 2223 2224 parameter PRIORITY = 0; 2225 2226 parameter FORMAT = ""; 2227 parameter signed ARGS_WIDTH = 0; 2228 2229 parameter TRG_ENABLE = 1; 2230 parameter signed TRG_WIDTH = 0; 2231 parameter TRG_POLARITY = 0; 2232 2233 input EN; 2234 input [TRG_WIDTH-1:0] TRG; 2235 input [ARGS_WIDTH-1:0] ARGS; 2236 2237endmodule
- yosys> help $scopeinfo¶
- Simulation model (verilog)¶
3214module \$scopeinfo (); 3215 3216 parameter TYPE = ""; 3217 3218endmodule
Format string syntax¶
The format string syntax resembles Python f-strings. Regular text is passed
through unchanged until a format specifier is reached, starting with a {.
Format specifiers have the following syntax. Unless noted, all items are required:
{Denotes the start of the format specifier.
- size
Signal size in bits; this many bits are consumed from the
ARGSport by this specifier.:Separates the size from the remaining items.
- justify
>for right-justified,<for left-justified.- padding
0for zero-padding, or a space for space-padding.- width?
(optional) The number of characters wide to pad to.
- base
bfor base-2 integers (binary)ofor base-8 integers (octal)dfor base-10 integers (decimal)hfor base-16 integers (hexadecimal)cfor ASCII characters/stringstandrfor simulation time (corresponding to$timeand$realtime)
For integers, this item may follow:
+?(optional, decimals only) Include a leading plus for non-negative numbers. This can assist with symmetry with negatives in tabulated output.
- signedness
ufor unsigned,sfor signed. This distinction is only respected when rendering decimals.
ASCII characters/strings have no special options, but the signal size must be divisible by 8.
For simulation time, the signal size must be zero.
Finally:
}Denotes the end of the format specifier.
Some example format specifiers:
{8:>02hu}- 8-bit unsigned integer rendered as hexadecimal, right-justified, zero-padded to 2 characters wide.{32:< 15d+s}- 32-bit signed integer rendered as decimal, left-justified, space-padded to 15 characters wide, positive values prefixed with+.{16:< 10hu}- 16-bit unsigned integer rendered as hexadecimal, left-justified, space-padded to 10 characters wide.{0:>010t}- simulation time, right-justified, zero-padded to 10 characters wide.
To include literal { and } characters in your format string, use {{
and }} respectively.
It is an error for a format string to consume more or less bits from ARGS
than the port width.
Values are never truncated, regardless of the specified width.
Note that further restrictions on allowable combinations of options may apply depending on the backend used.
For example, Verilog does not have a format specifier that allows zero-padding a string (i.e. more than 1 ASCII character), though zero-padding a single character is permitted.
Thus, while the RTLIL format specifier {8:>02c} translates to %02c,
{16:>02c} cannot be represented in Verilog and will fail to emit. In this
case, {16:> 02c} must be used, which translates to %2s.