Tutorials
Learn More
TLM Analysis FIFO
UVM TLM analysis FIFO is nothing but a UVM TLM FIFO with an unbounded size and a write interface.
Same as uvm_tlm_fifo, uvm_tlm_analysis_fifo is used to store broadcasted transactions and retrieve them based on the requirement.
It can be used in any place a uvm_analysis_imp is used.
class uvm_tlm_analysis_fifo #( type T = int ) extends uvm_tlm_fifo #(T)
analysis_export #(T)
– The analysis_export provides the write method to all connected analysis ports and parent exports
TLM Analysis FIFO methods
Methods |
Description |
new |
To create TLM analysis FIFO. function new (string name, uvm_component parent=null); |
write |
function void write (T t) |
TLM Analysis FIFO example
`include "uvm_macros.svh"
import uvm_pkg::*;
`include "seq_item.sv"
class producer extends uvm_component;
seq_item req;
uvm_analysis_port #(seq_item) a_port;
`uvm_component_utils(producer)
function new(string name = "producer", uvm_component parent = null);
super.new(name, parent);
a_port = new("a_port", this);
endfunction
task run_phase(uvm_phase phase);
super.run_phase(phase);
repeat(10) begin
req = seq_item::type_id::create("req");
assert(req.randomize());
a_port.write(req);
`uvm_info(get_name(), $sformatf("Send value = %0h", req.value), UVM_NONE);
#5;
end
endtask
endclass
class consumer extends uvm_component;
seq_item req;
uvm_tlm_analysis_fifo #(seq_item) tlm_a_fifo;
`uvm_component_utils(consumer)
function new(string name = "consumer", uvm_component parent = null);
super.new(name, parent);
tlm_a_fifo = new("tlm_a_fifo", this);
endfunction
task run_phase(uvm_phase phase);
super.run_phase(phase);
repeat(10) begin
#10;
tlm_a_fifo.get(req);
`uvm_info(get_type_name(), $sformatf("Received value = %0h", req.value), UVM_NONE);
end
endtask
endclass
class env extends uvm_env;
producer pro;
consumer con;
`uvm_component_utils(env)
function new(string name = "env", uvm_component parent = null);
super.new(name, parent);
endfunction
function void build_phase(uvm_phase phase);
super.build_phase(phase);
pro = producer::type_id::create("pro", this);
con = consumer::type_id::create("con", this);
endfunction
function void connect_phase(uvm_phase phase);
super.connect_phase(phase);
pro.a_port.connect(con.tlm_a_fifo.analysis_export);
endfunction
endclass
class test extends uvm_test;
env env_o;
`uvm_component_utils(test)
function new(string name = "test", uvm_component parent = null);
super.new(name, parent);
endfunction
function void build_phase(uvm_phase phase);
super.build_phase(phase);
env_o = env::type_id::create("env_o", this);
endfunction
task run_phase(uvm_phase phase);
phase.raise_objection(this);
#100;
phase.drop_objection(this);
endtask
endclass
module tb_top;
initial begin
run_test("test");
end
endmodule
Output:
UVM_INFO testbench.sv(24) @ 0: uvm_test_top.env_o.pro [pro] Send value = 5
UVM_INFO testbench.sv(24) @ 5: uvm_test_top.env_o.pro [pro] Send value = 8
UVM_INFO testbench.sv(47) @ 10: uvm_test_top.env_o.con [consumer] Received value = 5
UVM_INFO testbench.sv(24) @ 10: uvm_test_top.env_o.pro [pro] Send value = 2
UVM_INFO testbench.sv(24) @ 15: uvm_test_top.env_o.pro [pro] Send value = 6
UVM_INFO testbench.sv(47) @ 20: uvm_test_top.env_o.con [consumer] Received value = 8
UVM_INFO testbench.sv(24) @ 20: uvm_test_top.env_o.pro [pro] Send value = b
UVM_INFO testbench.sv(24) @ 25: uvm_test_top.env_o.pro [pro] Send value = a
UVM_INFO testbench.sv(47) @ 30: uvm_test_top.env_o.con [consumer] Received value = 2
UVM_INFO testbench.sv(24) @ 30: uvm_test_top.env_o.pro [pro] Send value = 4
UVM_INFO testbench.sv(24) @ 35: uvm_test_top.env_o.pro [pro] Send value = 5
UVM_INFO testbench.sv(47) @ 40: uvm_test_top.env_o.con [consumer] Received value = 6
UVM_INFO testbench.sv(24) @ 40: uvm_test_top.env_o.pro [pro] Send value = c
UVM_INFO testbench.sv(24) @ 45: uvm_test_top.env_o.pro [pro] Send value = 3
UVM_INFO testbench.sv(47) @ 50: uvm_test_top.env_o.con [consumer] Received value = b
UVM_INFO testbench.sv(47) @ 60: uvm_test_top.env_o.con [consumer] Received value = a
UVM_INFO testbench.sv(47) @ 70: uvm_test_top.env_o.con [consumer] Received value = 4
UVM_INFO testbench.sv(47) @ 80: uvm_test_top.env_o.con [consumer] Received value = 5
UVM_INFO testbench.sv(47) @ 90: uvm_test_top.env_o.con [consumer] Received value = c
UVM_INFO testbench.sv(47) @ 100: uvm_test_top.env_o.con [consumer] Received value = 3
TLM Tutorials