Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
6e56e3b
using match
WorldofKerry Oct 4, 2023
1e0a4bf
python 3.12
WorldofKerry Oct 4, 2023
1b2d8c2
cleanup
WorldofKerry Oct 4, 2023
b3bc488
WIP
WorldofKerry Oct 4, 2023
9520253
testing hrange, 8 fails
WorldofKerry Oct 4, 2023
bc7e900
possible fix making ifelse children nonclocked, however that's a work…
WorldofKerry Oct 4, 2023
8a2b5c7
should have fixed
WorldofKerry Oct 5, 2023
3894c7e
minor cleanup
WorldofKerry Oct 5, 2023
7770779
lint
WorldofKerry Oct 5, 2023
46ddfd0
cleanup
WorldofKerry Oct 5, 2023
7e80ee6
fixed generator2ir bug
WorldofKerry Oct 5, 2023
c170883
renames
WorldofKerry Oct 5, 2023
9f8d77b
removed yield node, optimized debug stmts
WorldofKerry Oct 5, 2023
d9c740e
bumped ver num
WorldofKerry Oct 5, 2023
e678557
dropped py3.9
WorldofKerry Oct 5, 2023
2d848cd
updated names
WorldofKerry Oct 5, 2023
efdd7ce
refractor
WorldofKerry Oct 5, 2023
d477dc5
refractor
WorldofKerry Oct 5, 2023
84ee5e6
test perf
WorldofKerry Oct 5, 2023
9243d0c
this works somehow
WorldofKerry Oct 5, 2023
8b36b27
cleanup
WorldofKerry Oct 5, 2023
261dc78
cleanup
WorldofKerry Oct 5, 2023
afacf1e
cleanup
WorldofKerry Oct 5, 2023
590b510
removed a match
WorldofKerry Oct 5, 2023
618bbf7
renames and minor
WorldofKerry Oct 5, 2023
aeb69d5
removed match
WorldofKerry Oct 5, 2023
1d9add9
does system work?
WorldofKerry Oct 5, 2023
fdf3e98
does system work?
WorldofKerry Oct 5, 2023
5c4faf6
cleaner match
WorldofKerry Oct 5, 2023
5732bc2
removed strict
WorldofKerry Oct 5, 2023
8163e07
version numbers
WorldofKerry Oct 5, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/linting.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
if: ${{ !github.event.pull_request.draft }}
strategy:
matrix:
python-version: ["3.11"]
python-version: ["3.x"]
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/packaging.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: ["3.11"]
python-version: ["3.x"]

steps:
- uses: actions/checkout@v3
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/pytest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: ["3.11"]
python-version: ["3.12"]
steps:
- uses: actions/checkout@v3
with:
Expand Down Expand Up @@ -56,7 +56,7 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: ["3.11"]
python-version: ["3.12"]
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
Expand Down Expand Up @@ -94,7 +94,7 @@ jobs:
matrix:
pytest-args: ["", "-RS", "-FRS", "-F"]
pytest-opti-levels: ["-L 0 1 2 4 8", "-L 16"]
python-version: ["3.9", "3.10", "3.11"]
python-version: ["3.9", "3.10", "3.11", "3.12"]

steps:
- uses: actions/checkout@v3
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "python2verilog"
version = "0.2.5"
version = "0.2.6"
authors = [{ name = "Kerry Wang", email = "kerrywang369@gmail.com" }]
description = "Converts a subset of python generator functions into synthesizable sequential SystemVerilog"
readme = "README.md"
Expand Down
16 changes: 11 additions & 5 deletions python2verilog/api/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
from python2verilog import ir
from python2verilog.backend import verilog
from python2verilog.backend.verilog.config import CodegenConfig, TestbenchConfig
from python2verilog.frontend.generator2ir import Generator2Graph
from python2verilog.optimizer.optimizer import OptimizeGraph
from python2verilog.frontend.generator import FromGenerator
from python2verilog.optimizer import IncreaseWorkPerClockCycle
from python2verilog.utils.typed import typed


