[myhdl-list] range object
Brought to you by:
jandecaluwe
From: Haitao Z. <ha...@gm...> - 2005-03-02 23:26:35
|
Another nice to have :) In VHDL one could define a range type and define a constant with it, so that one can associate a symbolic name say CTRL_FIELD with 7 DOWNTO 3, and then one can refer to register(CTRL_FIELD). In Verilog one can probably get by with macro defines. However in Python the native slicing is limited to integer arguments (?), so one has to define two named constants instead of passing an indexing object. This feature is handy when one needs to define control register fields. It allows one to define the named constants in one place. In Matlab one can index any vector with another vector. I don't see why this shouldn't be doable in Python as well. Maybe just no need for it, until the hardware designers come along? Is the simplest way to overload __getslice__ to accept a tuple (defining range)? I am not a Python expert so I will be happy to know if there is a way to do it now in Python. Haitao |