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

1 comment:

  1. Hi Sandeep,

    How to generalize below indicated "coverpoint" code for any number of chain (32, 64 and 128 etc). Cover point should have a bin for each selected chain. Please note that RHS is using one-hot coding.

    Thanks in advance,

    dut_chainsel_cov: coverpoint TxnPacket.chain_selected iff (Opcode == 'h13) {

    bins none_of_the_chain_selected = {'h0};
    bins chain_0_selected = {8'h1};
    bins chain_1_selected = {8'h2};
    bins chain_2_selected = {8'h4};
    bins chain_3_selected = {8'h8};
    bins chain_4_selected = {8'h10};
    bins chain_5_selected = {8'h20};
    bins chain_6_selected = {8'h40};
    bins chain_7_selected = {8'h80};