Skip to content

Commit f9477d8

Browse files
mithroTim 'mithro' Ansell
authored andcommitted
Create a base class for process technologies.
Signed-off-by: Tim 'mithro' Ansell <me@mith.ro>
1 parent 8674fb5 commit f9477d8

5 files changed

Lines changed: 101 additions & 8 deletions

File tree

vlsiffra/tech/asap7.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
from amaranth import Elaboratable, Instance, Signal
1+
from amaranth import Instance, Signal
2+
from .base import Process
23

34

4-
class ASAP7Process(Elaboratable):
5+
class ASAP7Process(Process):
56
def _PoweredInstance(self, *args, **kwargs):
67
if self._powered:
78
kwargs.update({

vlsiffra/tech/base.py

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
from amaranth import Elaboratable
2+
3+
# The following shell command can be used to discover the usage;
4+
# grep -R '_generate_' | sed -e's/: */:/' -e's/(.*/(/' | sort | uniq | less
5+
6+
7+
class Process(Elaboratable):
8+
""" Base class for process technologies. """
9+
10+
def _PoweredInstance(self, *args, **kwargs):
11+
pass
12+
13+
# Standard cells used in *both* `adders.py` and `multipliers.py`
14+
15+
def _generate_and(self, a, b, o):
16+
"""2 input AND gate.
17+
18+
Used by both `adders.py` and `multipliers.py`.
19+
"""
20+
raise NotImplementedError()
21+
22+
def _generate_xor(self, a, b, o):
23+
"""2 input XOR gate.
24+
25+
Used by both `adders.py` and `multipliers.py`.
26+
"""
27+
raise NotImplementedError()
28+
29+
def _generate_full_adder(self, a, b, carry_in, sum_out, carry_out, name=None):
30+
"""Full adder.
31+
32+
Used by both `adders.py` and `multipliers.py`.
33+
"""
34+
raise NotImplementedError()
35+
36+
def _generate_half_adder(self, a, b, sum_out, carry_out, name=None):
37+
"""Half adder.
38+
39+
Used by both `adders.py` and `multipliers.py`.
40+
"""
41+
raise NotImplementedError()
42+
43+
# Standard cells used only in adders
44+
def _generate_ao21(self, a1, a2, b1, o):
45+
"""2-input AND into first input of 2-input OR.
46+
47+
Used by `adders.py`.
48+
"""
49+
raise NotImplementedError()
50+
51+
# Standard cells used only in `multipliers.py`
52+
def _generate_inv(self, a, o):
53+
"""1-bit inverter.
54+
55+
Used by `multipliers.py`.
56+
"""
57+
raise NotImplementedError()
58+
59+
def _generate_ao22(self, a1, a2, b1, b2, o):
60+
"""2-input AND into both inputs of 2-input OR.
61+
62+
Used by `multipliers.py`.
63+
"""
64+
raise NotImplementedError()
65+
66+
def _generate_ao32(self, a1, a2):
67+
"""3-input AND into first input, and 2-input AND into 2nd input of 2-input OR.
68+
69+
Used by `multipliers.py`.
70+
"""
71+
raise NotImplementedError()
72+
73+
def _generate_ao33(self, a1, a2, a3, b1, b2, b3, o):
74+
"""3-input AND into both inputs of 2-input OR.
75+
76+
Optional, a `oai33` cell can be provided instead.
77+
78+
Used by `multipliers.py`.
79+
"""
80+
raise AttributeError()
81+
82+
def _generate_oai33(self, a1, a2, a3, b1, b2, b3, o):
83+
"""3-input AND into both inputs of 2-input OR.
84+
85+
Optional, can be provided instead of the `ao33` cell.
86+
87+
Used by `multipliers.py`.
88+
"""
89+
raise AttributeError()

vlsiffra/tech/gf180mcu.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
from amaranth import Elaboratable, Instance, Signal
1+
from amaranth import Instance, Signal
2+
from .base import Process
23

34

4-
class GF180MCUProcess(Elaboratable):
5+
class GF180MCUProcess(Process):
56
def _PoweredInstance(self, *args, **kwargs):
67
if self._powered:
78
kwargs.update({

vlsiffra/tech/none.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
from amaranth import Elaboratable, Cat
1+
from amaranth import Cat
2+
from .base import Process
23

34

4-
class NoneProcess(Elaboratable):
5+
class NoneProcess(Process):
56
def _generate_and(self, a, b, o):
67
self.m.d.comb += o.eq(a & b)
78

vlsiffra/tech/sky130hd.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
from amaranth import Elaboratable, Instance
1+
from amaranth import Instance
2+
from .base import Process
23

34

4-
class SKY130HDProcess(Elaboratable):
5+
class SKY130HDProcess(Process):
56
def _PoweredInstance(self, *args, **kwargs):
67
if self._powered:
78
kwargs.update({

0 commit comments

Comments
 (0)