Re: [sv-bc] static casting vs bit-stream casting

From: Daniel Mlynek <danielm@aldec.com.pl>
Date: Thu Sep 19 2013 - 09:12:12 PDT
OK i understand rules are defined in many places in LRM.
I still think that my 1st point should be done in LRM to have some 
clearence change :

Type casting can also be applied to unpacked arrays and structs.

to

Type casting can also be applied to unpacked arrays*classes*and structs.


Classes + static cast are not well understand - I'm seeing real codes 
where users try to use class static cast in place where dynamic cast 
should be done.

LRM on one side says that class can be bitsream type while on the other 
says that : "Class handles and chandles are type incompatible with all 
other types."
So from reading the above quoation and chapter with bit stream 
eplanation is below legal or not

module top;
   int i;
   class C; int j; endclass
   C c;
   class D; shortint k,l; endclass
   D d;
   intial begin
     c = C'(i);   //(1)?
     i = int'(c); //(2)?
     d = D'(c);   //(3)? to be 100% LRM compatybile only this one is legal?
   end
endmodule




DANiel

W dniu 9/18/2013 5:02 PM, Rich, Dave pisze:
> Actually, bit-stream casting is a static cast, and static casting only works when there are rules explaining how assignments are made between the types. If there are no explicit rules, the cast is illegal. See 6.22.4 Cast compatible
>
>
> Dave
> Mentor Graphics
>
>
> -----Original Message-----
> From: owner-sv-bc@eda.org [mailto:owner-sv-bc@eda.org] On Behalf Of Daniel Mlynek
> Sent: Wednesday, September 18, 2013 12:56 AM
> To: sv-bc@eda.org
> Subject: [sv-bc] static casting vs bit-stream casting
>
> Those 2 features : static casting and  bit-stream casting share same syntax. It depends on the type/expression used before apostrophe which one is used.
> IMHO current description need some clearence:
>
> 1. Chapter "Bit-stream casting" says "Type casting can also be applied to unpacked arrays and structs." While after reading whole chapter I suppose that at least classes need to be added to this sentence.
> It would be also nice to repeat in this chapter that bit stream casting occur if the type of cast and casted variaable are not assignment compatybile
>
> 2. Static cast chapter says:
> "If the expression is not assignment compatible with the casting type, then if the casting typeis an enumerated type, the behavior shall be as described as in 6.19.4, and if the casting type is a bit-stream type, the behavior shall be as described in 6.24.3."
> But do not explain what to do if the expression is not assignment compatible with the casting type and is not enum nor bit-stream type.
>
>
> DANiel
>
> --
> This message has been scanned for viruses and dangerous content by MailScanner, 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 Thu Sep 19 09:12:55 2013

This archive was generated by hypermail 2.1.8 : Thu Sep 19 2013 - 09:13:14 PDT