diff --git a/vlsiffra/tech/asap7.py b/vlsiffra/tech/asap7.py index 7f519ea..596d874 100644 --- a/vlsiffra/tech/asap7.py +++ b/vlsiffra/tech/asap7.py @@ -1,7 +1,7 @@ -from amaranth import Elaboratable, Instance, Signal +from .base import Process -class ASAP7Process(Elaboratable): +class ASAP7Process(Process): def _PoweredInstance(self, *args, **kwargs): if self._powered: kwargs.update({ diff --git a/vlsiffra/tech/base.py b/vlsiffra/tech/base.py new file mode 100644 index 0000000..05a067f --- /dev/null +++ b/vlsiffra/tech/base.py @@ -0,0 +1,88 @@ +from amaranth import Elaboratable, Instance + +# The following shell command can be used to discover the usage; +# grep -R '_generate_' | sed -e's/: */:/' -e's/(.*/(/' | sort | uniq | less + +class Process(Elaboratable): + """ Base class for process technologies. """ + + def _PoweredInstance(self, *args, **kwargs): + pass + + # Standard cells used in *both* `adders.py` and `multipliers.py` + + def _generate_and(self, a, b, o): + """2 input AND gate. + + Used by both `adders.py` and `multipliers.py`. + """ + raise NotImplementedError() + + def _generate_xor(self, a, b, o): + """2 input XOR gate. + + Used by both `adders.py` and `multipliers.py`. + """ + raise NotImplementedError() + + def _generate_full_adder(self, a, b, carry_in, sum_out, carry_out, name=None): + """Full adder. + + Used by both `adders.py` and `multipliers.py`. + """ + raise NotImplementedError() + + def _generate_half_adder(self, a, b, sum_out, carry_out, name=None): + """Half adder. + + Used by both `adders.py` and `multipliers.py`. + """ + raise NotImplementedError() + + # Standard cells used only in adders + def _generate_ao21(self, a1, a2, b1, o): + """2-input AND into first input of 2-input OR. + + Used by `adders.py`. + """ + raise NotImplementedError() + + # Standard cells used only in `multipliers.py` + def _generate_inv(self, a, o): + """1-bit inverter. + + Used by `multipliers.py`. + """ + raise NotImplementedError() + + def _generate_ao22(self, a1, a2, b1, b2, o): + """2-input AND into both inputs of 2-input OR. + + Used by `multipliers.py`. + """ + raise NotImplementedError() + + def _generate_ao32(self, a1, a2): + """3-input AND into first input, and 2-input AND into 2nd input of 2-input OR. + + Used by `multipliers.py`. + """ + raise NotImplementedError() + + def _generate_ao33(self, a1, a2, a3, b1, b2, b3, o): + """3-input AND into both inputs of 2-input OR. + + Optional, a `oai33` cell can be provided instead. + + Used by `multipliers.py`. + """ + raise AttributeError() + + def _generate_oai33(self, a1, a2, a3, b1, b2, b3, o): + """3-input AND into both inputs of 2-input OR. + + Optional, can be provided instead of the `ao33` cell. + + Used by `multipliers.py`. + """ + raise AttributeError() diff --git a/vlsiffra/tech/gf180mcu.py b/vlsiffra/tech/gf180mcu.py index d9d9521..af8e799 100644 --- a/vlsiffra/tech/gf180mcu.py +++ b/vlsiffra/tech/gf180mcu.py @@ -1,7 +1,7 @@ -from amaranth import Elaboratable, Instance, Signal +from .base import Process -class GF180MCUProcess(Elaboratable): +class GF180MCUProcess(Process): def _PoweredInstance(self, *args, **kwargs): if self._powered: kwargs.update({ diff --git a/vlsiffra/tech/none.py b/vlsiffra/tech/none.py index 201fde8..f794808 100644 --- a/vlsiffra/tech/none.py +++ b/vlsiffra/tech/none.py @@ -1,7 +1,8 @@ -from amaranth import Elaboratable, Cat +from amaranth import Cat +from .base import Process -class NoneProcess(Elaboratable): +class NoneProcess(Process): def _generate_and(self, a, b, o): self.m.d.comb += o.eq(a & b) diff --git a/vlsiffra/tech/sky130hd.py b/vlsiffra/tech/sky130hd.py index af380d4..691f728 100644 --- a/vlsiffra/tech/sky130hd.py +++ b/vlsiffra/tech/sky130hd.py @@ -1,7 +1,7 @@ -from amaranth import Elaboratable, Instance +from .base import Process -class SKY130HDProcess(Elaboratable): +class SKY130HDProcess(Process): def _PoweredInstance(self, *args, **kwargs): if self._powered: kwargs.update({