Java is a little more readable with it's interface/implements
keywords, but one thing SV does not already lack is too many keywords.
So Dave's keyword reuse seems like a good idea.
In Java, interfaces can extend interfaces, and classes can implement
interfaces; but classes can't extend interfaces, and interfaces can't
extend classes. I propose to use the pure keyword slightly
differently. Declare the class to be 'pure virtual', meaning the
exact same thing as a Java interface. You can then skip the pure
keyword on all the tasks, as that is already implied and enforced by
the compiler. Here's a modified version of Dave's example:
// the interface for puts
pure virtual class tlm_put_if;
virtual task put(int arg);
endclass
// the interface for gets
pure virtual class tlm_get_if;
virtual task get(int arg);
endclass
pure virtual class tlm_slave_if extends
pure virtual tlm_put_if, pure virtual tlm_get_if;
endclass
...
class tlm_slave_imp extends pure virtual tlm_slave_if, C; // extends
non-virtual C
task put(int Barg1);
C::put(Barg1*123);
endtask
task get(int Barg1);
C::get(Barg1*123);
endtask
endclass
I'd want to duplicate Java's safety checking. So, pure virtual
classes could extend other pure virtual classes, but not other
classes. And, regular classes extending pure virtual classes must use
"extends pure virtual" or they'd get a compile error.
-Ryan
On Mon, Mar 22, 2010 at 6:12 PM, Brad Pierce <Brad.Pierce@synopsys.com> wrote:
> Dave's paper is available via the following blog entry
>
> http://bradpierce.wordpress.com/2010/03/01/multiple-inheritance-and-systemverilog/
>
> -- Brad
>
> -----Original Message-----
> From: Ryan S Warner [mailto:ryan.s.warner@seagate.com]
> Sent: Monday, March 22, 2010 1:56 PM
> To: SV_EC List
> Cc: Brad Pierce; Rich, Dave
> Subject: Re: [sv-ec] Multiple inheritance
>
> I strongly support Mantis 0001356: Multiple inheritance, as MI really
> is the only _good_ way to merge multiple methodologies in a mixed
> methodology environment. That said, I strongly prefer Java interfaces
> over C++ MI. The restrictions of Java's interfaces have never seemed
> all that limiting to me, and generally result in more well thought out
> code. C++ MI on the other hand, seems to produce poorly thought out
> code that makes me work extra hours to debug.
>
> You could utilize Java style interfaces, but use a more C++ style
> syntax. You could just declare a class as pure virtual. However on
> the extension side, I really like the "implements" keyword. It makes
> the intent blatantly obvious to the reader. Just look at how much
> more information "implements" conveys in this example:
>
> // Using a more C++ style syntax
> class P extends A, B, C;
> endclass
>
> // Using a more Java style syntax
> class P extends A implements B, C;
> endclass
>
> Using the more C++-like style I need to look at the definitions of
> A,B,C to know anything about these relationships. Using the Java
> style, I don't even need to see the class definitions to know that B
> and C are interface (sorry, pure virtual class) definitions.
>
> Regards,
> Ryan
>
> On Mon, Mar 1, 2010 at 7:35 PM, Rich, Dave <Dave_Rich@mentor.com> wrote:
>>
>> Attached to http://www.eda.org/svdb/view.php?id=1356
>>
>> > -----Original Message-----
>> > From: owner-sv-ec@eda.org [mailto:owner-sv-ec@eda.org] On Behalf Of Brad
>> > Pierce
>> > Sent: Sunday, February 28, 2010 1:02 PM
>> > To: SV_EC List
>> > Subject: RE: [sv-ec] Multiple inheritance
>> >
>> > Dave,
>> >
>> > > I'll post the paper as soon as the conference is over.
>> >
>> > I'm eager to read it.
>> > http://www.dvcon.org/events/eventdetails.aspx?id=108-2 When it's
>> > available, please send us a link.
>> >
>> > Thanks!
>> >
>> > -- Brad
>> >
>> > -----Original Message-----
>> > From: owner-sv-ec@eda.org [mailto:owner-sv-ec@eda.org] On Behalf Of Rich,
>> > Dave
>> > Sent: Thursday, February 25, 2010 8:00 AM
>> > Cc: SV_EC List
>> > Subject: RE: [sv-ec] Multiple inheritance
>> >
>> > This "tweet" was in response to a paper I presented at DVCon on multiple
>> > inheritance. My proposal was to have the functionality of Java interfaces
>> > using C++ syntax and limited semantics of virtual inheritance. (The
>> > interface keyword is already in use for a different purpose). I'll post
>> > the paper as soon as the conference is over.
>> >
>> > Dave
>> >
>> >
>> > > -----Original Message-----
>> > > From: owner-sv-ec@eda.org [mailto:owner-sv-ec@eda.org] On Behalf Of
>> > David
>> > > Jones
>> > > Sent: Thursday, February 25, 2010 5:20 AM
>> > > To: Brad Pierce
>> > > Cc: SV_EC List
>> > > Subject: Re: [sv-ec] Multiple inheritance
>> > >
>> > > Is the request for true multiple inheritance (C++ style) or for
>> > > something similar to Java interfaces?
>> > >
>> > > The functionality of Java interfaces is relatively easy to define. But
>> > > if we try to define the equivalent of C++ multiple inheritance
>> > > (including multiple virtual inheritance) then the definition and
>> > > implementation get a lot more complex.
>> > >
>> > > On Thu, Feb 25, 2010 at 1:59 AM, Brad Pierce <Brad.Pierce@synopsys.com>
>> > > wrote:
>> > > > According to Scott Roland, writing from DVCon, "Multiple inheritance
>> > is
>> > > the #1 SystemVerilog feature request for people with an OO background."
>> > > >
>> > > > http://twitter.com/scott_roland/statuses/9584083182
>> > > >
>> > > > -- Brad
>> > > >
>> > > >
>> > > >
>> > > > --
>> > > > This message has been scanned for viruses and
>> > > > dangerous content by MailScanner, and is
>> > > > believed to be clean.
>> > > >
>> > > >
>> > > >
>> > >
>> > > --
>> > > This message has been scanned for viruses and
>> > > dangerous content by MailScanner, and is
>> > > believed to be clean.
>> > >
>> >
>> >
>> > --
>> > This message has been scanned for viruses and
>> > dangerous content by MailScanner, and is
>> > believed to be clean.
>> >
>> >
>> >
>> > --
>> > This message has been scanned for viruses and
>> > dangerous content by MailScanner, and is
>> > believed to be clean.
>> >
>>
>>
>> --
>> This message has been scanned for viruses and
>> dangerous content by MailScanner, and is
>> believed to be clean.
>>
>>
>
-- This message has been scanned for viruses and dangerous content by MailScanner, and is believed to be clean.Received on Tue Mar 23 08:27:37 2010
This archive was generated by hypermail 2.1.8 : Tue Mar 23 2010 - 08:27:41 PDT