Re: Examples of using classes?

Jeremy Herbert <[email protected]>
Newsgroups gmane.comp.python.myhdl
Message-ID <CAHYNNe1OX78uiN9OtBAKJF1DBBAObbAAmexi9LY=kashaHz=kQ@mail.gmail.com>
Hi Chris,

I was thinking of using inheritance in defining interfaces using classes
like so:

class FIFO(object):
...

class AXIFIFO(FIFO):
...

class WishboneFIFO(FIFO):
...

Or even mixins:

class FIFO(object):
...

class AXI4SSlaveMixin(object):
...

class AXI4SMasterMixin(object):
...

class AXIFIFO(FIFO, AXI4SSlaveMixin, AXI4SMasterMixin):
...

Does this make sense? I'd basically like to be able to drop the
AXI4SSlaveMixin and replace it with WishboneSlaveMixin and have it "just
work".

Thanks,
Jeremy

On Tue, 28 Jul 2015 at 23:22 Christopher Felton <[email protected]>
wrote:

> On 7/28/2015 4:52 AM, Jeremy Herbert wrote:
> > Hi everyone,
> >
> > I'm currently playing with myhdl, and I was wondering if anyone has
> > examples on using python classes to describe logic? more specifically, I
> am
> > looking for examples of class inheritance being used.
> >
> > I have looked on the myhdl website and here:
> > https://github.com/jandecaluwe/myhdl-examples
> >
> > but everything seems to be defined by functions in functions rather than
> in
> > a class.
>
> This question pops up every once in awhile from new
> users.  I think most users don't use classes as the
> modules that contain the logic implementations.
> Classes are used for interfaces and objects that might
> have logic implementations (implemented in methods).
>
> You can use classes, you just need to provide the
> myhdl generators to the simulator and/or conversion
> tools.
>
> Can you elaborate how you want to use classes?  Its
> not clear to me how inheritance can help logic
> implementations.
>
>
> Regards,
> Chris
>
>
>
>
>
> ------------------------------------------------------------------------------
> _______________________________________________
> myhdl-list mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/myhdl-list
>

------------------------------------------------------------------------------

_______________________________________________
myhdl-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/myhdl-list
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.