Skip to content

Commit 2a4c764

Browse files
authored
Merge pull request #12 from ktok07b6/devel
Version 0.3.5
2 parents fa466f4 + 523b6de commit 2a4c764

59 files changed

Lines changed: 1056 additions & 558 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.flake8

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
[flake8]
2-
ignore = H101,H301,H304,H306,E221,E231,E241,E265,F403,F405,W503
2+
ignore = H101,H301,H304,H306,E221,E231,E241,E265,F403,F405,W503,W504
33
max-line-length = 99

polyphony/_internal/__init__.py

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
__version__ = '0.3.5' # type: str
2+
3+
4+
@decorator
5+
def testbench(func) -> None:
6+
pass
7+
8+
9+
@decorator
10+
def pure(func) -> None:
11+
pass
12+
13+
14+
def is_worker_running() -> bool:
15+
pass
16+
17+
18+
@decorator
19+
def module() -> None:
20+
pass
21+
22+
23+
@decorator
24+
def rule(kwargs) -> None:
25+
pass
26+
27+
28+
@builtin
29+
def unroll(seq, factor='full') -> list:
30+
pass
31+
32+
33+
@builtin
34+
def pipelined(seq, ii=-1) -> list:
35+
pass

polyphony/_internal/_io.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,3 @@
1-
__all__ = [
2-
'Port',
3-
'Queue',
4-
]
5-
6-
71
class Port:
82
def __init__(self, dtype:generic, direction:str, init=None, protocol:str='none') -> object:
93
pass

polyphony/_internal/_polyphony.py

Lines changed: 0 additions & 41 deletions
This file was deleted.

polyphony/_internal/_timing.py

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,5 @@
1-
__all__ = [
2-
'clksleep',
3-
'clkfence',
4-
'wait_edge',
5-
'wait_rising',
6-
'wait_falling',
7-
'wait_value',
8-
]
1+
from .io import Port
2+
93

104
@builtin
115
def clksleep(clk_cycles:int) -> None:
@@ -18,20 +12,20 @@ def clkfence() -> None:
1812

1913

2014
@builtin
21-
def wait_edge(old:int, new:int, *ports:polyphony.io.Port) -> None:
15+
def wait_edge(old:int, new:int, *ports:Port) -> None:
2216
pass
2317

2418

2519
@builtin
26-
def wait_rising(*ports:polyphony.io.Port) -> None:
20+
def wait_rising(*ports:Port) -> None:
2721
pass
2822

2923

3024
@builtin
31-
def wait_falling(*ports:polyphony.io.Port) -> None:
25+
def wait_falling(*ports:Port) -> None:
3226
pass
3327

3428

3529
@builtin
36-
def wait_value(value:int, *ports:polyphony.io.Port) -> None:
30+
def wait_value(value:int, *ports:Port) -> None:
3731
pass

polyphony/_internal/_typing.py