Expand All @@ -22,12 +22,18 @@ def context_to_codegen(context: ir.Context):
:return: (codegen, ir)
"""
context = copy.deepcopy(context) # context should be changed to frozened
ir_root, context = Generator2Graph(context).results
logging.info("Running %s", FromGenerator.__name__)
ir_root, context = FromGenerator(context).results
logging.debug(
f"context to codegen {ir_root.unique_id} {context.name} -O{context.optimization_level}"
"context to codegen %s %s -O%s",
ir_root.unique_id,
context.name,
context.optimization_level,
)
if context.optimization_level > 0:
OptimizeGraph(ir_root, threshold=context.optimization_level - 1)
logging.info("Running %s", IncreaseWorkPerClockCycle.__name__)
IncreaseWorkPerClockCycle(ir_root, threshold=context.optimization_level - 1)
logging.info("Running %s", verilog.CodeGen.__name__)
return verilog.CodeGen(ir_root, context), ir_root


Expand Down
3 changes: 0 additions & 3 deletions python2verilog/api/python.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,7 @@
from python2verilog.api.context import context_to_codegen
from python2verilog.api.modes import Modes
from python2verilog.api.namespace import get_namespace
from python2verilog.backend import verilog
from python2verilog.backend.verilog.config import CodegenConfig, TestbenchConfig
from python2verilog.frontend.generator2ir import Generator2Graph
from python2verilog.optimizer.optimizer import OptimizeGraph
from python2verilog.utils.typed import typed, typed_list


Expand Down
37 changes: 3 additions & 34 deletions python2verilog/backend/verilog/codegen.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from typing import Generator, Iterator, cast

from python2verilog.backend.verilog.config import TestbenchConfig
from python2verilog.optimizer.optimizer import backwards_replace
from python2verilog.optimizer import backwards_replace
from python2verilog.utils.lines import Lines

from ... import ir
Expand All @@ -29,10 +29,6 @@ def __init__(self, root: ir.Node, context: ir.Context):
typed(context, ir.Context)
self.context = context
root_case = CaseBuilder(root, context).get_case()
logging.debug(
f"{self.__class__.__name__} "
f"{[case.condition.ver_name for case in root_case.case_items]}" # type: ignore
)

for item in root_case.case_items:
self.context.add_state_weak(
Expand Down Expand Up @@ -316,7 +312,7 @@ def get_testbench(self, config: TestbenchConfig):

:param random_ready: whether or not to have random ready signal in the while loop
"""
logging.debug(f"{config}")
logging.debug("%s", config)
if len(self.context.input_vars) == 0:
raise RuntimeError(
f"Input var names not deduced for {self.context.name}, "
Expand Down Expand Up @@ -548,7 +544,7 @@ def new_caseitem(self, root: ir.Node):
Creates a new case item with the root's unique id as identifier
"""
stmts = self.do_vertex(root)
logging.debug(f"new caseitem {root.unique_id}")
logging.debug("new caseitem %s", root.unique_id)
item = ver.CaseItem(condition=ir.State(root.unique_id), statements=stmts)

return item
Expand Down Expand Up @@ -582,33 +578,6 @@ def do_vertex(self, vertex: ir.Node):
)
)

elif isinstance(vertex, ir.YieldNode):
outputs: list[ver.Statement] = []
outputs += [
ver.NonBlockingSubsitution(var, expr)
for var, expr in zip(self.context.output_vars, vertex.stmts)
]
outputs += [
ver.NonBlockingSubsitution(self.context.signals.valid, ir.UInt(1))
]
state_change: list[ver.Statement] = []

if isinstance(vertex.optimal_child.optimal_child, ir.DoneNode):
outputs.append(self.create_quick_done(self.context))

state_change.append(
ver.NonBlockingSubsitution(
self.context.state_var,
ir.State(vertex.optimal_child.optimal_child.unique_id),
)
)
if vertex.optimal_child.optimal_child.unique_id not in self.visited:
self.case.case_items.append(
self.new_caseitem(vertex.optimal_child.optimal_child)
)

stmts += outputs + state_change

else:
raise TypeError(type(vertex))

Expand Down
2 changes: 1 addition & 1 deletion python2verilog/frontend/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
Python to IR Parsers
"""

from .generator2ir import Generator2Graph
from .generator import FromGenerator
Loading