python2verilog.utils package

Submodules

python2verilog.utils.cytoscape module

python2verilog.utils.decorator module

Special decorator primatives

decorator_with_args(func)[source]

a decorator decorator, allowing the decorator to be used as: @decorator(with, arguments, and=kwargs) or @decorator

Note: can’t distinguish between a function as a parameter vs a function to-be decorated

python2verilog.utils.env module

Special env variable functions

class Vars(value)[source]

Bases: Enum

Env var names

DEBUG_COMMENTS = 'PYTHON_2_VERILOG_DEBUG_COMMENTS'
DEBUG_MODE = 'PYTHON_2_VERILOG_DEBUG'
IS_SYSTEM_VERILOG = 'PYTHON_2_VERILOG_SYSTEM_VERILOG'
IVERILOG_PATH = 'PYTHON_2_VERILOG_IVERILOG_PATH'
NO_WRITE_TO_FS = 'PYTHON_2_VERILOG_NO_WRITE_TO_FS'
get_var(name: Vars)[source]

Get an env var

is_debug_mode()[source]
Returns:

True if in debug mode, false otherwise

set_debug_mode(mode: bool)[source]

Sets the debug mode of package

set_var(name: Vars, value: str | None)[source]

Set an env var

python2verilog.utils.fifo module

Fifo wrappers

temp_fifo() Iterator[str][source]

Create a temporary fifo

python2verilog.utils.generics module

Implementation of generic base classes for __repr__ and __str__

class GenericRepr[source]

Bases: object

Implements a generic __repr__ based on self.__dict__

class GenericReprAndStr[source]

Bases: GenericRepr

Implements a generic __repr__ and __str__ based on self.__dict__

pretty_dict(dic: dict[Any, Any], indent: int = 0) str[source]

Returns pretty-formatted stringified dict

python2verilog.utils.lines module

Utility Classes

class ImplementsToLines[source]

Bases: object

A base class defining an interface for classes that need to provide a ‘to_lines’ method

to_lines()[source]

To Lines

to_string()[source]

To string

class Indent(indent: int = 0)[source]

Bases: object

Creates str instances of indentation

indentify(indent: int = 0) str[source]

Creates indentation

indentor = '    '
class Lines(data: list[str] | str | None = None)[source]

Bases: object

A list of str that can be serialized to string with provided indents

add(other: str)[source]

Adds a new line

static assert_no_newline(string: str)[source]

Asserts no newline character in string

blank()[source]

Adds a blank line

concat(other: Lines, indent: int = 0)[source]

Concats two Lines

indent(indent_amount: int)[source]

Indent all lines by amount

static nestify(buffers: list[tuple[Lines, Lines]], indent: int = 0)[source]
pair[0][0]
pair[1][0]

pair[2][0] pair[2][1]

pair[1][0]

pair[0][1]

to_string(indent: int = 0)[source]

Converts all lines into a string with lines

python2verilog.utils.mit_license module

Text for MIT license

get_mit_license() Lines[source]

Text of MIT license

python2verilog.utils.peek_counter module

Peekable counter

class PeekCounter(start: int = 0)[source]

Bases: Iterable[int]

Peekable counter

Based on itertools.count

next() int[source]

Gets next value in count

peek() int[source]

Peeks next value in count

python2verilog.utils.typed module

Type assertion utilities

guard(obj: Any, type_: Type[_ValueType]) TypeGuard[_ValueType][source]

Type guard for type

guard_dict(obj: dict[Any, Any], key_type: Type[_KeyType], value_type: Type[_ValueType]) TypeGuard[dict[_KeyType, _ValueType]][source]

Asserts that all key, values in dict_ are correctly typed,

typed(obj: _ValueType | None, type_: Type[_ValueType]) _ValueType | None[source]

Asserts that obj is of type type_, then returns obj or None if obj is None

typed_list(list_: list[Any] | None, type_: Type[_ValueType]) list[_ValueType][source]

Asserts that all elems in list_ are of type_, then returns list_ or [] if list_ is None

typed_strict(obj: _ValueType | None, type_: Type[_ValueType]) _ValueType[source]

Asserts that obj is of type type_

python2verilog.utils.visualization module

Module contents

Utilities