RE: [sv-bc] Function cannot return Unpack Array but can return unpack typedef

From: Arturo Salz <Arturo.Salz_at_.....>
Date: Fri Mar 13 2009 - 10:01:11 PDT
I believe that superlog had even defined some special syntax using '$' to handle the anonymous packed/unpacked array ambiguity. Something like:

function  bit [3:0] func_arr  (bit [7:0] arg);            // packed array return type
function  bit $ [3:0] func_arr  (bit [7:0] arg);         // unpacked array return type

Thus, you could write function
bit [3:0] $ [1:0] func_arr (bit [7:0] arg);

Perhaps we can introduce something like this to SV? I'm not sure it's that worthwhile though.

            Arturo

From: owner-sv-bc@eda.org [mailto:owner-sv-bc@eda.org] On Behalf Of Rich, Dave
Sent: Friday, March 13, 2009 7:57 AM
To: Abhishek Roy; sv-bc
Cc: Antara Ghosh; Saikat Bandyopadhyay
Subject: RE: [sv-bc] Function cannot return Unpack Array but can return unpack typedef

The quick answer is that the BNF only allows a basic data type to be specified in this spot, and an unpacked array is not a basic data type. I would have liked it to have been even stricter, like only allow simple_types since it makes no sense to declare an anonymous struct as the return type of a function.

The original reason for disallowing this goes back to SUPERLOG, which had pointers to functions and there was ambiguity in whether your intent was an array of function pointers or an unpacked array return type This was further complicated because of the existence of packed and unpacked array dimensions.

________________________________
From: owner-sv-bc@eda.org [mailto:owner-sv-bc@eda.org] On Behalf Of Abhishek Roy
Sent: Tuesday, July 05, 2005 12:27 AM
To: sv-bc
Cc: Antara Ghosh; Saikat Bandyopadhyay
Subject: [sv-bc] Function cannot return Unpack Array but can return unpack typedef

Hi all,

Consider the following scenario :-

/*************************************************************************************/
module test (input [7:0] in1, output bit [3:0] out1 [1:0]);

function  bit [3:0] func_arr [1:0] (bit [7:0] arg);  //invalid syntax : function cannot return unpack array
begin
    func_arr[1] = arg[7:4];
    func_arr[0] = arg[3:0];
end
endfunction

typedef bit [3:0] bit_arr [1:0];
function  bit_arr func_type (bit [7:0] arg); //valid syntax : But bit_arr is still unpack typedef
begin
    func_type[1] = arg[7:4];
    func_type[0] = arg[3:0];
end
endfunction

always@(*)
begin
    out1 = func_arr(in1); //invalid assignment
    out1 = func_type(in1); //valid assignment
end

endmodule
/*************************************************************************************/

Hence, when  a function can return object of unpack typedef , then why not unpack array.

regards
-Abhishek Roy

--
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 Fri Mar 13 10:04:12 2009

This archive was generated by hypermail 2.1.8 : Fri Mar 13 2009 - 10:05:06 PDT