Wednesday, April 23, 2008

Reusable Channel using Parameterized class

Let's consider the example of generic channel using paramerized class,

class channel #(type T = integer);

    T          queue[$];
    semaphore  sem;
    task put_data(T t);
    task get_data(ref T t);
        t = queue.pop_back(t);


Using above mentioned code, you can create any type of customized channel between two components.
Channel passing integer data between two components using,
channel #(integer) int_channel = new();
Channel passing class object of type 'data_class' between two component using,
channel #(data_class) data_class_channel = new();

Next: Reusable Channel using Define Macro

No comments:

Post a Comment