Skip to content

Commit e61f28e

Browse files
committed
Merge branch 'develop'
2 parents 994a460 + de2ff31 commit e61f28e

File tree

103 files changed

+9220
-387
lines changed

Some content is hidden

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

103 files changed

+9220
-387
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ for pull requests
6969

7070
Please check "CONTRIBUTORS.md" for the contributors who provided pull requests.
7171

72-
Veriloggen uses **pytest** for the integration testing. **When you send a pull request, please include a testing example with pytest.**
72+
Veriloggen uses **pytest** for the integration testing. **When you send a pull request, please include a testing example with pytest.**
7373
To write a testing code, please refer the existing testing examples in "tests" directory.
7474

7575
If the pull request code passes all the tests successfully and has no obvious problem, it will be merged to the *develop* branch by the main committers.
@@ -89,7 +89,7 @@ sudo apt install iverilog
8989
```
9090

9191
- Jinja2: 2.10 or later
92-
- Pyverilog: 1.2.0 or later
92+
- Pyverilog: 1.2.1 or later
9393
- NumPy: 1.17 or later
9494

9595
```

by_examples.ipynb

Lines changed: 325 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,325 @@
1+
{
2+
"cells": [
3+
{
4+
"cell_type": "markdown",
5+
"metadata": {},
6+
"source": [
7+
"Veriloggen by examples\n",
8+
"====================\n"
9+
]
10+
},
11+
{
12+
"cell_type": "markdown",
13+
"metadata": {},
14+
"source": [
15+
"Empty Module\n",
16+
"--------------------"
17+
]
18+
},
19+
{
20+
"cell_type": "code",
21+
"execution_count": 2,
22+
"metadata": {},
23+
"outputs": [
24+
{
25+
"name": "stdout",
26+
"output_type": "stream",
27+
"text": [
28+
"\n",
29+
"\n",
30+
"module empty\n",
31+
"(\n",
32+
" input CLK,\n",
33+
" input RST\n",
34+
");\n",
35+
"\n",
36+
"\n",
37+
"endmodule\n",
38+
"\n",
39+
"\n"
40+
]
41+
}
42+
],
43+
"source": [
44+
"from __future__ import absolute_import\n",
45+
"from __future__ import print_function\n",
46+
"from veriloggen import *\n",
47+
"\n",
48+
"m = Module('empty')\n",
49+
"clk = m.Input('CLK')\n",
50+
"rst = m.Input('RST')\n",
51+
"\n",
52+
"rtl = m.to_verilog()\n",
53+
"print(rtl)"
54+
]
55+
},
56+
{
57+
"cell_type": "markdown",
58+
"metadata": {},
59+
"source": [
60+
"Combinational Circuit\n",
61+
"--------------------"
62+
]
63+
},
64+
{
65+
"cell_type": "markdown",
66+
"metadata": {},
67+
"source": [
68+
"### Input/Output/Reg/Wire"
69+
]
70+
},
71+
{
72+
"cell_type": "code",
73+
"execution_count": 14,
74+
"metadata": {},
75+
"outputs": [
76+
{
77+
"name": "stdout",
78+
"output_type": "stream",
79+
"text": [
80+
"\n",
81+
"\n",
82+
"module comb\n",
83+
"(\n",
84+
" input CLK,\n",
85+
" input RST,\n",
86+
" input a,\n",
87+
" output b\n",
88+
");\n",
89+
"\n",
90+
" reg c;\n",
91+
" wire d;\n",
92+
"\n",
93+
"endmodule\n",
94+
"\n",
95+
"\n"
96+
]
97+
}
98+
],
99+
"source": [
100+
"m = Module('comb')\n",
101+
"clk = m.Input('CLK')\n",
102+
"rst = m.Input('RST')\n",
103+
"\n",
104+
"a = m.Input('a')\n",
105+
"b = m.Output('b')\n",
106+
"c = m.Reg('c')\n",
107+
"d = m.Wire('d')\n",
108+
"\n",
109+
"rtl = m.to_verilog()\n",
110+
"print(rtl)"
111+
]
112+
},
113+
{
114+
"cell_type": "markdown",
115+
"metadata": {},
116+
"source": [
117+
"### Multi-bit signal"
118+
]
119+
},
120+
{
121+
"cell_type": "code",
122+
"execution_count": 15,
123+
"metadata": {},
124+
"outputs": [
125+
{
126+
"name": "stdout",
127+
"output_type": "stream",
128+
"text": [
129+
"\n",
130+
"\n",
131+
"module comb\n",
132+
"(\n",
133+
" input CLK,\n",
134+
" input RST,\n",
135+
" input [8-1:0] a,\n",
136+
" output [8-1:0] b\n",
137+
");\n",
138+
"\n",
139+
" reg [16-1:0] c;\n",
140+
" wire [20-1:0] d;\n",
141+
"\n",
142+
"endmodule\n",
143+
"\n",
144+
"\n"
145+
]
146+
}
147+
],
148+
"source": [
149+
"m = Module('comb')\n",
150+
"clk = m.Input('CLK')\n",
151+
"rst = m.Input('RST')\n",
152+
"\n",
153+
"a = m.Input('a', 8)\n",
154+
"b = m.Output('b', width=a.width)\n",
155+
"c = m.Reg('c', 16)\n",
156+
"d = m.Wire('d', c.width + 4)\n",
157+
"\n",
158+
"rtl = m.to_verilog()\n",
159+
"print(rtl)"
160+
]
161+
},
162+
{
163+
"cell_type": "markdown",
164+
"metadata": {},
165+
"source": [
166+
"### Parameter and Localparam"
167+
]
168+
},
169+
{
170+
"cell_type": "code",
171+
"execution_count": 16,
172+
"metadata": {},
173+
"outputs": [
174+
{
175+
"name": "stdout",
176+
"output_type": "stream",
177+
"text": [
178+
"\n",
179+
"\n",
180+
"module comb #\n",
181+
"(\n",
182+
" parameter sig_width = 8\n",
183+
")\n",
184+
"(\n",
185+
" input CLK,\n",
186+
" input RST,\n",
187+
" input [sig_width-1:0] a,\n",
188+
" output [sig_width-1:0] b\n",
189+
");\n",
190+
"\n",
191+
" reg [sig_width-1:0] c;\n",
192+
" wire [sig_width+4-1:0] d;\n",
193+
"\n",
194+
"endmodule\n",
195+
"\n",
196+
"\n"
197+
]
198+
}
199+
],
200+
"source": [
201+
"m = Module('comb')\n",
202+
"clk = m.Input('CLK')\n",
203+
"rst = m.Input('RST')\n",
204+
"\n",
205+
"sig_width = m.Parameter('sig_width', 8)\n",
206+
"\n",
207+
"a = m.Input('a', sig_width)\n",
208+
"b = m.Output('b', a.width)\n",
209+
"c = m.Reg('c', a.width)\n",
210+
"d = m.Wire('d', c.width + 4)\n",
211+
"\n",
212+
"rtl = m.to_verilog()\n",
213+
"print(rtl)"
214+
]
215+
},
216+
{
217+
"cell_type": "markdown",
218+
"metadata": {},
219+
"source": [
220+
"### Substitution and Assign"
221+
]
222+
},
223+
{
224+
"cell_type": "code",
225+
"execution_count": 21,
226+
"metadata": {},
227+
"outputs": [
228+
{
229+
"data": {
230+
"text/plain": [
231+
"<veriloggen.core.vtypes.Subst at 0x10c721ad0>"
232+
]
233+
},
234+
"execution_count": 21,
235+
"metadata": {},
236+
"output_type": "execute_result"
237+
}
238+
],
239+
"source": [
240+
"m = Module('comb')\n",
241+
"clk = m.Input('CLK')\n",
242+
"rst = m.Input('RST')\n",
243+
"\n",
244+
"a = m.Input('a', 8)\n",
245+
"b = m.Output('b', 8)\n",
246+
"c = m.Wire('c', 8)\n",
247+
"d = m.Wire('d', 8)\n",
248+
"\n",
249+
"# Substitusion\n",
250+
"c(a + 1) # --> Subst object representing \"c <- a + 1\""
251+
]
252+
},
253+
{
254+
"cell_type": "code",
255+
"execution_count": 25,
256+
"metadata": {},
257+
"outputs": [
258+
{
259+
"name": "stdout",
260+
"output_type": "stream",
261+
"text": [
262+
"\n",
263+
"\n",
264+
"module comb\n",
265+
"(\n",
266+
" input CLK,\n",
267+
" input RST,\n",
268+
" input [8-1:0] a,\n",
269+
" output [8-1:0] b\n",
270+
");\n",
271+
"\n",
272+
" wire [8-1:0] c;\n",
273+
" wire [8-1:0] d;\n",
274+
" assign c = a + 1;\n",
275+
" assign d = a + 2;\n",
276+
"\n",
277+
"endmodule\n",
278+
"\n",
279+
"\n"
280+
]
281+
}
282+
],
283+
"source": [
284+
"m = Module('comb')\n",
285+
"clk = m.Input('CLK')\n",
286+
"rst = m.Input('RST')\n",
287+
"\n",
288+
"a = m.Input('a', 8)\n",
289+
"b = m.Output('b', 8)\n",
290+
"c = m.Wire('c', 8)\n",
291+
"d = m.Wire('d', 8)\n",
292+
"\n",
293+
"# Assign requires Substitution object\n",
294+
"m.Assign(c(a + 1))\n",
295+
"\n",
296+
"# var.assign() method returns same result\n",
297+
"d.assign(a + 2)\n",
298+
"\n",
299+
"rtl = m.to_verilog()\n",
300+
"print(rtl)"
301+
]
302+
}
303+
],
304+
"metadata": {
305+
"kernelspec": {
306+
"display_name": "Python 3",
307+
"language": "python",
308+
"name": "python3"
309+
},
310+
"language_info": {
311+
"codemirror_mode": {
312+
"name": "ipython",
313+
"version": 3
314+
},
315+
"file_extension": ".py",
316+
"mimetype": "text/x-python",
317+
"name": "python",
318+
"nbconvert_exporter": "python",
319+
"pygments_lexer": "ipython3",
320+
"version": "3.7.5"
321+
}
322+
},
323+
"nbformat": 4,
324+
"nbformat_minor": 2
325+
}

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ def read(filename):
2323
'veriloggen.simulation': ['*.cpp'],
2424
},
2525
install_requires=['Jinja2>=2.10',
26-
'pyverilog>=1.2.0',
26+
'pyverilog>=1.2.1',
2727
'numpy>=1.17'],
2828
extras_require={
2929
'test': ['pytest>=3.8.1', 'pytest-pythonpath>=0.7.3'],

tests/extension/stream_/average/test_stream_average.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -147,8 +147,8 @@
147147
reg signed [32-1:0] __delay_data_31;
148148
reg signed [32-1:0] _plus_data_25;
149149
reg signed [32-1:0] __delay_data_32;
150-
reg signed [32-1:0] _sra_data_26;
151-
reg signed [32-1:0] __delay_data_33;
150+
wire signed [32-1:0] _sra_data_26;
151+
assign _sra_data_26 = _plus_data_25 >>> 3'sd3;
152152
reg signed [32-1:0] _plus_data_28;
153153
assign zdata = _plus_data_28;
154154
@@ -173,8 +173,6 @@
173173
__delay_data_31 <= 0;
174174
_plus_data_25 <= 0;
175175
__delay_data_32 <= 0;
176-
_sra_data_26 <= 0;
177-
__delay_data_33 <= 0;
178176
_plus_data_28 <= 0;
179177
end else begin
180178
_plus_data_2 <= xdata + 1'sd0;
@@ -196,9 +194,7 @@
196194
__delay_data_31 <= __delay_data_30;
197195
_plus_data_25 <= _plus_data_21 + _plus_data_24;
198196
__delay_data_32 <= __delay_data_31;
199-
_sra_data_26 <= _plus_data_25 >>> 3'sd3;
200-
__delay_data_33 <= __delay_data_32;
201-
_plus_data_28 <= _sra_data_26 + __delay_data_33;
197+
_plus_data_28 <= _sra_data_26 + __delay_data_32;
202198
end
203199
end
204200

0 commit comments

Comments
 (0)