Thread: [myhdl-list] MEP : Signal Containers
Brought to you by:
jandecaluwe
From: Christopher F. <chr...@gm...> - 2011-11-15 04:33:25
|
The following is a *start* to a MEP that describes the conversion support for classes, lists, and dictionaries. This is just a start of the enhancement description and does not include some of the mechanical (code changes) items worth identifying in a MEP. I am posting the rough draft of the enhancement because there was interest in this enhancement and others might want to contribute to the MEP and code changes. Also, some initial development might occur before Jan returns but finalization will await his review. All feedback welcome. After some time (initial feedback) this will be moved to the wiki. Regards, Chris ****************** Signal Containers ****************** Introduction ============= The following is a proposal to add conversion support for Signal containers. Signal containers are; classes, lists, and dictionaries that contain a Signal type. Lists, and dictionaries are built-in data structures in the Python programming language. A class is the common method to define objects. For more information on Python classes, lists, and dictionaries see `[1]`_, `[2]`_, `[3]`_ and `[4]`_. Another native data structure in the Python programming language is the tuple. Tuples are non-mutable and not usable in this case. Tuples are useful when defining `ROMS`_ and currently supported. The rest of this enhancement proposal will outline the addition of classes, lists, and dictionaries to the MyHDL convertible subset of the Python programming language. Through the rest of this document the term "container(s)" will be used to refer to data structures and objects that contains Signals and other convertible types. .. _[1] : http://docs.python.org/tutorial/classes.html .. _[2] : http://docs.python.org/tutorial/introduction.html#lists .. _[3] : http://docs.python.org/tutorial/datastructures.html .. _[4] : http://docs.python.org/tutorial/datastructures.html#dictionaries .. _ROMS : http://www.myhdl.org/doc/0.6/manual/conversion_examples.html#rom-inference The desired approach is to generate a unique name for a Signal that is part of a container. If an expression includes a "container" a net name will be generate for the Signal, example :: myObject.x.next = ListOfSignal[10] + DictOfSignal['fred'] The above example has all three container types; a class, a list with signals and a dictionary with signals. The conversion utilities would determine if the type referenced is a Signal and then create a unique name for the Signal. :: myObject_x = ListOfSignal_10 + DictOfSignal_fred The converter will simply use the container's instance name as part of the net name. The same rules that apply to hierarchy naming will be included. The above might be converted to something like the following to avoid name collisions. :: mod1_mod2_myObject_x = mod1_mod2_ListOfSignal_10 + mod1_mod2_DictOfSignal_fred In other cases a data structure might not contain a Signal but a constant (literals). In this case the conversion methods will dig down to find the constant and use the constant value. Required support: * Expansion of Signal container names * Containers as ports * Containers as sensitivity lists * Resolution of data in data structures In general, containers can be used, as long as the final referenced object is a convertible type (Signal, int, long, bool, intbv). All of the above is supported for modeling in MyHDL 0.7, except for "containers as sensitivity lists" as discussed in the mailing-list. This feature is similar to the VHDL record and SystemVerilog struct. The idea is that signals can be logically grouped. This can be very useful to a designer to logically group signals. Variables in containers ------------------------ Variables should be supported as well. When variables are used, if needed, the variable should be converted to a long net name. Variables in containers will follow the same rules as outlined for signals in a container. Classes ======== Classes that contain Signals or a hierarchy of classes that eventually contain a Signal should be converted. Classes should be converted according to the following rules: #. The object attribute referenced is a convertible type #. Left hand side : Signal of type intbv or bool #. Right hand side : int, long, bool, intbv or a Signal of type int, long, bool, intbv #. The object being referenced will be represented in the converted code as a long-net-name. Long-net-names are derived by: #. Hierarchy name rules (which are?) #. Class path name, example :: class.refObj = class_refObj class1.class2.refObj = class1_class2_refObj Example -------- .. code-block :: python class MyObj(object): def __init__(self): x = Signal(intbv(0)[8:]) y = Signal(intbv(0)[4:]) z = Signal(intbv(0)[9:]) def foo(clk, srst, xyz): @always(clk.posedge) def rtl(): xyz.z.next = xyz.x + xyz.y return rtl if __name__ == '__main__': clk = Signal(False) xyz = MyObj() toVerilog(foo, clk, xyz) Verilog example conversion for the above. .. code-block :: verilog module foo ( input wire clk, input wire [7:0] MyObj_x, input wire [3:0] MyObj_y, output wire [8:0] MyObj_z ): always @(posedge clk) begin MyObj_z <= MyObj_x + MyObj_y end endmodule VHDL example conversion. .. code-block :: vhdl -- TBC Conversion of class methods ---------------------------- Generally speaking, the conversion of a class method that is a generator (yields not returns) is convertible. But it is not supported because the first argument to a class method is the object instance that contains the method (usually self). In conversion this is converted as a port. Another change proposed in this MEP is to ignore the first parameter of a class method so that class methods can be converted directly. This makes the conversion of classes more complete. For class methods, the only exception (difference) to the converter compared to a standard function is to ignore the first argument of the class method. The rest of the conversion would functionally be equivalent to the function conversion. Heterogeneous List Of Signals ============================== Here heterogeneous is used to differentiate a list of signals that contain different signal types versus list of signals that is homogeneous, all the same type of signals. Homogeneous list of signals are currently supported and convert to the underlying HDL as an array of bit-vectors. This is useful for defining `memories`_. The functions that determines a memory object will need to be enhanced to differentiate a homogeneous list of signals from a heterogeneous list of signals. .. _memories : http://www.myhdl.org/doc/0.6/manual/conversion_examples.html#ram-inference Dictionaries ============ Similar to the class conversion dictionaries should be convertible as well. The same rules that applied to class conversion should be applied to dictionaries. |
From: Oscar D. <osc...@gm...> - 2011-11-21 15:39:13
|
2011/11/15 Christopher Felton <chr...@gm...>: > The following is a *start* to a MEP that describes the conversion > support for classes, lists, and dictionaries. This is just a start of > the enhancement description and does not include some of the mechanical > (code changes) items worth identifying in a MEP. Thanks for making this draft. I'm mostly agree this MEP, I'll just add some thoughts: * Since a class could be more powerful than a list or a dict, container classes should allow enhanced features i.e. custom naming scheme. We can propose hidden methods to support that features, in a similar way of the special methods from the python data model: http://docs.python.org/reference/datamodel.html#special-method-names Right now I'm thinking about * It's not explicitly mentioned, but I guess the conversion step will "flatten" the signal container. Although I agree on that, maybe we could think about support to conversion to arrays or records (I speak mainly for VHDL, I'm not that expert of Verilog). * About the conversion of class methods, I think that should be in another MEP, this one is to define signal containers. We should make another MEP to add support for conversion of classes (not just class methods). However, I do agree that the class methods must have support for conversion, as you explained here, and I think it is easy to fix the self argument issue in the conversion code. That's all for now. Best regards. P.D.: Perhaps I can help with the VHDL code snippet: VHDL example conversion. .. code-block :: vhdl entity foo is port ( clk: in std_logic; MyObj_x: in unsigned(7 downto 0); MyObj_y: in unsigned(3 downto 0); MyObj_z: out unsigned(8 downto 0) ); end entity foo; architecture MyHDL of foo is begin RTL: process(clk) is begin if rising_edge(clk) then MyObj_z <= MyObj_x + MyObj_y end if; end process RTL; end architecture MyHDL; -- Oscar Díaz Key Fingerprint = 904B 306C C3C2 7487 650B BFAC EDA2 B702 90E9 9964 gpg --keyserver subkeys.pgp.net --recv-keys 90E99964 I recommend using OpenDocument Format for daily use and exchange of documents. http://www.fsf.org/campaigns/opendocument |
From: Oscar D. <osc...@gm...> - 2011-11-21 15:54:02
|
2011/11/21 Oscar Diaz <osc...@gm...>: > 2011/11/15 Christopher Felton <chr...@gm...>: >> The following is a *start* to a MEP that describes the conversion >> support for classes, lists, and dictionaries. This is just a start of >> the enhancement description and does not include some of the mechanical >> (code changes) items worth identifying in a MEP. > > Thanks for making this draft. I'm mostly agree this MEP, I'll just add > some thoughts: > > * Since a class could be more powerful than a list or a dict, > container classes should allow enhanced features i.e. custom naming > scheme. We can propose hidden methods to support that features, in a > similar way of the special methods from the python data model: > > http://docs.python.org/reference/datamodel.html#special-method-names > > Right now I'm thinking about Sorry, I press Enter too quick :p Right now I'm thinking about: * custom naming scheme: something like "_names_iter(self)" method that returns the desired names for each signal. * late signal creation: suppose that I need to calculate the width of a signal, but I already create the container object. A method that create (or update) the signal objects just before simulation or conversion can be defined. * classes with special method names: what happen if I define the __slot__ list? or if I define a custom __getattr__ or another methods? -- Oscar Díaz Key Fingerprint = 904B 306C C3C2 7487 650B BFAC EDA2 B702 90E9 9964 gpg --keyserver subkeys.pgp.net --recv-keys 90E99964 I recommend using OpenDocument Format for daily use and exchange of documents. http://www.fsf.org/campaigns/opendocument |
From: Christopher F. <chr...@gm...> - 2011-11-21 16:56:17
|
On 11/21/2011 9:39 AM, Oscar Diaz wrote: > 2011/11/15 Christopher Felton<chr...@gm...>: >> The following is a *start* to a MEP that describes the conversion >> support for classes, lists, and dictionaries. This is just a start of >> the enhancement description and does not include some of the mechanical >> (code changes) items worth identifying in a MEP. > > Thanks for making this draft. I'm mostly agree this MEP, I'll just add > some thoughts: > > * Since a class could be more powerful than a list or a dict, > container classes should allow enhanced features i.e. custom naming > scheme. We can propose hidden methods to support that features, in a > similar way of the special methods from the python data model: > > http://docs.python.org/reference/datamodel.html#special-method-names If we do this we would need to define a base class, something like SignalStruct, that would contain these features. Past feedback indicate they would like general class/objects to be convertible without defining a special base class. I think general class/objects would need to be supported but having an additional MyHDL ojbect to help guide conversion would be useful. Also, defining a SignalStruct object would make things easier (my guess) for a first implementation. It might be a good spot to start with and explore the conversion routines. > > Right now I'm thinking about > > * It's not explicitly mentioned, but I guess the conversion step will > "flatten" the signal container. Although I agree on that, maybe we > could think about support to conversion to arrays or records (I speak > mainly for VHDL, I'm not that expert of Verilog). The argument against using VHDL records is to keep a similar conversion for Verilog and VHDL, IMO. We don't want to use the SystemVerilog struct unless it is supported by the open-source compiler/simulators. Since we need to flatten it for Verilog I think flattening it VHDL is reasonable, least common denominator. My thought, if we have a special case for VHDL it would be more work to develop, maintain, and test. Personally I like limiting the use of the underlying HDL as minimal as possible and maximum overlap between HDLs. > > * About the conversion of class methods, I think that should be in > another MEP, this one is to define signal containers. We should make > another MEP to add support for conversion of classes (not just class > methods). However, I do agree that the class methods must have support > for conversion, as you explained here, and I think it is easy to fix > the self argument issue in the conversion code. That is reasonable but I don't follow what you mean by the conversion of classes? In my mind, once you have a mechanism to dig down and find the signal, I call them primitives (which is the main purpose of this mep). And generator conversion is already supported (other than a generator that is defined in a class). > > That's all for now. > > Best regards. > > P.D.: Perhaps I can help with the VHDL code snippet: > > VHDL example conversion. > .. code-block :: vhdl > > entity foo is > port ( > clk: in std_logic; > MyObj_x: in unsigned(7 downto 0); > MyObj_y: in unsigned(3 downto 0); > MyObj_z: out unsigned(8 downto 0) > ); > end entity foo; > > architecture MyHDL of foo is > > begin > > RTL: process(clk) is > begin > if rising_edge(clk) then > MyObj_z<= MyObj_x + MyObj_y > end if; > end process RTL; > > end architecture MyHDL; > > Thanks for the code snip. > Right now I'm thinking about: > * custom naming scheme: something like "_names_iter(self)" method that > returns the desired names for each signal. I believe an object would need to be provided, that has special hooks and methods. But the use of the object (e.g. SignalStruct) is optional. Converting objects with Signal members should be convertible. I will add this MyHDL object, SignalStruct, to the MEP and outline what you have suggested. > * late signal creation: suppose that I need to calculate the width of > a signal, but I already create the container object. A method that > create (or update) the signal objects just before simulation or > conversion can be defined. Late/dynamic signal creation is not an issue as long as it is done during elaboration. > * classes with special method names: what happen if I define the > __slot__ list? or if I define a custom __getattr__ or another methods? No methods would be used/inspected for conversion (ignoring generators for now), special methods shouldn't cause a problem. A member of an object, if it is a convertible Signal or a convertible constant will be considered for conversion and flattened. Thanks for the feedback, Chris |
From: Oscar D. <osc...@gm...> - 2011-11-21 17:29:50
|
2011/11/21 Christopher Felton <chr...@gm...>: > On 11/21/2011 9:39 AM, Oscar Diaz wrote: >> 2011/11/15 Christopher Felton<chr...@gm...>: >>> The following is a *start* to a MEP that describes the conversion >>> support for classes, lists, and dictionaries. This is just a start of >>> the enhancement description and does not include some of the mechanical >>> (code changes) items worth identifying in a MEP. >> >> Thanks for making this draft. I'm mostly agree this MEP, I'll just add >> some thoughts: >> >> * Since a class could be more powerful than a list or a dict, >> container classes should allow enhanced features i.e. custom naming >> scheme. We can propose hidden methods to support that features, in a >> similar way of the special methods from the python data model: >> >> http://docs.python.org/reference/datamodel.html#special-method-names > > If we do this we would need to define a base class, something like > SignalStruct, that would contain these features. Past feedback indicate > they would like general class/objects to be convertible without defining > a special base class. > > I think general class/objects would need to be supported but having an > additional MyHDL ojbect to help guide conversion would be useful. Also, > defining a SignalStruct object would make things easier (my guess) for a > first implementation. It might be a good spot to start with and explore > the conversion routines. > >> >> Right now I'm thinking about >> >> * It's not explicitly mentioned, but I guess the conversion step will >> "flatten" the signal container. Although I agree on that, maybe we >> could think about support to conversion to arrays or records (I speak >> mainly for VHDL, I'm not that expert of Verilog). > > The argument against using VHDL records is to keep a similar conversion > for Verilog and VHDL, IMO. We don't want to use the SystemVerilog > struct unless it is supported by the open-source compiler/simulators. > Since we need to flatten it for Verilog I think flattening it VHDL is > reasonable, least common denominator. > > My thought, if we have a special case for VHDL it would be more work to > develop, maintain, and test. Personally I like limiting the use of the > underlying HDL as minimal as possible and maximum overlap between HDLs. > >> >> * About the conversion of class methods, I think that should be in >> another MEP, this one is to define signal containers. We should make >> another MEP to add support for conversion of classes (not just class >> methods). However, I do agree that the class methods must have support >> for conversion, as you explained here, and I think it is easy to fix >> the self argument issue in the conversion code. > > That is reasonable but I don't follow what you mean by the conversion of > classes? In my mind, once you have a mechanism to dig down and find the > signal, I call them primitives (which is the main purpose of this mep). > And generator conversion is already supported (other than a generator > that is defined in a class). What I mean is a "standard" way to use classes. In my projects, I make heavy use of inheritance to add generators on base components. Right now I'm using a list of generators inside the classes, and just append generators at __init__ or by calling methods from the extended classes. On simulation, I make a big list with all the generators from all objects instantiated' list of generators. It works nice on simulation, but I wanted to do the same for conversion (I haven't researched this last issue yet). > >> >> That's all for now. >> >> Best regards. >> >> P.D.: Perhaps I can help with the VHDL code snippet: >> >> VHDL example conversion. >> .. code-block :: vhdl >> >> entity foo is >> port ( >> clk: in std_logic; >> MyObj_x: in unsigned(7 downto 0); >> MyObj_y: in unsigned(3 downto 0); >> MyObj_z: out unsigned(8 downto 0) >> ); >> end entity foo; >> >> architecture MyHDL of foo is >> >> begin >> >> RTL: process(clk) is >> begin >> if rising_edge(clk) then >> MyObj_z<= MyObj_x + MyObj_y >> end if; >> end process RTL; >> >> end architecture MyHDL; >> >> > > Thanks for the code snip. > >> Right now I'm thinking about: >> * custom naming scheme: something like "_names_iter(self)" method that >> returns the desired names for each signal. > I believe an object would need to be provided, that has special hooks > and methods. But the use of the object (e.g. SignalStruct) is optional. > Converting objects with Signal members should be convertible. I will > add this MyHDL object, SignalStruct, to the MEP and outline what you > have suggested. > >> * late signal creation: suppose that I need to calculate the width of >> a signal, but I already create the container object. A method that >> create (or update) the signal objects just before simulation or >> conversion can be defined. > Late/dynamic signal creation is not an issue as long as it is done > during elaboration. > >> * classes with special method names: what happen if I define the >> __slot__ list? or if I define a custom __getattr__ or another methods? > > No methods would be used/inspected for conversion (ignoring generators > for now), special methods shouldn't cause a problem. A member of an > object, if it is a convertible Signal or a convertible constant will be > considered for conversion and flattened. > > Thanks for the feedback, > Chris Best regards > > > ------------------------------------------------------------------------------ > All the data continuously generated in your IT infrastructure > contains a definitive record of customers, application performance, > security threats, fraudulent activity, and more. Splunk takes this > data and makes sense of it. IT sense. And common sense. > http://p.sf.net/sfu/splunk-novd2d > _______________________________________________ > myhdl-list mailing list > myh...@li... > https://lists.sourceforge.net/lists/listinfo/myhdl-list > -- Oscar Díaz Key Fingerprint = 904B 306C C3C2 7487 650B BFAC EDA2 B702 90E9 9964 gpg --keyserver subkeys.pgp.net --recv-keys 90E99964 I recommend using OpenDocument Format for daily use and exchange of documents. http://www.fsf.org/campaigns/opendocument |
From: Christopher F. <chr...@gm...> - 2012-05-14 11:48:37
|
On 11/14/2011 10:32 PM, Christopher Felton wrote: > The following is a *start* to a MEP that describes the conversion > support for classes, lists, and dictionaries. This is just a start of > the enhancement description and does not include some of the mechanical > (code changes) items worth identifying in a MEP. > <snip> I have made some minor changes to the proposed MEP, the modifications can be found here, http://www.myhdl.org/doku.php/meps:mep-107 I have been *waffling* if the class attributes should be part of this MEP or a separate MEP. I am leaning more towards inclusion, if a class attribute is a convertible type then it can be viewed as a "Signal Container". But it might warrant it separate MEP/thread simply because the conversation around class support might be lengthy, e.g. subset of class support (the current MEP107 and MEP108) or something different. Regards, Chris |
From: Oscar D. <osc...@gm...> - 2012-05-17 09:03:41
|
2012/5/14 Christopher Felton <chr...@gm...>: > On 11/14/2011 10:32 PM, Christopher Felton wrote: >> The following is a *start* to a MEP that describes the conversion >> support for classes, lists, and dictionaries. This is just a start of >> the enhancement description and does not include some of the mechanical >> (code changes) items worth identifying in a MEP. >> > <snip> > > I have made some minor changes to the proposed MEP, the modifications > can be found here, http://www.myhdl.org/doku.php/meps:mep-107 > > I have been *waffling* if the class attributes should be part of this > MEP or a separate MEP. I am leaning more towards inclusion, if a class > attribute is a convertible type then it can be viewed as a "Signal > Container". But it might warrant it separate MEP/thread simply because > the conversation around class support might be lengthy, e.g. subset of > class support (the current MEP107 and MEP108) or something different. I agree: class attributes should be covered in this MEP (as we discussed in this thread). However, I think this MEP should address first the easy containers: lists and dictionaries, and after that experience we can move to support -the more general- class attributes. > > Regards, > Chris > > > ------------------------------------------------------------------------------ > Live Security Virtual Conference > Exclusive live event will cover all the ways today's security and > threat landscape has changed and how IT managers can respond. Discussions > will include endpoint security, mobile security and the latest in malware > threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ > _______________________________________________ > myhdl-list mailing list > myh...@li... > https://lists.sourceforge.net/lists/listinfo/myhdl-list -- Oscar Díaz Key Fingerprint = 904B 306C C3C2 7487 650B BFAC EDA2 B702 90E9 9964 gpg --keyserver subkeys.pgp.net --recv-keys 90E99964 I recommend using OpenDocument Format for daily use and exchange of documents. http://www.fsf.org/campaigns/opendocument |
From: Tom D. <td...@di...> - 2012-05-17 13:36:09
|
On 05/17/2012 04:03 AM, Oscar Diaz wrote: > 2012/5/14 Christopher Felton<chr...@gm...>: > >> <snip> >> >> I have made some minor changes to the proposed MEP, the modifications >> can be found here, http://www.myhdl.org/doku.php/meps:mep-107 >> >> I have been *waffling* if the class attributes should be part of this >> MEP or a separate MEP. I am leaning more towards inclusion, if a class >> attribute is a convertible type then it can be viewed as a "Signal >> Container". But it might warrant it separate MEP/thread simply because >> the conversation around class support might be lengthy, e.g. subset of >> class support (the current MEP107 and MEP108) or something different. > I agree: class attributes should be covered in this MEP (as we > discussed in this thread). However, I think this MEP should address > first the easy containers: lists and dictionaries, and after that > experience we can move to support -the more general- class attributes. > I am more interested in using classes. I am not sure what class attributes would do. Can someone provide an example? My use for this is really to group related signals, so that you can pass them as a group. Secondary use would be to provide some useful class functions to do redundant tasks that I would prefer to hide in the class. My simple example would be for complex numbers. The object would simply store two values, real and imaginary. It would have some member functions like next(cplxNum), which would do the complex assignment to the two signals stored in the object. It would have other member functions as well, but you get the idea. Now, this all works now, other than you can't use the class object as a top level port of your MyHDL module. For now, I have to make a top level wrapper that breaks out the complex object into its real and imaginary signals and creates twice as many ports. Not horrible, but it is tedious and prone to errors. What I think would be useful, is for the class to have some hooks for conversion. For instance you may want to tell it to break out the object into two separate signals. Or you may want to concatenate them together into one long vector. I am very unfamiliar with conversion so have no idea the best way to achieve something like this. I guess I need to understand other issues to know what everybody else wants out of this. Tom |
From: Christopher F. <chr...@gm...> - 2012-05-18 15:08:33
|
On 5/17/12 8:35 AM, Tom Dillon wrote: > > > On 05/17/2012 04:03 AM, Oscar Diaz wrote: >> 2012/5/14 Christopher Felton<chr...@gm...>: >> >>> <snip> >>> >>> I have made some minor changes to the proposed MEP, the modifications >>> can be found here, http://www.myhdl.org/doku.php/meps:mep-107 >>> >>> I have been *waffling* if the class attributes should be part of this >>> MEP or a separate MEP. I am leaning more towards inclusion, if a class >>> attribute is a convertible type then it can be viewed as a "Signal >>> Container". But it might warrant it separate MEP/thread simply because >>> the conversation around class support might be lengthy, e.g. subset of >>> class support (the current MEP107 and MEP108) or something different. >> I agree: class attributes should be covered in this MEP (as we >> discussed in this thread). However, I think this MEP should address >> first the easy containers: lists and dictionaries, and after that >> experience we can move to support -the more general- class attributes. >> > I am more interested in using classes. I am not sure what class > attributes would do. Can someone provide an example? I have already implemented this feature and created a MEP write-up, MEP-108, http://www.myhdl.org/doku.php/meps:mep-108. There hasn't been much discussion so I haven't posted the patch yet. I will post the patch soon. > > My use for this is really to group related signals, so that you can pass > them as a group. Secondary use would be to provide some useful class > functions to do redundant tasks that I would prefer to hide in the class. Yes, that is the intent of the class attribute "signal container". A tool to group associated signals, like an embedded bus such as, Wishbone or Avalon. > > My simple example would be for complex numbers. The object would simply > store two values, real and imaginary. It would have some member > functions like next(cplxNum), which would do the complex assignment to > the two signals stored in the object. It would have other member > functions as well, but you get the idea. A complex number is a good example as well but also an example that illustrates why I have some reservations. With a complex number, in the SW world you also would want to define the operators on the new "type". This MEP only covers class use as a container and not general OO. That is my worry given some of the recent threads that this will open more confusion and misunderstanding, at least with Mr.Issues. The signal container MEP is simply to use the classes like a VHDL record or an SV struct. You can group associated signals and constants. But I think the class attribute signal container could be very useful if the confusion can be curbed. > > Now, this all works now, other than you can't use the class object as a > top level port of your MyHDL module. For now, I have to make a top > level wrapper that breaks out the complex object into its real and > imaginary signals and creates twice as many ports. Not horrible, but it > is tedious and prone to errors. I believe I have this resolved as long as the community agrees with the "feature", i.e gives the thumbs up. > > What I think would be useful, is for the class to have some hooks for > conversion. For instance you may want to tell it to break out the object > into two separate signals. Or you may want to concatenate them together > into one long vector. > > I am very unfamiliar with conversion so have no idea the best way to > achieve something like this. > > I guess I need to understand other issues to know what everybody else > wants out of this. I think the "hooks" could be a follow-on feature. I believe the current proposal is clear that it only allows the class attribute to be used a signal container. You still need to use the contained signal the same as you would handle current signals. Once the straight-up signal attribute and class methods are supported it is a good stepping stone for what you suggest. As mentioned, probably the most familiar example (I will add this to the MEP) is an embedded bus. I can create the following class class WishboneBus(object): def __init__(self, DataWidth=16, AddressWidth=8): self.clk = Signal(False) self.rst = Signal(False) self.cyc = Signal(False) self.stb = Signal(False) self.adr = Signal(intbv(0)[AddressWeidth:]) self.dat_i = Signal(intbv(0)[DataWidth:]) self.dat_o = Signal(intbv(0)[DataWidth:]) self.we = Signal(False) self.sel = Signal(intbv(0)[int(DataWidth/8)"]) self.ack = Signal(False) def WbGpio(wb_bus, outs, ints): ... wb_bus = WishboneBus() outs = Signal(intbv(0)[8:]) ints = Signal(intbv(0)[8:]) iGpio = WbGpio(wb_bus, outs, ins) In the above example the embedded bus is contained in the class description. The benefit is clumping associated signals together. It simply makes the hardware description more compact without losing descriptive information. In the above example, if I have a bunch of peripherals the bus that connects them all is in a neat compact description. As the MEP indicates the converted code these will all be individual signals in the lower HDLs, mainly so that the older most supported versions of Verilog/VHDL can be supported. Regards, Chris |
From: Tom D. <td...@di...> - 2012-05-18 15:28:12
|
On 05/18/2012 10:08 AM, Christopher Felton wrote: > On 5/17/12 8:35 AM, Tom Dillon wrote: >> >> On 05/17/2012 04:03 AM, Oscar Diaz wrote: >>> 2012/5/14 Christopher Felton<chr...@gm...>: >>> >>>> <snip> >>>> >>>> I have made some minor changes to the proposed MEP, the modifications >>>> can be found here, http://www.myhdl.org/doku.php/meps:mep-107 >>>> >>>> I have been *waffling* if the class attributes should be part of this >>>> MEP or a separate MEP. I am leaning more towards inclusion, if a class >>>> attribute is a convertible type then it can be viewed as a "Signal >>>> Container". But it might warrant it separate MEP/thread simply because >>>> the conversation around class support might be lengthy, e.g. subset of >>>> class support (the current MEP107 and MEP108) or something different. >>> I agree: class attributes should be covered in this MEP (as we >>> discussed in this thread). However, I think this MEP should address >>> first the easy containers: lists and dictionaries, and after that >>> experience we can move to support -the more general- class attributes. >>> >> I am more interested in using classes. I am not sure what class >> attributes would do. Can someone provide an example? > I have already implemented this feature and created a MEP write-up, > MEP-108, http://www.myhdl.org/doku.php/meps:mep-108. There hasn't been > much discussion so I haven't posted the patch yet. I will post the > patch soon. Read that over quickly. What is the advantage to that over a function? Also, how do class attributes fit into this? I think I may not undertand what they are and how they would be used in MyHDL. |
From: Christopher F. <chr...@gm...> - 2012-05-18 19:57:33
|
On 5/18/12 10:28 AM, Tom Dillon wrote: > > > On 05/18/2012 10:08 AM, Christopher Felton wrote: >> On 5/17/12 8:35 AM, Tom Dillon wrote: >>> >>> On 05/17/2012 04:03 AM, Oscar Diaz wrote: >>>> 2012/5/14 Christopher Felton<chr...@gm...>: >>>> >>>>> <snip> >>>>> >>>>> I have made some minor changes to the proposed MEP, the modifications >>>>> can be found here, http://www.myhdl.org/doku.php/meps:mep-107 >>>>> >>>>> I have been *waffling* if the class attributes should be part of this >>>>> MEP or a separate MEP. I am leaning more towards inclusion, if a class >>>>> attribute is a convertible type then it can be viewed as a "Signal >>>>> Container". But it might warrant it separate MEP/thread simply because >>>>> the conversation around class support might be lengthy, e.g. subset of >>>>> class support (the current MEP107 and MEP108) or something different. >>>> I agree: class attributes should be covered in this MEP (as we >>>> discussed in this thread). However, I think this MEP should address >>>> first the easy containers: lists and dictionaries, and after that >>>> experience we can move to support -the more general- class attributes. >>>> >>> I am more interested in using classes. I am not sure what class >>> attributes would do. Can someone provide an example? >> I have already implemented this feature and created a MEP write-up, >> MEP-108, http://www.myhdl.org/doku.php/meps:mep-108. There hasn't been >> much discussion so I haven't posted the patch yet. I will post the >> patch soon. > > Read that over quickly. What is the advantage to that over a function? > > Also, how do class attributes fit into this? I think I may not undertand > what they are and how they would be used in MyHDL. > Where I inlined my responses might have made it confusing. First, the reference to MEP-108 was simply to respond to your overall comment (or at least my interpretation) that /class methods/ be convertible. If you meant /class method/ conversion would be of interest then MEP-108 is relevant, if not I misunderstood. The advantage of a class method over a function ... no advantage per se. They both achieve the same thing in the similar manner. But it gives the ability to use a method versus a function if someone wanted. We have had this conversation a couple times in the past. The current solution is to have a method that returns the generators from the function, essentially wrapping a function in a /class method/. By allowing the /class method/ to be directly convertible would remove the need to wrap a function. MEP-108 is simple, its only intention is to enable a /class method/ the same as a function. My best example of why you might want to do this is the following example, http://bit.ly/w95kOd. The /class method/ conversion and the /class attribute/ can be viewed as separate. They can be used together but nothing says they have to be and the reason for the separate MEPs. The idea of the /class attribute/, when it is a Signal (a.k.a Signal container), basically helps manage namespace and organize collection of Signals. The MEP-107 for the attributes simply proposes to create a unique name for /class attribute/ when it is a Signal. If the example in the previous post (the wishbone) didn't illustrate how /class attributes/ could be used, either I am poorly explaining or we might have a misunderstanding what a /class attribute/ is. I guess, I would refer you back to the internal bus examples I and Oscar provided. Or maybe there is confusion because it is a basic enhancement proposal and you are thinking it might be something more. The use of classes to "contain" Signals doesn't mean a new type is created (this deeply depends on ones definition of *type*). As mentioned, the class is used as a VHDL record or SystemVerilog struct and nothing more. You can't build new types, then inherit to create yet another new type and define operations and behaviors on the new types. But as a Signal container it still has a lot of benefit and usage in my opinion. Hope that makes sense? Regards, Chris |
From: Jan D. <ja...@ja...> - 2012-05-19 09:02:27
|
On 05/18/2012 09:57 PM, Christopher Felton wrote: > The advantage of a class method over a function ... no advantage per se. > They both achieve the same thing in the similar manner. But it gives > the ability to use a method versus a function if someone wanted. I think there has to be a much better reason than this to warrant the effort to support this in conversion. There should be some feature that many people find useful and that cannot reasonably done in a different way. Conversion is complex enough as it is! > We have had this conversation a couple times in the past. The current > solution is to have a method that returns the generators from the > function, essentially wrapping a function in a /class method/. By > allowing the /class method/ to be directly convertible would remove the > need to wrap a function. I don't remember - can you provide simple examples? Is the issue only related to the very top level, as I MEP 108 seems to suggest, or also to intermediate hierarchical levels? > MEP-108 is simple, its only intention is to enable a /class method/ the > same as a function. My best example of why you might want to do this is > the following example, http://bit.ly/w95kOd. > > The /class method/ conversion and the /class attribute/ can be viewed as > separate. They can be used together but nothing says they have to be > and the reason for the separate MEPs. The idea of the /class > attribute/, when it is a Signal (a.k.a Signal container), basically > helps manage namespace and organize collection of Signals. The MEP-107 > for the attributes simply proposes to create a unique name for /class > attribute/ when it is a Signal. > > If the example in the previous post (the wishbone) didn't illustrate how > /class attributes/ could be used, either I am poorly explaining or we > might have a misunderstanding what a /class attribute/ is. I guess, I > would refer you back to the internal bus examples I and Oscar provided. /114/50122263/ I'm confused about terminology. When you talk about class attributes, are you sure you don't mean instance attributes instead? -- Jan Decaluwe - Resources bvba - http://www.jandecaluwe.com Python as a HDL: http://www.myhdl.org VHDL development, the modern way: http://www.sigasi.com World-class digital design: http://www.easics.com |
From: Christopher F. <chr...@gm...> - 2012-05-19 14:06:02
|
On 5/19/12 4:02 AM, Jan Decaluwe wrote: > On 05/18/2012 09:57 PM, Christopher Felton wrote: > >> The advantage of a class method over a function ... no advantage per se. >> They both achieve the same thing in the similar manner. But it gives >> the ability to use a method versus a function if someone wanted. > > I think there has to be a much better reason than this to warrant > the effort to support this in conversion. There should be some feature > that many people find useful and that cannot reasonably done in > a different way. Conversion is complex enough as it is! Oh oh, I setup this enhancement up poorly here, doh. In the context of describing hardware behavior using a class method (as proposed) or a python function, they will do the same thing. So what is the benefit to justify the changes in the conversion code? My opinion, the benefit is that it helps organize larger more complex designs (yes, complex can be subjective, what is complex?). To me this benefit is worth the inclusion. In the past couple years this topic has surfaced a couple times. Others do intuitively want to use a class method instead of a function in some cases. The changes can be diffed here (viewed), https://bitbucket.org/cfelton/myhdl_0.8dev_work/changeset/d61bf91023b7 . The changes are localized in two spots. The enhancement doesn't touch a lot of the conversion code. Hopefully, minimizing additional complexity in the conversion code. Is the concern that it will add unneeded complexity to the conversion code or be confusing for users? > >> We have had this conversation a couple times in the past. The current >> solution is to have a method that returns the generators from the >> function, essentially wrapping a function in a /class method/. By >> allowing the /class method/ to be directly convertible would remove the >> need to wrap a function. > > I don't remember - can you provide simple examples? Is the issue only > related to the very top level, as I MEP 108 seems to suggest, or also > to intermediate hierarchical levels? Best of my knowledge this is only an issue when the top-level is a class method. It appears class methods can be buried in the hierarchy but not the top-level. Which I think it self is a valid reason to add the feature, for completeness. As for an example ... simple example. I assume you mean an example that would demonstrate the benefits of using a class method? I have struggled with this. An example that can be easily digested is usually an example that is best suited for a non-class method implementation. But an example where a class method might be used is usually too complicated to be of benefit in conversation. The example I will try to provide will be missing all the "interesting" stuff. If I wanted to create a CRC module. I might want to use a class to abstract the different functions and HDL that might be used with the CRC module. class CRC(object): def __init__(self, GeneratorPoly=[], BusWidth=8): ... # bunch of stuff to check/massage # the generator polynomial def GetHammingDistance(self): ... return <hamming distance> def CrcHdl(self, <ports>): """Generate the hardware""" return <list of generators> In this example, this IP will have various data and methods used to create the generator polynomial, other house keeping, and then a method that describes the hardware behavior. Most of the functions are for the user of the component and used during elaboration. If the /CrcHdl/ is the top-level, currently you would need to do the following work around. def CrcHdl(self, clk, rst, data_in, data_out): return CrcFuncHdl(clk, rst, data_in, data_out) > >> MEP-108 is simple, its only intention is to enable a /class method/ the >> same as a function. My best example of why you might want to do this is >> the following example, http://bit.ly/w95kOd. >> >> The /class method/ conversion and the /class attribute/ can be viewed as >> separate. They can be used together but nothing says they have to be >> and the reason for the separate MEPs. The idea of the /class >> attribute/, when it is a Signal (a.k.a Signal container), basically >> helps manage namespace and organize collection of Signals. The MEP-107 >> for the attributes simply proposes to create a unique name for /class >> attribute/ when it is a Signal. >> >> If the example in the previous post (the wishbone) didn't illustrate how >> /class attributes/ could be used, either I am poorly explaining or we >> might have a misunderstanding what a /class attribute/ is. I guess, I >> would refer you back to the internal bus examples I and Oscar provided. > /114/50122263/ > > I'm confused about terminology. When you talk about class attributes, > are you sure you don't mean instance attributes instead? > That might be correct indeed. At this point I did not have an definition that would differentiate a class attribute vs. an instance attribute (reviewing [1] some more ... ). In the current proposal and threads I would have been using /class attribute/ to refer to class attributes and instance attributes. And the examples have been instances attributes, so I see why there might be confusion, I will update the MEP to clarify. I guess in future conversations I should simply use *attributes* and not specify class or instance unless applicable. [1] http://docs.python.org/tutorial/classes.html Regards, Chris Felton |
From: Jan D. <ja...@ja...> - 2012-05-21 07:16:20
|
On 05/19/2012 04:05 PM, Christopher Felton wrote: > On 5/19/12 4:02 AM, Jan Decaluwe wrote: >> On 05/18/2012 09:57 PM, Christopher Felton wrote: >> >>> The advantage of a class method over a function ... no advantage per se. >>> They both achieve the same thing in the similar manner. But it gives >>> the ability to use a method versus a function if someone wanted. >> >> I think there has to be a much better reason than this to warrant >> the effort to support this in conversion. There should be some feature >> that many people find useful and that cannot reasonably done in >> a different way. Conversion is complex enough as it is! > > Oh oh, I setup this enhancement up poorly here, doh. In the context of > describing hardware behavior using a class method (as proposed) or a > python function, they will do the same thing. So what is the benefit to > justify the changes in the conversion code? > > My opinion, the benefit is that it helps organize larger more complex > designs (yes, complex can be subjective, what is complex?). To me this > benefit is worth the inclusion. In the past couple years this topic has > surfaced a couple times. Others do intuitively want to use a class > method instead of a function in some cases. > > The changes can be diffed here (viewed), > https://bitbucket.org/cfelton/myhdl_0.8dev_work/changeset/d61bf91023b7 . > > The changes are localized in two spots. The enhancement doesn't touch a > lot of the conversion code. Hopefully, minimizing additional complexity > in the conversion code. > > Is the concern that it will add unneeded complexity to the conversion > code or be confusing for users? The latter is an often overlooked, but important concern. If something is supported it should be "all the way", otherwise it may just raise new expectations and increase confusion. However, it looks like this case is indeed simple and clean. -- Jan Decaluwe - Resources bvba - http://www.jandecaluwe.com Python as a HDL: http://www.myhdl.org VHDL development, the modern way: http://www.sigasi.com World-class digital design: http://www.easics.com |
From: Jan D. <ja...@ja...> - 2012-05-21 16:39:26
|
On 05/19/2012 04:05 PM, Christopher Felton wrote: > In the current proposal and threads I would have been using /class > attribute/ to refer to class attributes and instance attributes. And > the examples have been instances attributes, so I see why there might be > confusion, I will update the MEP to clarify. I guess in future > conversations I should simply use *attributes* and not specify class or > instance unless applicable. Yes, it is best to talk about attribute lookup in general, no need to specify what type of object the attribute belongs to. In practice, I suspect the principal use case will be instance attributes though. If you have several wishbone interfaces, you want signals with the same attribute name to refer to different signals :-) -- Jan Decaluwe - Resources bvba - http://www.jandecaluwe.com Python as a HDL: http://www.myhdl.org VHDL development, the modern way: http://www.sigasi.com World-class digital design: http://www.easics.com |
From: G. A. S. <g.a...@gm...> - 2012-06-01 04:46:11
|
Chris, In Example 1 of the MEP it says: class MyObj(object): def __init__(self): x = Signal(intbv(0)[8:]) y = Signal(intbv(0)[4:]) z = Signal(intbv(0)[9:]) But I hope you mean: class MyObj(object): def __init__(self): self.x = Signal(intbv(0)[8:]) self.y = Signal(intbv(0)[4:]) self.z = Signal(intbv(0)[9:]) (addition of "self." to the variables) Or I will be VERY confused! :-) Cheers! Andrew |
From: Christopher F. <chr...@gm...> - 2012-06-01 16:58:58
|
On 5/31/12 11:46 PM, G. Andrew Stone wrote: > Chris, > > In Example 1 of the MEP it says: > > class MyObj(object): > def __init__(self): > x = Signal(intbv(0)[8:]) > y = Signal(intbv(0)[4:]) > z = Signal(intbv(0)[9:]) > > > But I hope you mean: > > class MyObj(object): > def __init__(self): > self.x = Signal(intbv(0)[8:]) > self.y = Signal(intbv(0)[4:]) > self.z = Signal(intbv(0)[9:]) > > (addition of "self." to the variables) > > Or I will be VERY confused! :-) > > Cheers! > Andrew > > Yes, thanks for pointing out the error. I have updated the MEP. Regards, Chris |
From: G. A. S. <g.a...@gm...> - 2012-06-01 21:50:14
|
I've managed to read maybe 3/4 of the mail on this very long thread (and think I understand the MEP since I did find an error in the example). Somehow I got the idea that people aren't sure what value typical OO features would have in a hardware environment, so are considering leaving classes just a container for signals. Is that a correct assessment? Or is the problem that we don't know how to translate OO into verilog/vhdl? If its the former, I'd like to propose a couple of examples that would use OO features and then you guys can pick them apart and tell me how its all possible with myHdl today :-). Cheers! Andrew On Fri, Jun 1, 2012 at 12:58 PM, Christopher Felton <chr...@gm...>wrote: > On 5/31/12 11:46 PM, G. Andrew Stone wrote: > > Chris, > > > > In Example 1 of the MEP it says: > > > > class MyObj(object): > > def __init__(self): > > x = Signal(intbv(0)[8:]) > > y = Signal(intbv(0)[4:]) > > z = Signal(intbv(0)[9:]) > > > > > > But I hope you mean: > > > > class MyObj(object): > > def __init__(self): > > self.x = Signal(intbv(0)[8:]) > > self.y = Signal(intbv(0)[4:]) > > self.z = Signal(intbv(0)[9:]) > > > > (addition of "self." to the variables) > > > > Or I will be VERY confused! :-) > > > > Cheers! > > Andrew > > > > > > Yes, thanks for pointing out the error. I have updated the MEP. > > Regards, > Chris > > > > ------------------------------------------------------------------------------ > Live Security Virtual Conference > Exclusive live event will cover all the ways today's security and > threat landscape has changed and how IT managers can respond. Discussions > will include endpoint security, mobile security and the latest in malware > threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ > _______________________________________________ > myhdl-list mailing list > myh...@li... > https://lists.sourceforge.net/lists/listinfo/myhdl-list > |
From: Christopher F. <chr...@gm...> - 2012-06-02 12:01:54
|
On 6/1/12 4:50 PM, G. Andrew Stone wrote: > I've managed to read maybe 3/4 of the mail on this very long thread (and > think I understand the MEP since I did find an error in the example). I would call it a typo not an error since it wasn't a consistent throughout the MEP :) > Somehow I got the idea that people aren't sure what value typical OO > features would have in a hardware environment, so are considering > leaving classes just a container for signals. Is that a correct > assessment? No, I don't think that is the correct assessment. There hasn't been enough reasonable discussion on this topic to make a conclusion. Also, the waters are murky. For example, you mention "typical OO features". Two typical OO features are instantiation and inheritance. HDLs by virtue support instantiation, including MyHDL. That is a typical OO feature supported by HDLs. So I don't think it is a clear-cut OO support yeah or neah. I am not sure if I see how inheritance is useful. I think it is a stretch to say you can describe synthesizable hardware in the same manner as you write OO software (yet to be proven). There is a difference in representing a physical thing with OO inheritance (order and classification) and building a physical thing. I will try and explain my thoughts with an example. Take the common OO example, a vehicle. You might have a base class that represents an abstract model like a vehicle [1]. Then from there you might define a truck, sports car, and limousine. You create the later models by inheriting a set of classes derived from the base vehicle class. Now when you are creating the model for these different motor vehicles if you need to define the different engine powers you simply need to change a couple numbers. And that is sufficient for the model. But in real life, when building a motor you don't grab a base motor and change a couple attributes to get a more powerful motor. But what you do do, is reuse components to build the different motors. I think creating synthesiable descriptions are closer (not exact) to the real-world building of things than the abstract modeling. [1] http://publib.boulder.ibm.com/infocenter/tpfhelp/current/index.jsp?topic=%2Fcom.ibm.ztpf-ztpfdf.doc_put.cur%2Fgtpd1%2Foocon.html I am aware of some HDL tools that take an somewhat software OO model and try to generate hardware. But best of my knowledge these tools first compile the OO down to simple instructions to be executed (byte code) and then rebuild a hardware description from the byte code. I don't think a tool like this fits the domain of MyHDL. It might be a tool that uses MyHDL but I don't think it would be explicitly part of MyHDL. OO for hardware design, as I currently see it, is useful for modeling. And useful for organizing, parameterizing, and modularizing the synthesizble hardware descriptions. But the synthesizable (convertible subset that can be synthesized) is in a form similar to what exists. > Or is the problem that we don't know how to translate OO > into verilog/vhdl? If its the former, I'd like to propose a couple of > examples that would use OO features and then you guys can pick them > apart and tell me how its all possible with myHdl today :-). > My rational for this MEP is that it fits the current structure and it is useful on its own (it is more than just class/object signal container). More importantly OO support as some people may envision it will take quite a bit of hashing through (conversation). In addition, the yet to be define OO representation, more than likely, will require substantial conversion code modifications. Making near-term inclusion unlikely. The conversion code is quite complex. You need an strong understanding of the MyHDL design, the Python AST, and detailed knowledge of Verilog/VHDL. I think your examples in a separate thread would be worth some discussions and debate. Just be prepared. I think it is reasonable to expected some onus by the proposer. The idea person also needs to be the person that can provide details to some extent. I don't think it is reasonable for someone to only have the "idea" and expect others to come up with all the details. It makes the conversations difficult and more than likely won't go too far because the detail creators are yet to share the vision. Regards, Chris |
From: Christopher L. <loz...@fr...> - 2012-05-19 12:43:05
|
On 5/19/12 4:02 AM, Jan Decaluwe wrote: > There should be some feature > that many people find useful and that cannot reasonably done in > a different way. Conversion is complex enough as it is! I think if you only did classes, conversion would be so much easier. Right now you have to mess with the AST tree. If everything were a class, it would be easier to query them for signals public and private. You would only have to touch the AST tree for the code that is inside a python method, not for its arguments. You could have two representations of signals, the short list, and the expanded list. Two methods, one for short list, one for expanded list. Then just convert the expanded list. That would give you hierarchical signals much more easily. Verilog would just see a longer list of signals. And if everything were a class, they could all multiply inherit from a graphics drag and drop class, and you would get a great GUI. But those are all details. There are work arounds to each item. The real issue is at a much higher level. But the real feature would be in making MyHDL understandable to newbies, and in doing so growing the community. An even big feature is that it would give the MyHDL users a different mental model of MyHDL. I want to do some very very complex things, not very performance intensive things, but to even be able to think at this level of abstraction, to reduce the complexity of what I am doing, I need a simpler mental model of what I am building on top of. OOHDL hardware classes give me that simple conceptual model to build on top of. Ignoring licensing issues, If Jan C's microprocessor were a bunch of OOHDL hardware modules, it would be so easy to grab and use them. Right now I would have to edit them to fit my world view. They do not provide the right debugging functionality. Looking at waveforms is just not the right way to be debugging this stuff. For example I might want to keep the history of each signal, then print out a tree of hardware modules and their signal values to figure out what is going wrong. The current approach, A function returning a list, first calls the top level function, then returns me me a list of modules, not a tree of modules. Not what I need to debug this thing. The promise of MyHDL is in debugging, what you call verification, but it does not provide me with a tree of hardware modules that I need to iterate over in order to write my required debugging harnesses. Anyhow there is no one critical point. There are work arounds to each piece. It is just that the big picture would be so much simpler for newbies to get, and so much simpler to build complex systems on top of. While this is a signal mep, this point is not about a better signal, it is about a better overall system. Jan is asking show me the critical feature. I am responding we need a different elephant. But those are just my thoughts. My vision. I could be wrong. Thank you for helping me to clear these issues up in my mind. -- Regards Christopher Lozinski Check out my iPhone apps TextFaster and EmailFaster http://textfaster.com Expect a paradigm shift. http://MyHDLClass.com:8080 |
From: Tom D. <td...@di...> - 2012-05-19 13:17:20
|
On 05/19/2012 07:42 AM, Christopher Lozinski wrote: > On 5/19/12 4:02 AM, Jan Decaluwe wrote: >> There should be some feature >> that many people find useful and that cannot reasonably done in >> a different way. Conversion is complex enough as it is! > I think if you only did classes, conversion would be so much easier. I think two discussion got merged here and I believe I did it. I believe Jan's comment was concerning conversion of a class method as apposed to a function. The other discussion was about signals in class instances being converted. |
From: Tom D. <td...@di...> - 2012-05-20 14:43:22
|
On 05/19/2012 09:05 AM, Christopher Felton wrote: > On 5/19/12 4:02 AM, Jan Decaluwe wrote: >> On 05/18/2012 09:57 PM, Christopher Felton wrote: >> >>> The advantage of a class method over a function ... no advantage per se. >>> They both achieve the same thing in the similar manner. But it gives >>> the ability to use a method versus a function if someone wanted. >> I think there has to be a much better reason than this to warrant >> the effort to support this in conversion. There should be some feature >> that many people find useful and that cannot reasonably done in >> a different way. Conversion is complex enough as it is! > Oh oh, I setup this enhancement up poorly here, doh. In the context of > describing hardware behavior using a class method (as proposed) or a > python function, they will do the same thing. So what is the benefit to > justify the changes in the conversion code? > > My opinion, the benefit is that it helps organize larger more complex > designs (yes, complex can be subjective, what is complex?). To me this > benefit is worth the inclusion. In the past couple years this topic has > surfaced a couple times. Others do intuitively want to use a class > method instead of a function in some cases. > > The changes can be diffed here (viewed), > https://bitbucket.org/cfelton/myhdl_0.8dev_work/changeset/d61bf91023b7 . > > The changes are localized in two spots. The enhancement doesn't touch a > lot of the conversion code. Hopefully, minimizing additional complexity > in the conversion code. > > Is the concern that it will add unneeded complexity to the conversion > code or be confusing for users? > >>> We have had this conversation a couple times in the past. The current >>> solution is to have a method that returns the generators from the >>> function, essentially wrapping a function in a /class method/. By >>> allowing the /class method/ to be directly convertible would remove the >>> need to wrap a function. >> I don't remember - can you provide simple examples? Is the issue only >> related to the very top level, as I MEP 108 seems to suggest, or also >> to intermediate hierarchical levels? > Best of my knowledge this is only an issue when the top-level is a class > method. It appears class methods can be buried in the hierarchy but not > the top-level. Which I think it self is a valid reason to add the > feature, for completeness. It is only a top level issue. Works fine at lower levels. I guess I give some credit to the completeness argument when I think of it that way. This is really the same argument for the signal containers as it just makes a consistent use for top level vs lower levels. Sorry about combining two topics again, but I guess in this sense they are related. |
From: Jan D. <ja...@ja...> - 2012-05-21 07:20:20
|
On 05/20/2012 04:43 PM, Tom Dillon wrote: >> Best of my knowledge this is only an issue when the top-level is a class >> method. It appears class methods can be buried in the hierarchy but not >> the top-level. Which I think it self is a valid reason to add the >> feature, for completeness. > > It is only a top level issue. Works fine at lower levels. Logical perhaps, but I didn't realize this because never tried it myself. This stuff is more powerful than I thought :-) > I guess I give some credit to the completeness argument when I think of > it that way. This is really the same argument for the signal containers > as it just makes a consistent use for top level vs lower levels. Let's go for it then, changeset welcome. -- Jan Decaluwe - Resources bvba - http://www.jandecaluwe.com Python as a HDL: http://www.myhdl.org VHDL development, the modern way: http://www.sigasi.com World-class digital design: http://www.easics.com |
From: Jan D. <ja...@ja...> - 2012-05-21 08:58:34
|
On 05/19/2012 02:42 PM, Christopher Lozinski wrote: > On 5/19/12 4:02 AM, Jan Decaluwe wrote: >> There should be some feature >> that many people find useful and that cannot reasonably done in >> a different way. Conversion is complex enough as it is! > I think if you only did classes, conversion would be so much easier. I don't see why. > Right now you have to mess with the AST tree. That's the Migen rationale, isn't it? Well, everyone can see where that leads to: ridiculous restrictions and awkward syntax. In short, HDL design for amateurs. No thanks, I settle for the AST. I need python's expressiveness and syntax to describe hardware behavior. > If everything were a > class, it would be easier to query them for signals public and private. Signal handling is currently a minor task in conversion. > You would only have to touch the AST tree for the code that is inside a > python method, not for its arguments. That's how it works currently, except at the top level. Elaboration takes care of the other arguments. > You could have two representations of signals, the short list, and the > expanded list. Two methods, one for short list, one for expanded list. > Then just convert the expanded list. That would give you hierarchical > signals much more easily. Verilog would just see a longer list of signals. As I said, a minor task. > And if everything were a class, they could all multiply inherit from a > graphics drag and drop class, and you would get a great GUI. That is called schematics entry, an intelligent form of it at best. Not for me, thanks. > But those are all details. There are work arounds to each item. The > real issue is at a much higher level. > > But the real feature would be in making MyHDL understandable to newbies, > and in doing so growing the community. > > An even big feature is that it would give the MyHDL users a different > mental model of MyHDL. I want to do some very very complex things, not > very performance intensive things, but to even be able to think at this > level of abstraction, to reduce the complexity of what I am doing, I > need a simpler mental model of what I am building on top of. OOHDL > hardware classes give me that simple conceptual model to build on top of. > > Ignoring licensing issues, If Jan C's microprocessor were a bunch of > OOHDL hardware modules, it would be so easy to grab and use them. Right > now I would have to edit them to fit my world view. They do not > provide the right debugging functionality. I have zero interest to compare the benefits of some virtual super system with MyHDL, a proven system that works today. I you think you are on to something, it is your job to show it. With code and a manual I mean, not with vague visions and world views. > Looking at waveforms is just not the right way to be debugging this > stuff. Agreed. > For example I might want to keep the history of each signal, > then print out a tree of hardware modules and their signal values to > figure out what is going wrong. But that is exactly what a waveform viewer (and the associated input file) does! > The current approach, A function > returning a list, first calls the top level function, then returns me me > a list of modules, not a tree of modules. Not what I need to debug this > thing. Wrong, it is a tree, represented as a nested list. http://www.myhdl.org/doc/current/manual/intro.html#parameters-and-hierarchy > The promise of MyHDL is in debugging, what you call verification, but it > does not provide me with a tree of hardware modules that I need to > iterate over in order to write my required debugging harnesses. > > Anyhow there is no one critical point. There are work arounds to each > piece. It is just that the big picture would be so much simpler for > newbies to get, and so much simpler to build complex systems on top of. > > While this is a signal mep, this point is not about a better signal, it > is about a better overall system. Jan is asking show me the critical > feature. I am responding we need a different elephant. It is clear that you still don't understand what beast we currently have, so I don't think you are in pole position to specify a different one. The problem is that I see zero progress, despite all the energy invested. I think the issue is that your learning methodology is broken. You keep on posting, but it seems you don't listen to the good advice you get from the experts here: start with learning the basics of digital design, including synthesis, use the manual as a close reference, use the cookbook examples to go through the process yourself in small steps. Actually your own suggestion to start simple with Verilog may be a good one, but now it seems you're even ignoring your own good advice. I hope that you understand how irritating it is to hear about visions and world views all the time, and even get programming lessons, from someone in that position. > But those are just my thoughts. My vision. I could be wrong. Thank > you for helping me to clear these issues up in my mind. Visions are for those who know where they are. The others should not lose time with them, and work hard to get there. -- Jan Decaluwe - Resources bvba - http://www.jandecaluwe.com Python as a HDL: http://www.myhdl.org VHDL development, the modern way: http://www.sigasi.com World-class digital design: http://www.easics.com |
From: Christopher F. <chr...@gm...> - 2012-05-21 11:06:19
|
<snip> >> The promise of MyHDL is in debugging, what you call verification, but it >> does not provide me with a tree of hardware modules that I need to >> iterate over in order to write my required debugging harnesses. >> >> Anyhow there is no one critical point. There are work arounds to each >> piece. It is just that the big picture would be so much simpler for >> newbies to get, and so much simpler to build complex systems on top of. >> >> While this is a signal mep, this point is not about a better signal, it >> is about a better overall system. Jan is asking show me the critical >> feature. I am responding we need a different elephant. > > It is clear that you still don't understand what beast we currently have, > so I don't think you are in pole position to specify a different one. > > The problem is that I see zero progress, despite all the energy invested. > I think the issue is that your learning methodology is broken. You keep > on posting, but it seems you don't listen to the good advice you get from > the experts here: start with learning the basics of digital design, > including synthesis, use the manual as a close reference, use the cookbook > examples to go through the process yourself in small steps. Actually your > own suggestion to start simple with Verilog may be a good one, but now it > seems you're even ignoring your own good advice. > > I hope that you understand how irritating it is to hear about visions > and world views all the time, and even get programming lessons, from > someone in that position. > I would like to add some emphasis. I hope he does understand how *irritating* it is! Not the fact of asking a questions. This community has been very receptive to questions and helping newcomers. But the barge of this vision and the inability, in any shape or form, to really understand what his own vision is. As stated, the most frustrating appears to be his unwillingness to put the effort forward to grow in this area. I also hope he realizes how much effort is being spent on his behalf. Patient and eloquent explanations has been provided which has not been digested. Regards, Chris |