[sv-bc] Examples of parameterized class static functions

From: Gordon Vreugdenhil <gordonv@model.com>
Date: Mon Aug 16 2010 - 10:01:02 PDT

Here are some trivial examples of using parameterized
classes to mimic parameterized functions. This would
also trivially map to parameterized tasks, types, etc.
The only current LRM issue is 1527 (use as a constant
function).

Gord

class f#(type T = int);
    static function T f (T a); return a; endfunction
endclass

`define dofunc(base,val) base#(type(val))::base(val)

module top;
   int v1 = f#()::f(4);
   typedef f#(reg) freg;
   int v2 = freg::f(1);
   typedef enum {red, blue} Color;
   Color c = blue;
   Color v3 = `dofunc(f,c);

   initial #1 $display(v1, v2, v3);
endmodule

-- 
--------------------------------------------------------------------
Gordon Vreugdenhil                                503-685-0808
Model Technology (Mentor Graphics)                gordonv@model.com
-- 
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.
Received on Mon Aug 16 10:01:32 2010

This archive was generated by hypermail 2.1.8 : Mon Aug 16 2010 - 10:04:16 PDT