Skip to content

Commit fa466f4

Browse files
authored
Merge pull request #11 from ktok07b6/devel
version 0.3.4
2 parents 15755a6 + 9311581 commit fa466f4

Some content is hidden

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

91 files changed

+3786
-1465
lines changed

.travis.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
language: python
2+
sudo: false
3+
python:
4+
- "3.6"
5+
- "nightly"
6+
addons:
7+
apt:
8+
packages:
9+
- iverilog
10+
install:
11+
- pip install -r requirements.txt
12+
script:
13+
- python suite.py -j -f

README.rst

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,25 @@
1+
.. image:: https://travis-ci.org/ktok07b6/polyphony.svg?branch=devel
2+
:target: https://travis-ci.org/ktok07b6/polyphony
3+
.. image:: https://badge.fury.io/py/polyphony.svg
4+
:target: https://badge.fury.io/py/polyphony
5+
16
polyphony
27
=========
3-
48
Polyphony is Python based High-Level Synthesis compiler.
59

610
Requirements
711
------------
8-
Python 3.4
12+
Python 3.6 or later
913

1014
Installation
1115
------------
1216
$ pip3 install polyphony
1317

1418
Usage
1519
-----
16-
usage: polyphony [-h] [-o FILE] [-d DIR] [-v] [-D] [-q] [-V] source
20+
usage: polyphony [-h] [-o FILE] [-d DIR] [-c CONFIG] [-v] [-D] [-q] [-vd]
21+
[-vm] [-V]
22+
source
1723

1824
positional arguments:
1925
source Python source file
@@ -23,9 +29,14 @@ optional arguments:
2329
-o FILE, --output FILE
2430
output filename (default is "polyphony_out")
2531
-d DIR, --dir DIR output directory
32+
-c CONFIG, --config CONFIG
33+
set configration(json literal or file)
2634
-v, --verbose verbose output
2735
-D, --debug enable debug mode
2836
-q, --quiet suppress warning/error messages
37+
-vd, --verilog_dump output vcd file in testbench
38+
-vm, --verilog_monitor
39+
enable $monitor in testbench
2940
-V, --version print the Polyphony version number
3041

3142
Examples

error.py

Lines changed: 45 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#!/usr/bin/env python3
2+
import argparse
23
import sys
34
import os
45
import traceback
@@ -16,7 +17,33 @@
1617
from polyphony.compiler.env import env
1718

1819

19-
def error_test(casefile_path, output=True):
20+
def parse_options():
21+
if not os.path.exists(TMP_DIR):
22+
os.mkdir(TMP_DIR)
23+
parser = argparse.ArgumentParser(prog='simu')
24+
parser.add_argument('-c', '--config', dest='config',
25+
metavar='CONFIG', help='set configration(json literal or file)')
26+
parser.add_argument('-d', '--enable_debug', dest='debug_mode',
27+
action='store_true', help='enable debug mode')
28+
parser.add_argument('-w', dest='warn_test', action='store_true')
29+
parser.add_argument('source', help='Python source file')
30+
return parser.parse_args()
31+
32+
33+
def make_compile_options(casename, err_options, quiet_level):
34+
options = types.SimpleNamespace()
35+
options.config = err_options.config
36+
options.output_name = casename
37+
options.output_dir = TMP_DIR
38+
options.verbose_level = 0
39+
options.quiet_level = quiet_level
40+
options.debug_mode = err_options.debug_mode
41+
options.verilog_dump = False
42+
options.verilog_monitor = False
43+
return options
44+
45+
46+
def error_test(casefile_path, err_options):
2047
casefile = os.path.basename(casefile_path)
2148
casename, _ = os.path.splitext(casefile)
2249
with open(casefile_path, 'r') as f:
@@ -25,31 +52,25 @@ def error_test(casefile_path, output=True):
2552
print('The file is not error test file')
2653
sys.exit(0)
2754
expected_msg = first_line.split('#')[1].rstrip('\n')
28-
options = types.SimpleNamespace()
29-
options.output_name = casename
30-
options.output_dir = TMP_DIR
31-
options.verbose_level = 0
32-
options.quiet_level = 3
33-
options.debug_mode = output
34-
options.verilog_dump = False
35-
options.verilog_monitor = False
55+
options = make_compile_options(casename, err_options, env.QUIET_ERROR)
3656
try:
3757
compile_main(casefile_path, options)
3858
except AssertionError:
3959
raise
4060
except Exception as e:
4161
if e.args[0] == expected_msg:
42-
return
43-
if env.dev_debug_mode:
62+
return True
63+
if err_options.debug_mode:
4464
traceback.print_exc()
4565
print(casefile_path)
4666
print('[ERROR TEST] FAILED: actual "{}", expected "{}"'.format(e.args[0], expected_msg))
47-
return
67+
return False
4868
print(casefile_path)
4969
print('[ERROR TEST] FAILED: No exception was raised')
70+
return False
5071

5172

52-
def warn_test(casefile_path, output=True):
73+
def warn_test(casefile_path, err_options):
5374
casefile = os.path.basename(casefile_path)
5475
casename, _ = os.path.splitext(casefile)
5576
with open(casefile_path, 'r') as f:
@@ -59,30 +80,32 @@ def warn_test(casefile_path, output=True):
5980
sys.exit(0)
6081
expected_msg = first_line.split('#')[1].rstrip('\n')
6182
f = io.StringIO()
83+
err_options.debug_mode = False
84+
options = make_compile_options(casename, err_options, 0)
6285
with redirect_stdout(f):
6386
try:
64-
compile_main(casefile_path, casename, TMP_DIR, debug_mode=output)
87+
compile_main(casefile_path, options)
6588
except Exception as e:
6689
print(casefile_path)
6790
print('[WARNING TEST] FAILED')
6891
msg = f.getvalue()
92+
#print(msg)
6993
header = 'Warning: '
7094
for line in msg.split('\n'):
7195
if line.startswith(header):
7296
actual_msg = line[len(header):]
7397
if actual_msg != expected_msg:
7498
print(casefile_path)
7599
print('[WARNING TEST] FAILED: actual "{}", expected "{}"'.format(actual_msg, expected_msg))
76-
return
100+
return True
77101
print(casefile_path)
78102
print('[WARNING TEST] FAILED: No warning messages')
103+
return False
79104

80105

81106
if __name__ == '__main__':
82-
if not os.path.exists(TMP_DIR):
83-
os.mkdir(TMP_DIR)
84-
if len(sys.argv) > 1:
85-
if sys.argv[1] == 'w':
86-
warn_test(sys.argv[2])
87-
else:
88-
error_test(sys.argv[1])
107+
options = parse_options()
108+
if not options.warn_test:
109+
error_test(options.source, options)
110+
else:
111+
warn_test(options.source, options)

polyphony/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@ def __call__(self, **kwargs):
304304
rule = _Rule()
305305

306306

307-
def pipelined(seq):
307+
def pipelined(seq, ii=-1):
308308
return seq
309309

310310

polyphony/_internal/_polyphony.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
__version__ = '0.3.3' # type: str
1+
__version__ = '0.3.4' # type: str
22
__all__ = [
33
'testbench',
44
'pure',
@@ -37,5 +37,5 @@ def unroll(seq, factor='full') -> list:
3737

3838

3939
@builtin
40-
def pipelined(seq) -> list:
40+
def pipelined(seq, ii=-1) -> list:
4141
pass

polyphony/_internal/_verilog.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
@builtin
2+
def write(fmt:str, *args) -> None:
3+
pass
4+
5+
6+
@builtin
7+
def display(fmt:str, *args) -> None:
8+
pass

0 commit comments

Comments
 (0)