python2verilog.backend.verilog package¶
Submodules¶
python2verilog.backend.verilog.ast module¶
Verilog Abstract Syntax Tree Components
- class Always(trigger: Expression, *args, body: list[Statement] | None = None, **kwargs)[source]¶
Bases:
Statement
- always () begin
…
end
- class AtNegedge(condition: Expression)[source]¶
Bases:
Expression
@(negedge <condition>)
- class AtNegedgeStatement(condition: Expression, *args, **kwargs)[source]¶
Bases:
Statement
@(negedge <condition>);
- class AtPosedge(condition: Expression)[source]¶
Bases:
Expression
@(posedge <condition>)
- class AtPosedgeStatement(condition: Expression, *args, **kwargs)[source]¶
Bases:
Statement
@(posedge <condition>);
- class BlockingSub(lvalue: Var, rvalue: Expression, *args, **kwargs)[source]¶
Bases:
Subsitution
<lvalue> = <rvalue>
- class Case(expression: Expression, case_items: list[CaseItem], *args, **kwargs)[source]¶
Bases:
Statement
Verilog case statement with various cases case (<expression>)
<items[0]> … <items[n]>
endcase
- class CaseItem(condition: Expression, statements: list[Statement])[source]¶
Bases:
ImplementsToLines
Verilog case item, i.e. <condition>: begin
<statements>
end
- class Declaration(name: str, *args, size: int = 32, reg: bool = False, signed: bool = False, **kwargs)[source]¶
Bases:
Statement
<reg or wire> <modifiers> <[size-1:0]> <name>;
- class IfElse(condition: Expression, then_body: list[Statement], else_body: list[Statement] | None, *args, **kwargs)[source]¶
Bases:
Statement
Verilog if else
- class Initial(*args, body: list[Statement] | None = None, **kwargs)[source]¶
Bases:
Statement
- initial begin
…
end
- class Instantiation(module_name: str, given_name: str, port_connections: dict[str, str], *args, **kwargs)[source]¶
Bases:
Statement
Instantiationo f Verilog module. <module-name> <given-name> (…);
- class LocalParam(name: str, value: UInt, *args, **kwargs)[source]¶
Bases:
Statement
localparam <name> = <value>;
- class Module(name: str, body: list[Statement] | None = None, localparams: dict[str, UInt] | None = None, header: Lines | None = None)[source]¶
Bases:
ImplementsToLines
module name(…); endmodule
- class NonBlockingSubsitution(lvalue: Var, rvalue: Expression, *args, **kwargs)[source]¶
Bases:
Subsitution
<lvalue> <= <rvalue>
- class PosedgeSyncAlways(clock: Expression, *args, **kwargs)[source]¶
Bases:
Always
- always @(posedge <clock>) begin
<valid> = 0;
end
- class Statement(literal: str = '', comment: str = '')[source]¶
Bases:
ImplementsToLines
,GenericRepr
Represents a statement in verilog (i.e. a line or a block) If used directly, it is treated as a string literal
- class Subsitution(lvalue: Var, rvalue: Expression, oper: str, *args, **kwargs)[source]¶
Bases:
Statement
Interface for <lvalue> <blocking or nonblocking> <rvalue>
python2verilog.backend.verilog.codegen module¶
Verilog Codegen
- class CodeGen(root: Node, context: Context, config: CodegenConfig | None = None)[source]¶
Bases:
object
Builds the Verilog ast from the context and IR
- get_testbench(config: TestbenchConfig)[source]¶
Creates testbench with multiple test cases
Each element of self.context.test_cases represents a single test case
- Parameters:
random_ready – whether or not to have random ready signal in the while loop
- get_testbench_lines(config: TestbenchConfig)[source]¶
New Testbench as lines
- get_testbench_str(config: TestbenchConfig)[source]¶
New testbench as str
python2verilog.backend.verilog.config module¶
Configurations
- class CodegenConfig(random_ready: bool = False, add_debug_comments: bool = <factory>)[source]¶
Bases:
TestbenchConfig
Configurations for code generator
- add_debug_comments: bool¶
python2verilog.backend.verilog.fsm module¶
Lowers IR Graph to FSM
python2verilog.backend.verilog.module module¶
Creates module from context and FSM
python2verilog.backend.verilog.testbench module¶
Creates testbench from context and FSM
- class Testbench(context: Context, config: TestbenchConfig)[source]¶
Bases:
Module
Module contents¶
Verilog Backend