Re: [sv-bc] Query related with signedness of variable.

From: Dhiraj Kumar Prasad <dhiraj@cal.interrasystems.com>
Date: Tue Mar 22 2011 - 21:12:50 PDT

Hello Greg,

Equivalent I mean to say is this that a packed structure can be thought
of bit stream and in
that sense if we resolve the below struct definition

typedef struct packed signed {
            bit [1:0] bit1;
}[1:0]S1;

as two stage typedef like

typedef bit signed [1:0] b1;
typedef b1[1:0] b2;

than the var1[0] in the example will be signed but if We conclude it to be like

typedef bit signed [1:0][1:0] b3;

than var1[0] will be unsigned.

Shalom,

I have seen that discussion but there the structure was anonymous structure and the equivalent
which could be drawn will be something like "bit signed [][]S1;" is somehow different than typedef

Regards,
dhiRAj

 

Surya Pratik Saha wrote:
> Hi Greg,
> If you are saying "but |b2[0]| is signed, whereas |b3[0]| isn't", then
> I am not sure in which logic you are saying 'var1[0]' is signed. Does
> the signed keyword of struct not apply as a whole of var1 variable
> including [1:0] range? I think yes. Then var1 is signed but var1[0] is
> not. Can you please refer any LRM snippet for your comment.
> Regards
> Surya
>
>
> -------- Original Message --------
> Subject: Re: [sv-bc] Query related with signedness of variable.
> From: Greg Jaxon <Greg.Jaxon@synopsys.com>
> To: Dhiraj Kumar Prasad <dhiraj@cal.interrasystems.com>
> Cc: "sv-bc@server.eda.org" <sv-bc@eda.org>
> Date: Wednesday, March 23, 2011 12:59:45 AM
>> On 3/22/2011 8:59 AM, Dhiraj Kumar Prasad wrote:
>>> Hello,
>>>
>>> I have a query related with signedness of a variable.
>>>
>>> In following example
>>>
>>> module test();
>>>
>>> typedef struct packed signed {
>>> bit [1:0] bit1;
>>> }[1:0]S1;
>>> S1 var1;
>>> int i;
>>> initial
>>> begin
>>> var1[0] = 2'b10;
>>> i = var1[0];
>>> end
>>> endmodule
>>>
>>> Value of i should be 32'b11111111111111111111111111111110 or
>>> 32'b00000000000000000000000000000010.
>>>
>>
>> Value of |i| should be |32'sb11111111111111111111111111111110|
>> The elements of |var1| are packed /signed/ structures.
>>
>>> Different standard simulator are behaving differently.
>>>
>>> Should the equivalent of struct be like
>>>
>>> typedef bit signed [1:0] b1;
>>> typedef b1[1:0] b2;
>>>
>>> or
>>> typedef bit signed [1:0][1:0] b3;
>>>
>> Not sure how you mean "equivalent" here, but |b2[0]| is signed,
>> whereas |b3[0]| isn't.
>>
>> --
>> This message has been scanned for viruses and
>> dangerous content by *MailScanner* <http://www.mailscanner.info/>,
>> and is
>> believed to be clean.
>

-- 
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.
Received on Tue Mar 22 21:32:02 2011

This archive was generated by hypermail 2.1.8 : Tue Mar 22 2011 - 21:32:15 PDT