Advertisement
Guest User

Untitled

a guest
Jul 17th, 2019
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.41 KB | None | 0 0
  1. ----- ---------------------
  2. | MON |---->|uvm_tlm_analysis_fifo|
  3. ----- ---------------------
  4. ^ |
  5. | |
  6. ------------- | ------- |
  7. | |---------->| slave | v
  8. | DUT | ------- --------
  9. | |<---------------------| master |
  10. ------------- --------
  11.  
  12. typedef class seq_item extends uvm_sequence_item;
  13. typedef class driver extends uvm_driver(seq_item);
  14.  
  15. class agent extends uvm_agent;
  16. `uvm_component_utils(agent)
  17. uvm_analysis_port#(seq_item) ap;
  18. uvm_tlm_analysis_fifo#(seq_item) fifo;
  19. driver drv;
  20.  
  21. function new(string name, uvm_component parent);
  22. super.new(name,parent);
  23. endfunction: new
  24.  
  25. function void build_phase(uvm_phase phase);
  26. super.build_phase(phase);
  27. ap = new("ap", this);
  28. fifo= new("fifo",this);
  29. drv = driver::type_id::create("driver", this);
  30. endfunction: build_phase
  31.  
  32. function void connect_phase(uvm_phase phase);
  33. super.connect_phase(phase);
  34. ap.connect(fifo.analysis_export);
  35. drv.seq_item_port.connect(fifo.get_peek_export);
  36. endfunction: connect_phase
  37.  
  38. task main_phase(uvm_phase phase);
  39. seq_item trans;
  40. phase.raise_objection(this);
  41. repeat(5) begin
  42. trans = seq_item::type_id::create("inTrans");
  43. assert(trans.randomize());
  44. ap.write(trans);
  45. end
  46. phase.drop_objection(this);
  47. endtask
  48. endclass: agent
  49.  
  50. `include "uvm_macros.svh"
  51. package t;
  52. import uvm_pkg::*;
  53. class seq_item extends uvm_sequence_item;
  54. `uvm_object_utils(seq_item)
  55.  
  56. rand bit [31:0] data;
  57. function new(string name = "seq_item");
  58. super.new(name);
  59. endfunction: new
  60. endclass: seq_item
  61.  
  62. class driver extends uvm_driver#(seq_item);
  63. `uvm_component_utils(driver)
  64. function new (string name, uvm_component parent);
  65. super.new(name, parent);
  66. endfunction: new
  67.  
  68. task main_phase(uvm_phase phase);
  69. fork
  70. super.main_phase(phase);
  71. join_none
  72. forever begin
  73. seq_item_port.get_next_item(req);
  74. `uvm_info(get_type_name(),$psprintf("Got item with data: %h",req.data),UVM_NONE);
  75. seq_item_port.item_done();
  76. end
  77. endtask: main_phase
  78. endclass: driver
  79.  
  80. class test extends uvm_test;
  81. `uvm_component_utils(test)
  82. uvm_analysis_port#(seq_item) ap;
  83. uvm_tlm_analysis_fifo#(seq_item) fifo;
  84.  
  85. driver drv;
  86.  
  87. function new(string name, uvm_component parent);
  88. super.new(name,parent);
  89. endfunction: new
  90. function void build_phase(uvm_phase phase);
  91. super.build_phase(phase);
  92. ap = new(.name("apb_ap"), .parent(this));
  93. fifo= new("fifo",this);
  94. drv = driver ::type_id::create(.name("driver"), .parent(this) );
  95. endfunction: build_phase
  96.  
  97. function void connect_phase(uvm_phase phase);
  98. super.connect_phase(phase);
  99. ap.connect(fifo.analysis_export);
  100. drv.seq_item_port.connect(fifo.get_peek_export);
  101. endfunction: connect_phase
  102.  
  103. task main_phase(uvm_phase phase);
  104. seq_item trans;
  105. phase.raise_objection(this);
  106. repeat(5) begin
  107. trans = seq_item::type_id::create("inTrans");
  108. assert(trans.randomize());
  109. ap.write(trans);
  110. end
  111. phase.drop_objection(this);
  112. endtask
  113. endclass: test
  114. endpackage
  115.  
  116. module top();
  117. import uvm_pkg::*;
  118. import t::*;
  119. initial begin
  120. run_test();
  121. end
  122. endmodule
  123.  
  124. ** Error: (vsim-7065) 5.sv(51): Illegal assignment to class mtiUvm.uvm_pkg::uvm_port_base #(class mtiUvm.uvm_pkg::uvm_sqr_if_base #(class work.t::seq_item, class work.t::seq_item)) from class mtiUvm.uvm_pkg::uvm_get_peek_imp #(class work.t::seq_item, class mtiUvm.uvm_pkg::uvm_tlm_fifo_base #(class work.t::seq_item))
  125. # Time: 0 ns Iteration: 0 Region: /t File: 5.sv
  126. # ** Error: (vsim-8754) 5.sv(51): Actual input arg. of type 'class mtiUvm.uvm_pkg::uvm_get_peek_imp #(class work.t::seq_item, class mtiUvm.uvm_pkg::uvm_tlm_fifo_base #(class work.t::seq_item))' for formal 'provider' of 'connect' is not compatible with the formal's type 'class mtiUvm.uvm_pkg::uvm_port_base #(class mtiUvm.uvm_pkg::uvm_sqr_if_base #(class work.t::seq_item, class work.t::seq_item))'.
  127.  
  128. ----- ---------
  129. | MON |---->|sequencer|
  130. ----- | ------|
  131. ^ | | fifo |
  132. | ---------
  133. ------------- | ------- |
  134. | |-------->| slave | v
  135. | DUT | ------- --------
  136. | |<-----------------| master |
  137. ------------- --------
  138.  
  139. class fifo_sequencer#(type REQ=uvm_sequence_item,RSP=REQ) extends uvm_sequencer#(REQ,RSP);
  140. `uvm_component_param_utils(fake_sequencer#(REQ,RSP))
  141.  
  142. uvm_tlm_analysis_fifo#(REQ) fifo;
  143.  
  144. function new(string name, uvm_component parent);
  145. super.new(name, parent);
  146. fifo = new("fifo", this);
  147. endfunction
  148.  
  149. task get_next_item(output REQ t);
  150. fifo.get_peek_export.get(t);
  151. endtask
  152.  
  153. function void item_done(RSP item = null);
  154. if (item != null) begin
  155. seq_item_export.put_response(item);
  156. end
  157. endfunction
  158. endclass
  159.  
  160. `include "uvm_macros.svh"
  161. package t;
  162. import uvm_pkg::*;
  163.  
  164. class seq_item extends uvm_sequence_item;
  165. `uvm_object_utils(seq_item)
  166.  
  167. rand bit [31:0] data;
  168. function new(string name = "seq_item");
  169. super.new(name);
  170. endfunction: new
  171. endclass: seq_item
  172.  
  173. class driver extends uvm_driver#(seq_item);
  174. `uvm_component_utils(driver)
  175. function new (string name, uvm_component parent);
  176. super.new(name, parent);
  177. endfunction: new
  178.  
  179. task main_phase(uvm_phase phase);
  180. fork
  181. super.main_phase(phase);
  182. join_none
  183. forever begin
  184. seq_item_port.get_next_item(req);
  185. `uvm_info(get_type_name(),$psprintf("Got item with data: %h",req.data),UVM_NONE);
  186. seq_item_port.item_done();
  187. end
  188. endtask: main_phase
  189. endclass: driver
  190.  
  191. class fifo_sequencer#(type REQ=uvm_sequence_item,RSP=REQ) extends uvm_sequencer#(REQ,RSP);
  192. `uvm_component_param_utils(fifo_sequencer#(REQ,RSP))
  193.  
  194. uvm_tlm_analysis_fifo#(REQ) fifo;
  195.  
  196. function new(string name, uvm_component parent);
  197. super.new(name, parent);
  198. fifo = new("fifo", this);
  199. endfunction
  200.  
  201. task get_next_item(output REQ t);
  202. fifo.get_peek_export.get(t);
  203. endtask
  204.  
  205. function void item_done(RSP item = null);
  206. if (item != null) begin
  207. seq_item_export.put_response(item);
  208. end
  209. endfunction
  210. endclass
  211.  
  212. class test extends uvm_test;
  213. `uvm_component_utils(test)
  214. uvm_analysis_port#(seq_item) ap;
  215.  
  216. driver drv;
  217. fifo_sequencer#(seq_item) sqr;
  218.  
  219. function new(string name, uvm_component parent);
  220. super.new(name,parent);
  221. endfunction: new
  222. function void build_phase(uvm_phase phase);
  223. super.build_phase(phase);
  224. ap = new("apb_ap", this);
  225. sqr = fifo_sequencer#(seq_item) ::type_id::create("sequencer", this);
  226. drv = driver ::type_id::create("driver", this);
  227. endfunction: build_phase
  228.  
  229. function void connect_phase(uvm_phase phase);
  230. super.connect_phase(phase);
  231. ap.connect(sqr.fifo.analysis_export);
  232. drv.seq_item_port.connect(sqr.seq_item_export);
  233. endfunction: connect_phase
  234.  
  235. task main_phase(uvm_phase phase);
  236. seq_item trans;
  237. phase.raise_objection(this);
  238. repeat(5) begin
  239. trans = seq_item::type_id::create("inTrans");
  240. assert(trans.randomize());
  241. ap.write(trans);
  242. end
  243. phase.drop_objection(this);
  244. endtask
  245. endclass: test
  246. endpackage
  247.  
  248. module top();
  249. import uvm_pkg::*;
  250. import t::*;
  251. initial begin
  252. run_test();
  253. end
  254. endmodule
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement