Go Back   Velocity Reviews > Newsgroups > VHDL
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply

VHDL - Assignment (variable or signal)?

 
Thread Tools Search this Thread
Old 11-21-2007, 10:02 PM   #1
Default Assignment (variable or signal)?


Assuming you have a procedure that has a few output values. You need
one such output to be either a signal or a variable. Overloading does
not seem to work in this sense.

procedure p( signal s : out std_logic ) is
begin
s <= '1';
end procedure p;

procedure p( variable v : out std_logic ) is
begin
v := '1';
end procedure p;

I do NOT want to use a function in this case. Is there any way to do
this in VHDL? That is know if a procedure argument is a signal or a
variable?

-- Amal


Amal
  Reply With Quote
Old 11-21-2007, 11:00 PM   #2
Paul Uiterlinden
 
Posts: n/a
Default Re: Assignment (variable or signal)?
Amal wrote:

> Assuming you have a procedure that has a few output values. You need
> one such output to be either a signal or a variable. Overloading does
> not seem to work in this sense.
>
> procedure p( signal s : out std_logic ) is
> begin
> s <= '1';
> end procedure p;
>
> procedure p( variable v : out std_logic ) is
> begin
> v := '1';
> end procedure p;
>
> I do NOT want to use a function in this case. Is there any way to do
> this in VHDL? That is know if a procedure argument is a signal or a
> variable?


As far as I know: you can't. The solution is to have two differently named
procedures. For example p and p_sig.

--
Paul Uiterlinden
www.aimvalley.nl
e-mail addres: remove the not.


Paul Uiterlinden
  Reply With Quote
Old 11-22-2007, 10:58 PM   #3
Mike Treseler
 
Posts: n/a
Default Re: Assignment (variable or signal)?
> Amal wrote:
>> I do NOT want to use a function in this case. Is there any way to do
>> this in VHDL? That is know if a procedure argument is a signal or a
>> variable?


Paul Uiterlinden wrote:
> As far as I know: you can't. The solution is to have two differently named
> procedures. For example p and p_sig.


True.
One alternative is to use the default constant
class to pass a *value* sample of a signal or variable
to a procedure or impure function.

See the procedure "rising" here:
http://home.comcast.net/~mike_treseler/rise_count.vhd

Another is to declare procedures in process scope
with direct access to the variables:

procedure inc_tic_count is
begin
TxBitSampleCount_v := TxBitSampleCount_v+1;
end procedure inc_tic_count;


-- Mike Treseler


Mike Treseler
  Reply With Quote
Old 11-23-2007, 01:51 PM   #4
Paul Uiterlinden
 
Posts: n/a
Default Re: Assignment (variable or signal)?
Mike Treseler wrote:

>> Amal wrote:
>>> I do NOT want to use a function in this case. Is there any way to do
>>> this in VHDL? That is know if a procedure argument is a signal or a
>>> variable?

>
> Paul Uiterlinden wrote:
>> As far as I know: you can't. The solution is to have two differently
>> named procedures. For example p and p_sig.

>
> True.
> One alternative is to use the default constant
> class to pass a *value* sample of a signal or variable
> to a procedure or impure function.


For input parameters you are right. But for the example that the original
poster gave, this is not really an alternative. He specifically asked about
procedures that have output parameters.

--
Paul Uiterlinden
www.aimvalley.nl
e-mail addres: remove the not.


Paul Uiterlinden
  Reply With Quote
Old 11-23-2007, 06:49 PM   #5
Mike Treseler
 
Posts: n/a
Default Re: Assignment (variable or signal)?
Paul Uiterlinden wrote:

> For input parameters you are right. But for the example that the original
> poster gave, this is not really an alternative. He specifically asked about
> procedures that have output parameters.


Sorry.
I should have answered Amal directly and said,
"What I would do is use a function."

-- Mike Treseler




Mike Treseler
  Reply With Quote
Old 11-26-2007, 05:23 PM   #6
Andy
 
Posts: n/a
Default Re: Assignment (variable or signal)?
On Nov 21, 4:02 pm, Amal <akhailt...@gmail.com> wrote:
> Assuming you have a procedure that has a few output values. You need
> one such output to be either a signal or a variable. Overloading does
> not seem to work in this sense.
>
> procedure p( signal s : out std_logic ) is
> begin
> s <= '1';
> end procedure p;
>
> procedure p( variable v : out std_logic ) is
> begin
> v := '1';
> end procedure p;
>
> I do NOT want to use a function in this case. Is there any way to do
> this in VHDL? That is know if a procedure argument is a signal or a
> variable?
>
> -- Amal


That's another thing I don't understand why they did it, but it is
definitely in the LRM. But if you can assign a signal with a variable
expression, why not with a subprogram's variable out-mode port? In
fact when you overload operators with function declarations, there is
no need to define the input parameters as signal to accept a signal.
LRM (2000) Section 2.1.1 clearly states that a subprogram [function or
procedure] formal parameter of class variable must be associated with
an actual of class variable. Hmmm... Sounds like that restriction is
not quite extended to operators...

Maybe Jim Lewis will chime in here???

Andy



Andy
  Reply With Quote
Old 11-26-2007, 08:03 PM   #7
Mike Treseler
 
Posts: n/a
Default Re: Assignment (variable or signal)?
Andy wrote:

> That's another thing I don't understand why they did it, but it is
> definitely in the LRM. But if you can assign a signal with a variable
> expression, why not with a subprogram's variable out-mode port?


I don't know why, but it is plausible
that it covers some edge case.
The default constant class
enforces pass by value, which is safe.

Variable class is a pass by reference and the
variable could be an access type.
Note also that this class is
mysteriously and completely disallowed for functions.
Hmmm.

-- Mike Treseler


Mike Treseler
  Reply With Quote
Old 11-26-2007, 08:51 PM   #8
Jonathan Bromley
 
Posts: n/a
Default Re: Assignment (variable or signal)?
On Mon, 26 Nov 2007 12:03:08 -0800,
Mike Treseler <> wrote:

>The default constant class
>enforces pass by value, which is safe.


Depressingly, it *doesn't* and it's *not* safe.
The LRM explicitly licenses tools to pass-by-ref
in the interests of efficiency. Given that we have
perfectly good pass-by-ref mechanisms anyway, it's
completely idiotic - and badly broken.

The LRM regards any program that relies on the
difference as "erroneous" (translation: you're
stuffed, and we're not going to warn you about it).
--
Jonathan Bromley, Consultant

DOULOS - Developing Design Know-how
VHDL * Verilog * SystemC * e * Perl * Tcl/Tk * Project Services

Doulos Ltd., 22 Market Place, Ringwood, BH24 1AW, UK

http://www.MYCOMPANY.com

The contents of this message may contain personal views which
are not the views of Doulos Ltd., unless specifically stated.


Jonathan Bromley
  Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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

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

Similar Threads
Thread Thread Starter Forum Replies Last Post
I am having trouble editing a signal in a sub program. Haai Hardware 0 08-28-2007 02:58 PM
Need help on Modelsim VHDL syntax? ASAP:) kaji General Help Related Topics 0 03-14-2007 10:43 PM
Need help on a Modelsim VHDL Syntax? ASAP:) kaji Software 0 03-14-2007 10:43 PM
Need Help on a Modelsim VHDL Syntax....ASAP:) kaji Hardware 0 03-14-2007 10:41 PM
Variable Scope in asp.Net jansi_rk Software 1 09-18-2006 06:05 PM




SEO by vBSEO 3.3.2 ©2009, Crawlability, Inc.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46