On Feb 8, 10:39*am, Alan Fitch <alan.fi...@spamtrap.com> wrote:
> magne wrote:
> > On 5 Feb, 14:31, KJ <kkjenni...@sbcglobal.net> wrote:
> >> On Feb 5, 7:44 am, magne <magnem...@yahoo.no> 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: alan.fi...@doulos.com * * * *
> 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.