4.3.4. undulate.renderers.termrenderer module
termrenderer.py use the logic of renderer.py to render waveforms into textual representation in the available space
- class undulate.renderers.termrenderer.TermRenderer(**kwargs)
Bases:
undulate.renderers.renderer.Renderer
Render the wavelanes as UTF8/ASCII text based on the trce representation of https://github.com/UCSBarchlab/PyRTL
Note
For now, only black and white representation is supported
- brick(prv: undulate.bricks.generic.Brick, cur: undulate.bricks.generic.Brick, nxt: undulate.bricks.generic.Brick, **kwargs) Tuple[float, str]
Draw the symbol of a given Brick element
- wavelane(name: str, wavelane: str, **kwargs) str
Draw the internal Dict[str, Any] representing a waveform inside a waveform group.
the internal Dict[str, Any] is expected to have at least the following two keys:
name : name of the waveform
wavelane : string which describes the waveform
- Parameters
name (str) – name of the waveform
wavelane (str) – string of symbols describing the waveform
extra (str) – extra information given to self.group()
y (float) – global y position of the wavelane in the drawing context
- wavegroup(name: str, wavelanes, depth: int = 1, **kwargs) str
Draw a group of waveforms
- Parameters
name (str) – name of the waveform group
wavelanes (Dict[str, dict]) – named waveforms composing the group
depth (int) – depth of nested groups to represent hierarchy
config (Dict[str, Any]) – config section of the input file
brick_width (float) – width of a brick, default is 20.0
brick_height (float) – height of a brick, default is 20.0
width (float) – image width
height (float) – image height
- draw(wavelanes: dict, **kwargs) str
Business function calling all others
- Parameters
wavelanes (dict) – parsed dictionary from the input file
filename (str) – file name of the output generated file
brick_width (int) – by default 40
brick_height (int) – by default 20
is_reg (bool) – if True wavelanes given represents a register otherwise it represents a bunch of signals
- static adjust_y(index, brick_height: float = 1.0) float
Convert an integer expression the index of the waveform as a y-coordinate in the drawing context
- Parameters
y (int) – index of the waveform
brick_height (float) – height of a brick
- Returns
equivalent y-coordinate
- annotate(wavelanes: dict, viewport: tuple, **kwargs) str
Draw edges, vertical lines, horizontal lines, global time compression, … or any other shape defined in the annotations section of the input file
Example
{"annotations": [ {"shape": "||", "x": 3.5}, {"shape": "-~>", "from": "trigger", "to": "event", "text": "ready"} ]}
- Parameters
wavelanes (Dict) – global signals representations
viewport (Tuple[float, float, float, float]) – the drawable zone (excluding signal names) x, y, width, height
edges (Dict) – edge section of the input file
annotations (List[Dict]) – annotations section of the input file
brick_width (float) – default width of a brick
brick_height (float) – default height of a brick
- arrow(arrow_description: undulate.bricks.generic.ArrowDescription, **kwargs) str
Draw an arrow to represent edge trigger on clock signals or to point something in an annotation.
- Parameters
arrow_description (ArrowDescription) – position and oriantation
style_repr (optional str) – css rule, by default ‘arrow’
- static from_to_parser(s: object, width: float, height: float, brick_width: float = 40.0, brick_height: float = 20.0) undulate.bricks.generic.Point
Parse the from and to options of annotations into positions for drawing the specified shape or text
Supported format are: - float - Tuple[float, float] - String “float” - String “float unit” where unit is either “” or “%” - String “(float unit, float unit)” where unit is either “” or “%” - String “node_name” - String “node_name + (± float, ± float)”
- Parameters
s (str) – value of from or to option
width (float) – width of the image
height (float) – height of the image
brick_width (float, default=40) – brick width
brick_height (float, default=40) – brick height
- Returns
Point of x-y coordinate
- group(callback, identifier: str, **kwargs) str
Group some drawable together
- Parameters
callback (callable) – function which populate what inside the group
identifier (str) – unique id for the group
- path(vertices: List[undulate.bricks.generic.Point], **kwargs) str
Draw line segments to connect consecutive points of ‘vertices’ to represent common signals
- Parameters
vertices (List[Point]) – list of points to be connected
style_repr (optional str) – css rule, by default ‘path’
- polygon(vertices: List[undulate.bricks.generic.Point], **kwargs) str
Draw a closed shape for shaded/colored area
- Parameters
vertices (List[Point]) – Ordered list of point delimiting the polygon
style_repr (optional str) – css rule, by default None
- size(wavelanes, depth: int = 1, **kwargs)
Pre-estimate the size of the image (duplicate of wavegroup without drawing)
- Parameters
name (str) – name of the waveform group
wavelanes (Dict[str, dict]) – named waveforms composing the group
depth (int) – depth of nested groups to represent hierarchy
config (Dict[str, Any]) – config section of the input file
brick_width (float) – width of a brick, default is 20.0
brick_height (float) – height of a brick, default is 20.0
width (float) – image width
height (float) – image height
Warning
Might be good to implement a parameter no_drawing in wavegroup and performs 2 passes to prevent possible discrepency
- spline(vertices: List[undulate.bricks.generic.SplineSegment], **kwargs) str
Draw a path to represent smooth signals
- Parameters
vertices (List[SplineSegment]) – list of SVG path operators and arguments
style_repr (optional str) – css rule, by default ‘path’
- text(x: float, y: float, text: str = '', **kwargs) str
Draw a text at a specific position
- Parameters
x (float) – x coordinate of the text
y (float) – y coordinate of the text
text (str) – text to display
style_repr (optional str) – css rule, by default ‘text’
- ticks(width: int, height: int, step: float, **kwargs) str
Generates the dotted vertical lines to ease reading of waveforms and their respective alignment
- Parameters
width (int) – width of the image
height (int) – height of the image
step (float) – distance between two ticks
offsetx (optional) – shift all ticks along the x-axis
offsety (optional) – shift to the bottom ticks with exceeding the height
phase (optional) – phase of the first signal on the top level this parameter is used to align tick with the rising edges of the first signal
- translate(x: float, y: float, **kwargs) str
translation function that is inherited for svg and eps
- wavelane_title(name: str, **kwargs) str
Draw the title in front of a waveform
- Parameters
name (str) – name of the waveform print alongside
order (int) –
position from 0-4 of the title position along the y-axis. This property is important when overlaying signals
0 : middle of the wavelane height, is the default
1-4 : quarter from top to bottom of the wavelane
brick_height (float) – height a brick