微波EDA网,见证研发工程师的成长!
首页 > 研发问答 > 微电子和IC设计 > IC验证交流 > 有关uvm验证的问题

有关uvm验证的问题

时间:10-02 整理:3721RD 点击:

  1. `timescale 1ns/1ps
  2. `include "uvm_pkg.sv"


  3. module top_tb;
  4. import uvm_pkg::*;
  5. `include "uvm_macros.svh"

  6. reg clk;
  7. reg rst_n;
  8. reg[7:0] rxd;
  9. reg rx_dv;
  10. wire[7:0] txd;
  11. wire tx_en;

  12. class my_driver extends uvm_driver;

  13. function new(string name = "my_driver", uvm_component parent = null);
  14. super.new(name, parent);
  15. endfunction
  16. extern virtual task main_phase(uvm_phase phase);

  17. endclass

  18. task my_driver::main_phase(uvm_phase phase);
  19. top_tb.rxd <= 8'b0;
  20. top_tb.rx_dv <= 1'b0;
  21. while(top_tb.rst_n)
  22. @(posedge top_tb.clk);
  23. for(int i = 0; i < 256; i++)begin
  24. @(posedge top_tb.clk);
  25. top_tb.rxd <= $urandom_range(0, 255);
  26. top_tb.rx_dv <= 1'b1;
  27. `uvm_info("my_driver", "data is drived", UVM_LOW)
  28. end
  29. @(posedge top_tb.clk);
  30. top_tb.rx_dv <= 1'b0;
  31. endtask

  32. dut my_dut(.clk(clk),
  33. .rst_n(rst_n),
  34. .rxd(rxd),
  35. .rx_dv(rx_dv),
  36. .txd(txd),
  37. .tx_en(tx_en));

  38. initial begin
  39. my_driver drv;
  40. drv = new("drv", null);
  41. drv.main_phase(null);
  42. // $finish();
  43. // rxd = 200;
  44. // rx_dv = 0;
  45. // @(posedge rst_n);
  46. // rxd = 255;
  47. // rx_dv = 1;
  48. end

  49. initial begin
  50. clk = 0;
  51. forever begin
  52. #100 clk = ~clk;
  53. end
  54. end

  55. initial begin
  56. rst_n = 1'b0;
  57. #1000;
  58. rst_n = 1'b1;
  59. end

  60. endmodule

复制代码


我将上面这个类定义在内部的时候可以正常仿真为什么我单独定义的时候就不能使用了呢?

  1. `ifndef MY_DRIVER__SV
  2. `define MY_DRIVER__SV
  3. class my_driver extends uvm_driver;

  4. function new(string name = "my_driver", uvm_component parent = null);
  5. super.new(name, parent);
  6. endfunction
  7. extern virtual task main_phase(uvm_phase phase);
  8. endclass

  9. task my_driver::main_phase(uvm_phase phase);
  10. top_tb.rxd <= 8'b0;
  11. top_tb.rx_dv <= 1'b0;
  12. while(!top_tb.rst_n)
  13. @(posedge top_tb.clk);
  14. for(int i = 0; i < 256; i++)begin
  15. @(posedge top_tb.clk);
  16. top_tb.rxd <= $urandom_range(0, 255);
  17. top_tb.rx_dv <= 1'b1;
  18. `uvm_info("my_driver", "data is drived", UVM_LOW)
  19. end
  20. @(posedge top_tb.clk);
  21. top_tb.rx_dv <= 1'b0;
  22. endtask
  23. `endif

复制代码


我使用的是linux环境,questasim10.3a。do文件如下:

  1. setUVM_DPI_HOME/opt/mentor_graphics/questa/10.3a/questasim/uvm-1.1d/linux_x86_64
  2. vlib work
  3. vmap work
  4. vlog+incdir+/opt/mentor_graphics/questa/10.3a/questasim/verilog_src/uvm-1.1d/src -L mtiAvm -L mtiOvm -L mtiUvm -L mtiUPFtop_tb.sv
  5. vlog+incdir+/opt/mentor_graphics/questa/10.3a/questasim/verilog_src/uvm-1.1d/src -L mtiAvm -L mtiOvm -L mtiUvm -L mtiUPFdut.sv
  6. vlog+incdir+/opt/mentor_graphics/questa/10.3a/questasim/verilog_src/uvm-1.1d/src -L mtiAvm -L mtiOvm -L mtiUvm -L mtiUPFmy_driver.sv
  7. vsim-ldflags "-lregex" -t 1ns -c -sv_lib $UVM_DPI_HOME/uvm_dpi -voptargs=+acc -L lpm_ver -L altera_mf_ver -L altera_ver -L stratixv_ver work.top_tb

  8. set StdArithNoWarnings 1
  9. set NumericStdNoWarnings 1

复制代码

试试先编译my_driver.sv,再编译top_tb.sv看看?

效果差不多,error信号如下

  1. # ** Error: my_driver.sv(3): near "uvm_driver": syntax error, unexpected IDENTIFIER
  2. # ** Error: my_driver.sv(3): Error in class extension specification.

复制代码

`include "uvm_pkg.sv"
`include "uvm_macros.svh"
加到my_driver.sv里边试试

谢谢,这下可以了

Copyright © 2017-2020 微波EDA网 版权所有

网站地图

Top