> “Programming Hardware” the way it’s used here is pretty much the same as vanilla python
One can only hope so, since the project is a fork of MicroPython. Neither CPython or MicroPython are meant to be a long departure from Python itself.
Anyway, my first impression was same as parent's, write Python get hardware.
One does not "program hardware" except maybe in a CPLD. You cannot write code for a resistor or a tranzistor. You program maybe the microcontroller which is present on the board.
It almost does though. The name of the project has "circuit" in it (I guess because of Arduino applications or something?), and if you are confused why we're talking about circuits, well you can read on where the title goes on to double down on being about "programming hardware".
CPython IS the normal Python you get from python.org, It's only ever called CPython when discussing it in the context of other pythons like MicroPython, PyPy, Jython, etc.
class HalfAdder(Component):
def __init__(self, a, b, out=None, c=None):
super().__init__()
self.a = self.input(a)
self.b = self.input(b)
self.out = self.output(out)
self.c = self.output(c)
XOR(a=self.a, b=self.b, out=self.out)
AND(a=self.a, b=self.b, out=self.c)
having to declare each pin as input or output adds a lot of boilerplate; I was hoping to add a feature where input/output information could be declared using type annotations in the function signature itself. That would look something like: class HalfAdder(Component):
def __init__(self,
a: input,
b: input,
out:output = None,
c:output = None):
super().__init__()
XOR(a=self.a, b=self.b, out=self.out)
AND(a=self.a, b=self.b, out=self.c)
which I think is starting to look pretty Verilog-ish, while still staying Pythonic.