Re: [myhdl-list] Convertible records
Brought to you by:
jandecaluwe
From: Christopher F. <chr...@gm...> - 2011-09-02 19:21:26
|
On 9/2/2011 1:57 PM, Sébastien Bourdeauducq wrote: > On 09/02/2011 08:15 PM, Jan Langer wrote: >> maybe it would be a good idea to let the converter "ask" the class how >> it wants to be converted > > Can't you infer the list of signals to convert from which ones get > actually used? > > What would be good imo (but with my limited knowledge of Python, I don't > know if it's possible) is to simply name signal objects in the generated > HDL according to how they were created. For example: > > class some_class() > def __init__(x): > self.some_signal = x I think, similar to the previous examples, we want the class with signals to be declarative and not dynamically building. Not that they can't be, but for a start should limit the discussion to building objects similar to VHDL record and SV struct. (??) The SignalStruct is a basic container of Signals. At least for conversion, modeling you can do all kinds of cool stuff. If you encapsulate an interface (collection of signals) into a class (SignalStruct) you can build in balun circuits :) Think they are also know as transactors or interfaces abstractions. > (...) > b = Signal(bool(0)) > some_object = some_class(b) > toVerilog(some_object.method) > => gives a signal named "b" > > class some_class() > def __init__(): > self.some_signal = Signal(bool(0)) > (...) > some_object = some_class() > toVerilog(some_object.method) > => gives a signal named "some_object_some_signal" > > (We should adopt a better naming scheme to guarantee the absence of > collisions, but you get the idea) > > This way (I believe) we could happily play with Python objects and still > make nicely convertible/synthesizable code. > > For ports, we can maybe give references to signal objects we want > exported to the conversion functions. I think the port can be the class object, for the previous example bus1 = MyBus() bus2 = MyBus() arb = MyBusArb(bus1, bus2) # <-- RTL module The converter will check the types, and will be ok with the port types because it will know how to handle them. Regards, Chris |