class channel #(type T = integer);
T queue[$];
semaphore sem;
task put_data(T t);
sem.get(1);
queue.push_back(t);
sem.put(1);
endtask
task get_data(ref T t);
sem.get(1);
t = queue.pop_back(t);
sem.put(1);
endtask
endclass
Using above mentioned code, you can create any type of customized channel between two components.
Like,
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
Hi Sandeep,
ReplyDeleteHow 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,
Pradeep
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};
}