UVM_学习笔记(一)_简单验证平台的搭建

UVM_学习笔记(一)_简单验证平台搭建



前言

利用UVM搭建最简单验证平台的搭建。


DUT

此dut的功能,通过rxd接收数据,在通过txd发送出去,rx_dv是接收数据有效指示,tx_en是发送数据有效指示。即当rx_dv为高时,数据接收成功;tx_en为高时,数据发送成功

module dut(
	input clk,rst_n,
	input [7:0] rxd,
	input rx_dv,
	output reg [7:0] txd,
	output reg tx_en
);
	always@(posedge clk)begin
		if(!rst_n)begin
			txd <= 8'b0;
			tx_en <= 0;
		end
		else begin
			txd <= rxd;
			tx_en <= rx_dv;
		end
	end
endmodule

interface

`ifdef INTERFACE_SV
`define INTERFACE_SV
interface my_if(input clk,input rst_n);
	logic [7:0] data;
	logic valid;
endinterface
`endif

top_tb

`ifdef TOP_TB_SV
`define TOP_TB_SV
`timescale 1ns/1ps
`include "uvm_macros.svh"
import uvm_pkg::*;
`include "interface.sv"
`include "my_transaction.sv"
module top_tb;
	wire [7:0] txd;
	wire tx_en;
	reg [7:0] rxd;
	reg rx_dv;
	reg clk,rst_n;
	my_if input_if(clk,rst_n);
	my_if output_if(clk,rst_n);
	dut my_dut(
		.clk(clk),
		.rst_n(rst_n),
		.rxd(input_if.data),
		.rx_dv(input_if.valid),
		.txd(output_if.data),
		.tx_en(output_if.valid)
	);
	initial begin
		run_test("base_test");
	end
	initial begin
		`uvm_config_db #(virtual my_if)::set(null,"uvm_test_top.env.i_agt.drv","vif",input_if)
		`uvm_config_db #(virtual my_if)::set(null,"uvm_test_top.env.i_agt.mon","vif",input_if)
		`uvm_config_db #(virtual my_if)::set(null,"uvm_test_top.env.o_agt.mon","vif",output_if)
	end
	initial begin
		clk = 0;
		forever #5 clk = ~clk;
	end
	initial begin
		rst_n = 0;
		#1000 rst_n = 1;
	end
endmodule
`endif

transaction

`ifdef MY_TRANSACTION_SV
`define MY_TRANSACTION_SV
class my_transaction extends uvm_sequence_item;
	function new(string name = "my_transaction");
		super.new(name);
	endfunction
	rand bit [47:0] smac;
	rand bit [47:0] dmac;
	rand bit [15:0] ether_type;
	rand byte pload[];
	rand bit [31:0] crc;
	`uvm_object_utils_begin(my_transaction)
		`uvm_field_int(smac,UVM_ALL_ON)
		`uvm_field_int(dmac,UVM_ALL_ON)
		`uvm_field_int(ether_type,UVM_ALL_ON)
		`uvm_field_array_int(pload
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值