-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Experimenting with parsing from text, incremented version number (#164)
- Loading branch information
1 parent
6137160
commit c5f72bf
Showing
7 changed files
with
105 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
[project] | ||
name = "python2verilog" | ||
version = "0.2.7" | ||
version = "0.2.8" | ||
authors = [{ name = "Kerry Wang", email = "[email protected]" }] | ||
description = "Converts a subset of python generator functions into synthesizable sequential SystemVerilog" | ||
readme = "README.md" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import tempfile | ||
from importlib import util | ||
|
||
raw = """ | ||
from python2verilog import verilogify | ||
ns = {} | ||
@verilogify(namespace=ns) | ||
def fib() -> int: | ||
a, b = 0, 1 | ||
while a < 30: | ||
yield a | ||
a, b = b, a + b | ||
""" | ||
|
||
# Create a temporary source code file | ||
with tempfile.NamedTemporaryFile(suffix=".py") as tmp: | ||
tmp.write(raw.encode()) | ||
tmp.flush() | ||
|
||
# Now load that file as a module | ||
spec = util.spec_from_file_location("tmp", tmp.name) | ||
module = util.module_from_spec(spec) | ||
spec.loader.exec_module(module) | ||
|
||
# ...or, while the tmp file exists, you can query it externally | ||
import inspect | ||
|
||
print(inspect.getsource(module.fib)) | ||
print(module.ns) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters