Re: Question on the domain of a variable

From: Geoffrey.Coram <geoffrey.coram@analog.com>
Date: Thu May 06 2010 - 07:27:36 PDT

I remember this was brought up when we were talking about variable declarations
with initializations. It used to be that you could only do
   real x;
at module scope, and any assignments had to be done in a digital or analog block,
so then you'd know the domain.

I agree with David's reading of 7.2.2 -- since it's not in the analog block,
everything else is said to be in the digital context.

I also wonder why it matters, if there's only that one assignment --
effectively, x is a constant for your module. It's not changing, so you
don't care whether the changes are computed on the `timescale or otherwise.

-Geoffrey

David Miller wrote:
> Hi Luc,
>
> This is not clearly defined. My take on this is since the statement
> appears outside of an analog block the context of the assignment is in
> the digital domain, hence this is a digital variable (refer Section
> 7.2.2 Contexts - LRM 2.3.1)
> But some may also argue that since default domain for variables is
> analog (is that even explicitly stated?) it is just as valid to treat
> 'x' in your case as analog.
>
> To clear up this ambiguity we have added the "analog initial" block
> (similar to the digital "initial") to allow users to initialise
> variables etc. in the analog context prior to simulation (so before
> initial_step blocks fire).
>
> Hope this helps
>
> Cheers...
> Dave
>
> On 05/06/2010 07:53 AM, Luc Rebillard wrote:
>> Hello,
>>
>> According to the LRM, the domain of a variable (integer, real) is
>> determinated by the context in which this variable
>> is assigned. This recalled, I wonder what is the domain of the variable
>> 'x' is the following module
>>
>> module test ;
>>
>> real x = 1.0 ;
>>
>> analog @(initial_step) $display("x=%f",x) ;
>>
>> initial $display("x=%f",x) ;
>>
>> endmodule
>>
>> Thanks,
>>
>> Regards,
>>
>> Luc
>>
>

-- 
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.
Received on Thu May 6 07:27:51 2010

This archive was generated by hypermail 2.1.8 : Thu May 06 2010 - 07:27:52 PDT