fvm.drom2psl.interpret module

Functions to actually interpret the wavedrom dictionary

fvm.drom2psl.interpret.adapt_value_to_hdltype(value)[source]

Adds the necessary characters (such as simple or double quotes, 0x, etc) to convert a literal value to a properly formated VHDL datatype

The input value can be either a single character with a valid std_ulogic value, or (value, type) tuple where type is one of the following:

  • "bin" (binary)

  • "hex" (hexadecimal)

  • "int" (integer)

  • "arg" (argument)

Parameters:

value (single-char str or tuple) – value to convert

Returns:

adapted value

Return type:

str

fvm.drom2psl.interpret.assign_datatypes(data, datatype)[source]

Assign datatypes to data elements correctly even if datatype is a string that looks like a list.

fvm.drom2psl.interpret.check_wavelane(wavelane)[source]

Check wavelane for correctness.

In normal wavedrom, a wavelane is always correct if it is a dictionary. It can be empty, but it can also have ‘name’, ‘wave’, ‘data’ or ‘node’ fields.

We’ll be a bit more restrictive:
  • We will allow (and ignore) empty wavelanes

  • If a wavelane is not empty, it needs to have at least a ‘name’ field

  • For now we will allow not having a ‘wave’ field, but probably we will need to check for that too, because having empty waves or no waves doesn’t make much sense

Parameters:

wavelane (dict) – wavelane to analyze

Returns:

True if ok, False if there are any errors

Return type:

bool

fvm.drom2psl.interpret.classify_value(value)[source]

Return (value, type)

fvm.drom2psl.interpret.data2list(wavelane_data)[source]

Converts wavelane data to a list if it is a string, returns it untouched if it is already a list

fvm.drom2psl.interpret.exclude_data_types(datalist)[source]

Exclude VHDL types from a data list

fvm.drom2psl.interpret.expand_concatenations(datalist)[source]

Expands any element containing ‘&’ into separate elements.

Example

[“a”, “b & c & d”] → [“a”, “b”, “c”, “d”]

fvm.drom2psl.interpret.flatten(group, signal, flattened=None, hierarchyseparator='.')[source]

Flatten the signal field.

We do this by generating a new list of signalelements where there are no groups: instead, groups/subgroup names are added as prefixes to the name field of each wavelane that is inside a group

For each signalelement:
  • if it is a signal, just append it to the flattened list - to do that, first copy the original wavelane - and then append the current group name to the wavelane’s name field

  • if it is a group, flatten it recursively: set the group name as the new prefix and call flatten passing it the rest of the element

  • if it is a string, something is wrong (strings should be only the names of the groups, and we should have caught that when operating with the group)

Parameters:
  • group (str) – group prefix from which the signal descends

  • signal (list) – signal to flatten

  • flattened (list or None) – already flattened signal (for recursive flattening groups)

  • hierarchyseparator (str) – hierarchy separator for the flattened representation

Returns:

a (flattened, ok) tuple. flattened is the flattened signal, ok is True if there were no errors, False if there were any

Type:

(list, bool)

fvm.drom2psl.interpret.gen_sere_repetition(num_cycles, or_more, add_semicolon=False, comments=True)[source]

Generates the SERE repetition operator according to the number of cycles received and if N ‘or more’ cycles can be matched

fvm.drom2psl.interpret.get_clock_value(wavelane, cycle)[source]

Get the value of the clock during a specific cycle of the wavelane. This value is not an electronic signal value (such as zero, one, rising_edge, etc) but a binary coded value that tells us if that cycle is to be repeated or not:

  • 1: Do once

  • 0: Repeat zero or more times

Parameters:
  • wavelane (dict) – wavelane of the clock signal

  • cycle (integer) – clock cycle

Returns:

clock repeat value (0 or 1)

Return type:

int

fvm.drom2psl.interpret.get_group_arguments(groupname, flattened_signal)[source]

Get the arguments of a group

A group is a set of wavelanes which are grouped together in the .json, and its arguments are all values in the data field of its wavelanes that are not literal values. For example if a wavelane inside a group has a data field that is [0, 127, addr, 42] then addr is an argument for the group.

Parameters:
  • groupname (string) – name of the group

  • flattened_signal (string) – a flattened signal

Returns:

a list of arguments for the group

Return type:

list

fvm.drom2psl.interpret.get_group_name(group)[source]

Get name of group.

The name of the group is the first element of the list, which should be a string

Parameters:

group (list) – group from which to get the name

Returns:

the group name

Return type:

str

fvm.drom2psl.interpret.get_signal(dictionary)[source]

Get signal field from dictionary

Parameters:

dictionary (dict) – wavedrom dictionary

Returns:

a (signal_list, ok) tuple. signal_list is the signal field, ok is True if there were no errors, False if there were any

Type:

(list, bool)

fvm.drom2psl.interpret.get_signal_value(wave, data, cycle)[source]

Get value of signal at a specific clock cycle

fvm.drom2psl.interpret.get_type(element)[source]

Get the type of a signal element.

  • A wavelane is a dictionary

  • A group of wavelanes is a list

Parameters:

element (dict or list) – signal element to analyze

Returns:

one of the following: WAVELANE, GROUP, STRING, “others”

Return type:

str

fvm.drom2psl.interpret.get_wavelane_data(wavelane)[source]

Get the data field of a wavelane, if it exists

Parameters:

wavelane (dict) – wavelane whose data we want to get

Returns:

data field of the wavelane

Return type:

can be list or a string, use data2list to ensure it is a list

fvm.drom2psl.interpret.get_wavelane_name(wavelane)[source]

Get the name field of a wavelane

Parameters:

wavelane (dict) – wavelane whose name we want to get

Returns:

name of the wavelane

Return type:

string

fvm.drom2psl.interpret.get_wavelane_type(wavelane)[source]

Get the type field of a wavelane, if it exists

Parameters:

wavelane (dict) – wavelane whose type we want to get

Returns:

type field of the wavelane

Return type:

string

fvm.drom2psl.interpret.get_wavelane_wave(wavelane)[source]

Get the wave field of a wavelane

Parameters:

wavelane (dict) – wavelane whose wave we want to get

Returns:

wave field of the wavelane

Return type:

string

fvm.drom2psl.interpret.is_empty(wavelane)[source]

Check if wavelane is empty.

Parameters:

wavelane (dict) – wavelane to check

Returns:

True if empty, False if not empty

Return type:

bool

fvm.drom2psl.interpret.is_pipe(wavelane, cycle)[source]

Returns True if the ‘data’ at ‘cycle’ in ‘wave’ is a pipe (|), which means: ‘repeat zero or more times’

fvm.drom2psl.interpret.list_elements(prefix, signal)[source]

List all elements in a signal

Parameters:
  • prefix (str) – prefix for printing debugging messages

  • signal (list) – signal to list

Returns:

None

Return type:

None

fvm.drom2psl.interpret.list_signal_elements(prefix, signal)[source]

List elements in signal field

Parameters:
  • prefix (str) – prefix for printing debugging messages

  • signal (list) – signal field

Returns:

None

Return type:

None

fvm.drom2psl.interpret.process_concatenation(expr)[source]

Process a concatenation expression into PSL format

fvm.drom2psl.interpret.process_value(value)[source]

Process a value according to its type

fvm.drom2psl.interpret.remove_parentheses(string)[source]

Removes anything between parentheses, including the parentheses, from a string

fvm.drom2psl.interpret.remove_psl_operators(datalist)[source]
Removes any element from the list that matches:

prev(arg) or prev(arg, N)

fvm.drom2psl.interpret.split_concatenation(expr)[source]

Splits a concatenation expression into its parts