magne
Guest
Fri Feb 05, 2010 3:44 pm
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
KJ
Guest
Fri Feb 05, 2010 4:31 pm
On Feb 5, 7:44 am, magne <magnem...@yahoo.no> wrote:
Quote:
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
Tricky
Guest
Fri Feb 05, 2010 5:58 pm
On 5 Feb, 13:31, KJ <kkjenni...@sbcglobal.net> wrote:
Quote:
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
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.
magne
Guest
Sun Feb 07, 2010 7:05 pm
On 5 Feb, 14:31, KJ <kkjenni...@sbcglobal.net> wrote:
Quote:
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.
Mike Treseler
Guest
Sun Feb 07, 2010 10:51 pm
magne wrote:
Quote:
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/ConstrainedRandom_SynthWorks_2009.pdf
-- Mike Treseler
Alan Fitch
Guest
Mon Feb 08, 2010 11:39 am
magne wrote:
Quote:
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.fitch_at_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.
magne
Guest
Mon Feb 08, 2010 12:18 pm
On Feb 7, 9:51 pm, Mike Treseler <mtrese...@gmail.com> wrote:
Quote:
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/ConstrainedRandom_SynthWorks_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
magne
Guest
Mon Feb 08, 2010 3:13 pm
On Feb 8, 10:39 am, Alan Fitch <alan.fi...@spamtrap.com> wrote:
Quote:
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.
Alan Fitch
Guest
Mon Feb 08, 2010 3:42 pm
Yes, you probably just need to add vcom +acc=v ...
regards
Alan
(or of course vcom -O0 -novopt, vsim -novopt at the expense of disabling
all optimizations)
--
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.fitch_at_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.