Skip to content

Commit 5d87a11

Browse files
committed
Create a base class for process technologies.
Signed-off-by: Tim 'mithro' Ansell <[email protected]>
1 parent 8674fb5 commit 5d87a11

File tree

5 files changed

+97
-8
lines changed

5 files changed

+97
-8
lines changed

vlsiffra/tech/asap7.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
from amaranth import Elaboratable, Instance, Signal
1+
from .base import Process
22

33

4-
class ASAP7Process(Elaboratable):
4+
class ASAP7Process(Process):
55
def _PoweredInstance(self, *args, **kwargs):
66
if self._powered:
77
kwargs.update({

vlsiffra/tech/base.py

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

vlsiffra/tech/gf180mcu.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
from amaranth import Elaboratable, Instance, Signal
1+
from .base import Process
22

33

4-
class GF180MCUProcess(Elaboratable):
4+
class GF180MCUProcess(Process):
55
def _PoweredInstance(self, *args, **kwargs):
66
if self._powered:
77
kwargs.update({

vlsiffra/tech/none.py

+3-2
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

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
from amaranth import Elaboratable, Instance
1+
from .base import Process
22

33

4-
class SKY130HDProcess(Elaboratable):
4+
class SKY130HDProcess(Process):
55
def _PoweredInstance(self, *args, **kwargs):
66
if self._powered:
77
kwargs.update({

0 commit comments

Comments
 (0)