|
| 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() |
0 commit comments