Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > VHDL > VHDL 2008: protected type

Reply
Thread Tools

VHDL 2008: protected type

 
 
magne
Guest
Posts: n/a
 
      02-05-2010

Hi,

I was trying to write code for a protected type when I ran into a
issue. When testing in simulation it seems like functions of protected
types cannot update private variables of that type, but procedures
can.

Is this correct or are there some other logical explanation?


Magne
 
Reply With Quote
 
 
 
 
KJ
Guest
Posts: n/a
 
      02-05-2010
On Feb 5, 7:44*am, magne <(E-Mail Removed)> wrote:
> Hi,
>
> I was trying to write code for a protected type when I ran into a
> issue. When testing in simulation it seems like functions of protected
> types cannot update private variables of that type, but procedures
> can.
>
> Is this correct or are there some other logical explanation?
>
> Magne


That's correct, functions cannot update the private variables...but
impure functions can. Change your function declarations from

function xyz(...) return ...

to
impure function xyz(...) return ...

Kevin Jennings
 
Reply With Quote
 
 
 
 
Tricky
Guest
Posts: n/a
 
      02-05-2010
On 5 Feb, 13:31, KJ <(E-Mail Removed)> wrote:
> On Feb 5, 7:44*am, magne <(E-Mail Removed)> wrote:
>
> > Hi,

>
> > I was trying to write code for a protected type when I ran into a
> > issue. When testing in simulation it seems like functions of protected
> > types cannot update private variables of that type, but procedures
> > can.

>
> > Is this correct or are there some other logical explanation?

>
> > Magne

>
> That's correct, functions cannot update the private variables...but
> impure functions can. *Change your function declarations from
>
> function xyz(...) return ...
>
> to
> impure function xyz(...) return ...
>
> Kevin Jennings


This isnt just a VHDL 2008 issue or an issue with protected types. Its
functions in general updating anything not declared inside or passed
into the function. you'll get a warning if you try to write to OUTPUT
(the cmd prompt) inside a pure function.
 
Reply With Quote
 
magne
Guest
Posts: n/a
 
      02-07-2010
On 5 Feb, 14:31, KJ <(E-Mail Removed)> wrote:
> On Feb 5, 7:44*am, magne <(E-Mail Removed)> wrote:
>
> > Hi,

>
> > I was trying to write code for a protected type when I ran into a
> > issue. When testing in simulation it seems like functions of protected
> > types cannot update private variables of that type, but procedures
> > can.

>
> > Is this correct or are there some other logical explanation?

>
> > Magne

>
> That's correct, functions cannot update the private variables...but
> impure functions can. *Change your function declarations from
>
> function xyz(...) return ...
>
> to
> impure function xyz(...) return ...
>
> Kevin Jennings



Hi Kevin,

thanks for your answer but no, impure functions can't update the
private variables either, at least not in QuestaSim 6.5c.
I don't get any warnings or anything but the variables stays the same
when using pure or impure functions. Procedures can work the magic,
however.

 
Reply With Quote
 
Mike Treseler
Guest
Posts: n/a
 
      02-07-2010
magne wrote:

> thanks for your answer but no, impure functions can't update the
> private variables either, at least not in QuestaSim 6.5c.
> I don't get any warnings or anything but the variables stays the same
> when using pure or impure functions. Procedures can work the magic,
> however.



An impure function ought to have the same scope
as a procedure declared in the same place.

See also:
http://www.synthworks.com/downloads/...Works_2009.pdf


-- Mike Treseler
 
Reply With Quote
 
magne
Guest
Posts: n/a
 
      02-08-2010
On Feb 7, 9:51*pm, Mike Treseler <(E-Mail Removed)> wrote:
> magne wrote:
> > thanks for your answer but no, impure functions can't update the
> > private variables either, at least not in QuestaSim 6.5c.
> > I don't get any warnings or anything but the variables stays the same
> > when using pure or impure functions. Procedures can work the magic,
> > however.

>
> An impure function ought to have the same scope
> as a procedure declared in the same place.
>
> See also:http://www.synthworks.com/downloads/...ynthWorks_2009...
>
> * -- Mike Treseler


Hi Mike,

Yes, that is the paper where I got the idea to put some stuff in a
protected type.
I've had a quick look at the code from synthworks, and I can't find an
impure function where the private variables are updated directly. Some
impure functions do call procedures that updates private variables,
though, so maybe that is the way to do it.

Magne
 
Reply With Quote
 
magne
Guest
Posts: n/a
 
      02-08-2010
On Feb 8, 10:39*am, Alan Fitch <(E-Mail Removed)> wrote:
> magne wrote:
> > On 5 Feb, 14:31, KJ <(E-Mail Removed)> wrote:
> >> On Feb 5, 7:44 am, magne <(E-Mail Removed)> wrote:

>
> >>> Hi,
> >>> I was trying to write code for a protected type when I ran into a
> >>> issue. When testing in simulation it seems like functions of protected
> >>> types cannot update private variables of that type, but procedures
> >>> can.
> >>> Is this correct or are there some other logical explanation?
> >>> Magne
> >> That's correct, functions cannot update the private variables...but
> >> impure functions can. *Change your function declarations from

>
> >> function xyz(...) return ...

>
> >> to
> >> impure function xyz(...) return ...

>
> >> Kevin Jennings

>
> > Hi Kevin,

>
> > thanks for your answer but no, impure functions can't update the
> > private variables either, at least not in QuestaSim 6.5c.
> > I don't get any warnings or anything but the variables stays the same
> > when using pure or impure functions. Procedures can work the magic,
> > however.

>
> I've tried an example in 6.5d and it works as expected (i.e. impure
> functions can update a variable declared within the body of the
> protected type).
>
> Is it possible to post a simple example which doesn't work for you, and
> I can try it in 6.5d in case there's a difference?
>
> regards
> Alan
>
> --
> Alan Fitch
> Senior Consultant
>
> Doulos Developing Design Know-how
> VHDL * Verilog * SystemVerilog * SystemC * PSL * Perl * Tcl/Tk * Project
> Services
>
> Doulos Ltd. Church Hatch, 22 Marketing Place, Ringwood, Hampshire, BH24
> 1AW, UK
> Tel: *+ 44 (0)1425 471223 * * * * * * * Email: (E-Mail Removed) * * * *
> Fax: *+44 (0)1425 471573 * * * * * * * *http://www.doulos.com
>
> ------------------------------------------------------------------------
>
> This message may contain personal views which are not the views of
> Doulos, unless specifically stated.


I tried to make a simple example to prove my claims, but it worked as
expected for me as well. I found out however, by experimenting with my
original code, that under some circumstances and simulation
optimizations the value in the wave window doesn't update even if the
value of the variable changes. I assumed that since I could add the
variable to the wave window it was visible, but now I know better.

So I was wrong, impure functions of protected types CAN update private
variables.


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
VHDL Type Mismatch error indexed name returns a value whose type does not match programmingzeal VHDL 0 05-06-2012 06:38 AM
Why cant protected type methods have a parameter thats an access type? Tricky VHDL 1 02-10-2012 08:38 PM
VHDL-2002 vs VHDL-93 vs VHDL-87? afd VHDL 1 03-23-2007 09:33 AM
Accessing a protected member of a member of type BaseClass???? Steven T. Hatton C++ 2 08-16-2004 03:11 PM
Difference between "Protected WithEvents myClassName" And "Protected myClassName" ? Andreas Klemt ASP .Net 2 07-05-2003 12:51 AM



Advertisments