-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add tests for RTLIL and nMigen input formats
Signed-off-by: Robert Winkler <[email protected]>
- Loading branch information
Showing
7 changed files
with
208 additions
and
5 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
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,18 @@ | ||
from nmigen import * | ||
from nmigen.back import rtlil | ||
|
||
|
||
class Counter(Elaboratable): | ||
def __init__(self, width): | ||
self.v = Signal(width, reset=2**width-1) | ||
self.o = Signal() | ||
|
||
def elaborate(self, platform): | ||
m = Module() | ||
m.d.sync += self.v.eq(self.v + 1) | ||
m.d.comb += self.o.eq(self.v[-1]) | ||
return m | ||
|
||
|
||
ctr = Counter(width=16) | ||
print(rtlil.convert(ctr, ports=[ctr.o])) |
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,49 @@ | ||
attribute \generator "nMigen" | ||
attribute \top 1 | ||
attribute \nmigen.hierarchy "top" | ||
module \top | ||
attribute \src "counter.py:9" | ||
wire width 1 output 0 \o | ||
attribute \src "/usr/local/lib/python3.7/site-packages/nmigen/hdl/ir.py:526" | ||
wire width 1 input 1 \clk | ||
attribute \src "/usr/local/lib/python3.7/site-packages/nmigen/hdl/ir.py:526" | ||
wire width 1 input 2 \rst | ||
attribute \src "counter.py:8" | ||
wire width 16 \v | ||
attribute \src "counter.py:8" | ||
wire width 16 \v$next | ||
attribute \src "counter.py:13" | ||
wire width 17 $1 | ||
attribute \src "counter.py:13" | ||
wire width 17 $2 | ||
attribute \src "counter.py:13" | ||
cell $add $3 | ||
parameter \A_SIGNED 1'0 | ||
parameter \A_WIDTH 5'10000 | ||
parameter \B_SIGNED 1'0 | ||
parameter \B_WIDTH 1'1 | ||
parameter \Y_WIDTH 5'10001 | ||
connect \A \v | ||
connect \B 1'1 | ||
connect \Y $2 | ||
end | ||
connect $1 $2 | ||
process $group_0 | ||
assign \v$next \v | ||
assign \v$next $1 [15:0] | ||
attribute \src "/usr/local/lib/python3.7/site-packages/nmigen/hdl/xfrm.py:530" | ||
switch \rst | ||
case 1'1 | ||
assign \v$next 16'1111111111111111 | ||
end | ||
sync init | ||
update \v 16'1111111111111111 | ||
sync posedge \clk | ||
update \v \v$next | ||
end | ||
process $group_1 | ||
assign \o 1'0 | ||
assign \o \v [15] | ||
sync init | ||
end | ||
end |
File renamed without changes.
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,37 @@ | ||
Test nMigen | ||
=========== | ||
|
||
This test checks diagram generation from nMigen sources. | ||
|
||
Yosys BlackBox Diagram | ||
---------------------- | ||
|
||
.. code-block:: rst | ||
.. hdl-diagram:: counter.py | ||
:type: yosys-blackbox | ||
.. hdl-diagram:: counter.py | ||
:type: yosys-blackbox | ||
|
||
Yosys AIG Diagram | ||
----------------- | ||
|
||
.. code-block:: rst | ||
.. hdl-diagram:: counter.py | ||
:type: yosys-aig | ||
.. hdl-diagram:: counter.py | ||
:type: yosys-aig | ||
|
||
Netlistsvg Diagram | ||
------------------ | ||
|
||
.. code-block:: rst | ||
.. hdl-diagram:: counter.py | ||
:type: netlistsvg | ||
.. hdl-diagram:: counter.py | ||
:type: netlistsvg |
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,37 @@ | ||
Test RTLIL | ||
=========== | ||
|
||
This test checks diagram generation from RTLIL sources. | ||
|
||
Yosys BlackBox Diagram | ||
---------------------- | ||
|
||
.. code-block:: rst | ||
.. hdl-diagram:: counter.il | ||
:type: yosys-blackbox | ||
.. hdl-diagram:: counter.il | ||
:type: yosys-blackbox | ||
|
||
Yosys AIG Diagram | ||
----------------- | ||
|
||
.. code-block:: rst | ||
.. hdl-diagram:: counter.il | ||
:type: yosys-aig | ||
.. hdl-diagram:: counter.il | ||
:type: yosys-aig | ||
|
||
Netlistsvg Diagram | ||
------------------ | ||
|
||
.. code-block:: rst | ||
.. hdl-diagram:: counter.il | ||
:type: netlistsvg | ||
.. hdl-diagram:: counter.il | ||
:type: netlistsvg |