What's the relationship between TLM interface,port/export and channel?

Hi all,
I know port/export which you can instantiate in the stimulus or transator to communicate with each other.channel have the export which implement what port need.

Then what’s the TLM interface for?I look a lot of TLM interface declaration.

Thank you!

Hi Ahan, TLM interface declares the API; for example, tlm_blocking_put_if declares that the API has 1 method: put(); whereas, tlm_put_if declares that the API consists of 3 methods: put(), try_put(), and can_put(). Note that the interface only defines the method prototypes; no implementation is provided. TLM port and export (or imp) are closely related to the TLM interface. When you declare a TLM port/export, you also need to declare the type of interface for that TLM port/export. A TLM port declares the type of interface that it REQUIRES; a TLM export (or imp) declares the type of interface that it PROVIDES (implements). An example below might help. In this example, a producer generates a packet and send to the consumer through a TLM blocking_put port:
class producer  extends ovm_threaded_component;
      ovm_blocking_put_port #(packet) packet_out= new("packet_out",  this);
      ...
      packet_out.<font color=Red>put</font>(packet1);
      ...
 endclass
  

class consumer  extends ovm_threaded_component;
      ovm_blocking_put_imp #(packet, consumer) packet_in= new("packet_in",  this);
      ...
     task <font color=Red>put</font>(input  packet pkt);
         ...//implementation of put() here
      endtask
      ...
 endclass

In the above code, the producer declares that it has TLM blocking_put port named packet_out; the producer will call the method declared in the tlm_blocking_put interface, put(), to send the packet. The consumer declares that it has a TLM blocking_put “imp”; this means that the consumer _provides _the implementation of the tlm_blocking_put interface: put().

Note that you can only connect port to export/imp of similar interface. For example, you can connect an ovm_blocking_put_port to an ovm_blocking_put_imp but you cannot connect an ovm_blocking_put_port to an ovm_blocking_get_imp. Since my response is getting pretty long, I have skipped a few things, such as the code to connect the consumer to the producer, and the “complete guidelines” of what type of TLM export/imp can be connected to what type of TLM port. You can get more details in the OVM reference guide.

Lastly you can think of the built-in TLM channels as FIFO (or FIFO’s for tlm_req_rsp_channel and tlm_transport_channel) with TLM interfaces; these are mainly used for buffering transactions so that the producer and consumer can “work” at its own rate. Again, you can get more details of these channels in the OVM reference guide.

Phu

Hi phu,
Thanks for your information and good example.
It seem the TLM interface is underneath port/export and channel.
My question is,when will we use TLM interface?
It 's used when we define our customize port/export or channel?
Otherwise,it’s meanless to users to know more about these,right?
Thank you!

Please read the AVM cookbook chapter 4, available at http://www.mentor.com/go/cookbook

Hi Ahan, The OVM library has defined all the different combination of port/export/imp; so, you probably will not have the needs to customize port/export/imp. The syntax for a type of port/export/imp is: ovm_'tlm interface type' _port #(T) ovm_'tlm interface type' _export #(T, 'component provides the implementation' ) ovm_'tlm interface type' _imp #(T, 'component provides the implementation' ) Even though you don't use the TLM interface directly, you still need to know about the API defined in the TLM interface, since you need to know which methods are available to call (in the port case) and which methods you will need to implement (in the imp case). For example, if you declare an ovm_put_imp in one of your components, you will need to provide the implementation of all the methods declared in the tlm_put_if: task put(), function bit try_put(), and function bit can_put(), in that component. Phu

I got it!
Thanks phu and dave!
Your information is very important for me:)