You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

122 lines
4.2 KiB

  1. // Brief description:
  2. // This is the axi master monitor, where in the information from the
  3. // virtual interface is caputured and translate into transaction level data
  4. //
  5. // Known exceptions to rules:
  6. //
  7. //============================================================================
  8. // Author : Venkatesh
  9. // Created on : 30/05/2025
  10. // File Id :
  11. //============================================================================
  12. `ifndef AXI_MASTER_MONITOR_SV
  13. `define AXI_MASTER_MONITOR_SV
  14. class axi_master_monitor#(parameter int DATA_WIDTH_MAS = 32,parameter int ADDR_WIDTH_MAS = 32) extends uvm_monitor;
  15. `uvm_component_utils(axi_master_monitor)
  16. uvm_analysis_port#(axi_tx) ap_sb;
  17. uvm_analysis_port#(axi_tx) ap_fc;
  18. //virtual axi_intf vif;
  19. virtual axi_interface#(.DATA_WIDTH(DATA_WIDTH_MAS),.ADDR_WIDTH(ADDR_WIDTH_MAS)) vif;
  20. axi_m_agent_config m_cfg;
  21. int addr [int];
  22. int data[*];
  23. int resp[int];
  24. axi_tx w_tx,r_tx;
  25. extern function new(string name="",uvm_component parent=null);
  26. extern function void build_phase(uvm_phase phase);
  27. extern task run_phase(uvm_phase phase);
  28. endclass
  29. //add a variable for configration of port
  30. function axi_master_monitor :: new(string name="",uvm_component parent=null);
  31. super.new(name,parent);
  32. //ap_port = new("ap_port",this);
  33. endfunction
  34. function axi_master_monitor :: void build_phase(uvm_phase phase);
  35. super.build_phase(phase);
  36. if(!uvm_config_db#(virtual axi_interface)::get(this,"","vif",vif))begin
  37. `uvm_error("[MONITOR]","VIF NOT RECEIVED FROM TOP")
  38. end
  39. if(!uvm_config_db #(axi_m_agent_config)::get(this,"","axi_m_agent_config",m_cfg)) begin
  40. `uvm_error("CONFIG","Getting failed in mst_monitor")
  41. end
  42. if(m_cfg.has_sb)
  43. ap_sb = new("ap_sb",this);
  44. if(m_cfg.has_fc)
  45. ap_fc = new("ap_fc",this);
  46. endfunction
  47. task axi_master_monitor :: run_phase(uvm_phase phase);
  48. forever begin
  49. @(vif.mon_cb);
  50. //write address channel
  51. if(vif.mon_cb.awvalid==1 && vif.mon_cb.awready==1)
  52. begin
  53. `uvm_info("[AWCHECK]",$psprintf("%t write addr %h",$time,vif.mon_cb.awaddr),UVM_LOW)
  54. w_tx = axi_tx::type_id::create("w_tx");
  55. w_tx.wr_rd = WRITE;
  56. w_tx.awid = vif.mon_cb.awid;
  57. w_tx.awaddr = vif.mon_cb.awaddr;
  58. w_tx.awlen = vif.mon_cb.awlen;
  59. w_tx.awsize = vif.mon_cb.awsize;
  60. w_tx.awburst = vif.mon_cb.awburst;
  61. w_tx.awcache = vif.mon_cb.awcache;
  62. w_tx.awprot = vif.mon_cb.awprot;
  63. w_tx.awlock = vif.mon_cb.awlock;
  64. addr[vif.mon_cb.awid]=w_tx;
  65. end
  66. // write data channel
  67. if(vif.mon_cb.wvalid==1 && vif.mon_cb.wready==1)
  68. begin
  69. `uvm_info("[WCHECK]",$psprintf("%t write data %h",$time,vif.mon_cb.wdata),UVM_LOW)
  70. w_tx.wdata.push_back(vif.mon_cb.wdata);
  71. w_tx.wstrb.push_back(vif.mon_cb.wstrb);
  72. w_tx.wlast=vif.mon_cb.wlast;
  73. data[]=w_tx;
  74. end
  75. //write response channel
  76. if(vif.mon_cb.bvalid==1 && vif.mon_cb.bready==1)
  77. begin
  78. w_tx.bid = vif.mon_cb.bid;
  79. `uvm_info("[BCHECK]",$psprintf("%t write RESP %h",$time,vif.mon_cb.bresp),UVM_LOW)
  80. w_tx.bresp = vif.mon_cb.bresp;
  81. resp[vif.mon_cb.bid]=w_tx;
  82. ap_port.write(w_tx);
  83. end
  84. //read address channel
  85. if(vif.mon_cb.arvalid==1 && vif.mon_cb.arready==1)
  86. begin
  87. `uvm_info("[ARCHECK]",$psprintf("%t read addr %h",$time,vif.mon_cb.araddr),UVM_LOW)
  88. r_tx = axi_tx::type_id::create("r_tx");
  89. w_tx.wr_rd = READ;
  90. r_tx.arid = vif.mon_cb.arid;
  91. r_tx.araddr = vif.mon_cb.araddr;
  92. r_tx.arlen = vif.mon_cb.arlen;
  93. r_tx.arsize = vif.mon_cb.arsize;
  94. r_tx.arburst = vif.mon_cb.arburst;
  95. r_tx.arcache = vif.mon_cb.arcache;
  96. r_tx.arprot = vif.mon_cb.arprot;
  97. r_tx.arlock = vif.mon_cb.arlock;
  98. end
  99. //read data channel
  100. if(vif.mon_cb.rvalid==1 && vif.mon_cb.rready==1)
  101. begin
  102. `uvm_info("[RCHECK]",$psprintf("%t write data %h",$time,vif.mon_cb.rdata),UVM_LOW)
  103. r_tx.rid = vif.mon_cb.rid;
  104. r_tx.rdata.push_back(vif.mon_cb.rdata);
  105. r_tx.rresp = vif.mon_cb.rresp;
  106. r_tx.rlast = vif.mon_cb.rlast;
  107. ap_port.write(r_tx);
  108. end
  109. end
  110. endtask
  111. `endif