Lines changed: 0 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -1,59 +1,3 @@
1-
__all__ = [
2-
'bit',
3-
'bit2', 'bit3', 'bit4', 'bit5', 'bit6', 'bit7', 'bit8',
4-
'bit9', 'bit10', 'bit11', 'bit12', 'bit13', 'bit14', 'bit15', 'bit16',
5-
'bit17', 'bit18', 'bit19', 'bit20', 'bit21', 'bit22', 'bit23', 'bit24',
6-
'bit25', 'bit26', 'bit27', 'bit28', 'bit29', 'bit30', 'bit31', 'bit32',
7-
'bit33', 'bit34', 'bit35', 'bit36', 'bit37', 'bit38', 'bit39', 'bit40',
8-
'bit41', 'bit42', 'bit43', 'bit44', 'bit45', 'bit46', 'bit47', 'bit48',
9-
'bit49', 'bit50', 'bit51', 'bit52', 'bit53', 'bit54', 'bit55', 'bit56',
10-
'bit57', 'bit58', 'bit59', 'bit60', 'bit61', 'bit62', 'bit63', 'bit64',
11-
'bit65', 'bit66', 'bit67', 'bit68', 'bit69', 'bit70', 'bit71', 'bit72',
12-
'bit73', 'bit74', 'bit75', 'bit76', 'bit77', 'bit78', 'bit79', 'bit80',
13-
'bit81', 'bit82', 'bit83', 'bit84', 'bit85', 'bit86', 'bit87', 'bit88',
14-
'bit89', 'bit90', 'bit91', 'bit92', 'bit93', 'bit94', 'bit95', 'bit96',
15-
'bit97', 'bit98', 'bit99', 'bit100', 'bit101', 'bit102', 'bit103', 'bit104',
16-
'bit105', 'bit106', 'bit107', 'bit108', 'bit109', 'bit110', 'bit111', 'bit112',
17-
'bit113', 'bit114', 'bit115', 'bit116', 'bit117', 'bit118', 'bit119', 'bit120',
18-
'bit121', 'bit122', 'bit123', 'bit124', 'bit125', 'bit126', 'bit127', 'bit128',
19-
20-
'int2', 'int3', 'int4', 'int5', 'int6', 'int7', 'int8',
21-
'int9', 'int10', 'int11', 'int12', 'int13', 'int14', 'int15', 'int16',
22-
'int17', 'int18', 'int19', 'int20', 'int21', 'int22', 'int23', 'int24',
23-
'int25', 'int26', 'int27', 'int28', 'int29', 'int30', 'int31', 'int32',
24-
'int33', 'int34', 'int35', 'int36', 'int37', 'int38', 'int39', 'int40',
25-
'int41', 'int42', 'int43', 'int44', 'int45', 'int46', 'int47', 'int48',
26-
'int49', 'int50', 'int51', 'int52', 'int53', 'int54', 'int55', 'int56',
27-
'int57', 'int58', 'int59', 'int60', 'int61', 'int62', 'int63', 'int64',
28-
'int65', 'int66', 'int67', 'int68', 'int69', 'int70', 'int71', 'int72',
29-
'int73', 'int74', 'int75', 'int76', 'int77', 'int78', 'int79', 'int80',
30-
'int81', 'int82', 'int83', 'int84', 'int85', 'int86', 'int87', 'int88',
31-
'int89', 'int90', 'int91', 'int92', 'int93', 'int94', 'int95', 'int96',
32-
'int97', 'int98', 'int99', 'int100', 'int101', 'int102', 'int103', 'int104',
33-
'int105', 'int106', 'int107', 'int108', 'int109', 'int110', 'int111', 'int112',
34-
'int113', 'int114', 'int115', 'int116', 'int117', 'int118', 'int119', 'int120',
35-
'int121', 'int122', 'int123', 'int124', 'int125', 'int126', 'int127', 'int128',
36-
37-
'uint2', 'uint3', 'uint4', 'uint5', 'uint6', 'uint7', 'uint8',
38-
'uint9', 'uint10', 'uint11', 'uint12', 'uint13', 'uint14', 'uint15', 'uint16',
39-
'uint17', 'uint18', 'uint19', 'uint20', 'uint21', 'uint22', 'uint23', 'uint24',
40-
'uint25', 'uint26', 'uint27', 'uint28', 'uint29', 'uint30', 'uint31', 'uint32',
41-
'uint33', 'uint34', 'uint35', 'uint36', 'uint37', 'uint38', 'uint39', 'uint40',
42-
'uint41', 'uint42', 'uint43', 'uint44', 'uint45', 'uint46', 'uint47', 'uint48',
43-
'uint49', 'uint50', 'uint51', 'uint52', 'uint53', 'uint54', 'uint55', 'uint56',
44-
'uint57', 'uint58', 'uint59', 'uint60', 'uint61', 'uint62', 'uint63', 'uint64',
45-
'uint65', 'uint66', 'uint67', 'uint68', 'uint69', 'uint70', 'uint71', 'uint72',
46-
'uint73', 'uint74', 'uint75', 'uint76', 'uint77', 'uint78', 'uint79', 'uint80',
47-
'uint81', 'uint82', 'uint83', 'uint84', 'uint85', 'uint86', 'uint87', 'uint88',
48-
'uint89', 'uint90', 'uint91', 'uint92', 'uint93', 'uint94', 'uint95', 'uint96',
49-
'uint97', 'uint98', 'uint99', 'uint100', 'uint101', 'uint102', 'uint103', 'uint104',
50-
'uint105', 'uint106', 'uint107', 'uint108', 'uint109', 'uint110', 'uint111', 'uint112',
51-
'uint113', 'uint114', 'uint115', 'uint116', 'uint117', 'uint118', 'uint119', 'uint120',
52-
'uint121', 'uint122', 'uint123', 'uint124', 'uint125', 'uint126', 'uint127', 'uint128',
53-
'List',
54-
'Tuple',
55-
]
56-
571
class bit: pass
582
class bit2: pass
593
class bit3: pass

polyphony/compiler/__main__.py

Lines changed: 11 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
from .scopegraph import CallGraphBuilder
5252
from .scopegraph import DependencyGraphBuilder
5353
from .selectorbuilder import SelectorBuilder
54-
from .setlineno import LineNumberSetter, SourceDump
54+
from .setlineno import SourceDump
5555
from .specfunc import SpecializedFunctionMaker
5656
from .ssa import ScalarSSATransformer, TupleSSATransformer, ObjectSSATransformer
5757
from .statereducer import StateReducer
@@ -114,11 +114,8 @@ def is_hdlmodule_scope(scope):
114114

115115
def preprocess_global(driver):
116116
scopes = Scope.get_scopes(with_global=True, with_class=True)
117-
lineno = LineNumberSetter()
118117
src_dump = SourceDump()
119-
120118
for s in scopes:
121-
lineno.process(s)
122119
src_dump.process(s)
123120

124121

@@ -369,7 +366,7 @@ def staticconstopt(driver):
369366
scopes = driver.get_scopes(bottom_up=True,
370367
with_global=True,
371368
with_class=True,
372-
with_lib=False)
369+
with_lib=True)
373370
StaticConstOpt().process_scopes(scopes)
374371

375372

@@ -752,50 +749,32 @@ def setup(src_file, options):
752749
logging.basicConfig(**logging_setting)
753750

754751
translator = IRTranslator()
755-
internal_root_dir = '{0}{1}{2}{1}_internal{1}'.format(
752+
root_dir = '{0}{1}{2}{1}'.format(
756753
os.path.dirname(__file__),
757754
os.path.sep, os.path.pardir
758755
)
759-
internal_root_dir = os.path.abspath(internal_root_dir) + os.path.sep
760-
761-
builtin_package_file = internal_root_dir + '_builtins.py'
756+
env.root_dir = os.path.abspath(root_dir)
757+
internal_dir = f'{env.root_dir}{os.path.sep}_internal'
758+
builtin_package_file = f'{internal_dir}{os.sep}_builtins.py'
762759
env.set_current_filename(builtin_package_file)
763760
translator.translate(read_source(builtin_package_file), '__builtin__')
764761

765-
polyphony_package_file = internal_root_dir + '_polyphony.py'
766-
env.set_current_filename(polyphony_package_file)
767-
translator.translate(read_source(polyphony_package_file), 'polyphony')
768-
769-
package_names = [
770-
'typing',
771-
'io',
772-
'timing',
773-
'verilog'
774-
]
775-
for package_name in package_names:
776-
package_file = f'{internal_root_dir}_{package_name}.py'
777-
env.set_current_filename(package_file)
778-
translator.translate(read_source(package_file), package_name)
779-
780762
env.set_current_filename(src_file)
781-
g = Scope.create_namespace(None, env.global_scope_name, {'global'})
763+
g = Scope.create_namespace(None, env.global_scope_name, {'global'}, src_file)
782764
env.push_outermost_scope(g)
783765
for sym in builtin_symbols.values():
784766
g.import_sym(sym)
785767

786-
scopes = Scope.get_scopes(with_global=False, with_class=True, with_lib=True)
787-
static_lib_scopes = [s for s in scopes
788-
if s.name.startswith('polyphony') and
789-
(s.is_namespace() or s.is_class())]
790-
StaticConstOpt().process_scopes(static_lib_scopes)
791-
792768

793769
def compile(plan, source, src_file=''):
794770
translator = IRTranslator()
795771
translator.translate(source, '')
796772
if env.config.enable_pure:
797773
interpret(source, src_file)
798-
scopes = Scope.get_scopes(bottom_up=False, with_global=True, with_class=True)
774+
scopes = Scope.get_scopes(bottom_up=False,
775+
with_global=True,
776+
with_class=True,
777+
with_lib=True)
799778
driver = Driver(plan, scopes)
800779
driver.run()
801780
return driver.codes

0 commit comments

Comments
 (0)