View Full Version : Passing Dynamic array of Class on TLM channel
abhingp01
01-04-2010, 10:47 PM
Hi all,
I need to pass dynamic array of class (buffer) on tlm channel.
Some thing like.
// --------------------------------------------------------------------
class dummy # (param1,param2)
bit[7:0] addr;
bit[7:0] data;
endclass : dummy
// --------------------------------------------------------------------
class top # (param1,param2)
dummy class_array[];
ovm_transport_port(dummy[],dummy[]) my_port; ........................!!!
// . . . .
class_array = new[10];
my_port.put(class_array);
// . . . .
endclass : top
// --------------------------------------------------------------------
class foo # (param1,param2)
// . . . .
dummy class_array_rec[];
ovm_transport_imp(dummy[],dummy[],foo) my_imp; ................... !!!
my_imp.get(class_array_rec[]); .................................................! !!
// . . . .
endclass: foo
// --------------------------------------------------------------------
Is this correct ???
Regards,
Abhi
chinmay
01-05-2010, 04:26 AM
Hi Abhi ,
The TLM port declaration does not take array as a type but takes only class as a type, hence you need to wrap arround the array of classes inside another class and then pass it to the port.I have taken a simple putport without any parameterized data and it seems working fine.
Let me know if this helps
Regards
Chinmay
chinmay@cadence.com
http://support.cadence.com
=====tlm_dy_array-pass_test.sv===
module top;
import ovm_pkg::*;
`include "ovm_macros.svh"
class dummy extends ovm_object;
bit[7:0] addr;
bit[7:0] data;
`ovm_object_utils_begin(dummy)
`ovm_field_int(addr, OVM_ALL_ON)
`ovm_field_int(data, OVM_ALL_ON)
`ovm_object_utils_end
endclass
class dat extends ovm_sequence_item;
dummy class_array[];
`ovm_object_utils_begin(dat)
`ovm_field_array_object(class_array, OVM_ALL_ON)
`ovm_object_utils_end
function new (string name = "dat");
super.new(name);
class_array = new[4];
for (int i = 0; i < 4; i++)
begin
class_array[i] = new();
end
endfunction : new
endclass
lass producer extends ovm_threaded_component;
dat idat;
`ovm_component_utils(producer)
ovm_blocking_put_port #(dat) iputit = new("iputit", this);
function new(string name="producer", ovm_component parent);
super.new(name, parent);
endfunction
task run();
for (int i=0; i<5; i++)
begin
idat = new();
assert(idat.randomize() );
$display("Producer creates data");
idat.print();
iputit.put(idat); // call the put() function in the consumer
end
#2000;
global_stop_request();
endtask
endclass
lass consumer extends ovm_threaded_component;
dat idat;
`ovm_component_utils(consumer)
ovm_blocking_put_imp #(dat, consumer) putit = new("putit", this);
function new(string name="consumer", ovm_component parent);
super.new(name, parent);
endfunction // new
// this consumer needs to supply the producer with a "put" task
task put(input dat dat_in);
$display("Consumer prints Producer's data sent thru TLM port");
idat = dat_in;
idat.print();
endtask
endclass
lass myenv extends ovm_env;
consumer iconsumer;
producer iproducer;
`ovm_component_utils(myenv)
function new(string name = "myenv", ovm_component parent = null);
super.new(name, parent);
endfunction : new
function void build();
super.build();
iproducer = producer::type_id::create("iproducer",this);
iconsumer = consumer::type_id::create("iconsumer",this);
endfunction
function void connect();
iproducer.iputit.connect(iconsumer.putit);
endfunction
endclass
myenv imyenv;
initial
begin
imyenv = new();
run_test();
end
endmodule
========end================
~
abhingp01
01-05-2010, 04:36 AM
Thanks a lot chinmay . . .
As an alternate way I had used a for loop to send all items in array rather than sending array itself.
I will try it again by wraping array into a class as you told.
thanks once again.
Powered by vBulletin™ Version 4.0.3 Copyright © 2010 vBulletin Solutions, Inc. All rights reserved.