【无标题】

本文档展示了APB(Advanced Peripheral Bus)总线协议的主从通信序列实现,包括单次写、单次读、写读序列以及突发写和突发读序列。每个序列类继承自基础序列类,并定义了相应的随机化字段和约束,用于模拟APB总线上的不同事务类型。
摘要由CSDN通过智能技术生成

ifndef APB_MASTER_SEQ_LIB_SVdefine APB_MASTER_SEQ_LIB_SV

//------------------------------------------------------------------------------
// SEQUENCE: default
//------------------------------------------------------------------------------
typedef class apb_transfer;
typedef class apb_master_sequencer;

class apb_master_base_sequence extends uvm_sequence #(apb_transfer);

`uvm_object_utils(apb_master_base_sequence)
function new(string name="");
super.new(name);
endfunction : new

endclass : apb_master_base_sequence

// USER: Add your sequences here

class apb_master_single_write_sequence extends apb_master_base_sequence;
rand bit [31:0] addr;
rand bit [31:0] data;

`uvm_object_utils(apb_master_single_write_sequence)
function new(string name="");
super.new(name);
endfunction : new

virtual task body();
uvm_info(get_type_name(),"Starting sequence", UVM_HIGH)uvm_do_with(req, {trans_kind == WRITE; addr == local::addr; data == local::data;})
get_response(rsp);
`uvm_info(get_type_name(),$psprintf(“Done sequence: %s”,req.convert2string()), UVM_HIGH)
endtask: body

endclass: apb_master_single_write_sequence

class apb_master_single_read_sequence extends apb_master_base_sequence;
rand bit [31:0] addr;
rand bit [31:0] data;

`uvm_object_utils(apb_master_single_read_sequence)
function new(string name="");
super.new(name);
endfunction : new

virtual task body();
uvm_info(get_type_name(),"Starting sequence", UVM_HIGH)uvm_do_with(req, {trans_kind == READ; addr == local::addr;})
get_response(rsp);
data = rsp.data;
`uvm_info(get_type_name(),$psprintf(“Done sequence: %s”,req.convert2string()), UVM_HIGH)
endtask: body

endclass: apb_master_single_read_sequence

class apb_master_write_read_sequence extends apb_master_base_sequence;
rand bit [31:0] addr;
rand bit [31:0] data;
rand int idle_cycles;
constraint cstr{
idle_cycles == 0;
}

`uvm_object_utils(apb_master_write_read_sequence)
function new(string name="");
super.new(name);
endfunction : new

virtual task body();
uvm_info(get_type_name(),"Starting sequence", UVM_HIGH)uvm_do_with(req, {trans_kind == WRITE;
addr == local::addr;
data == local::data;
idle_cycles == local::idle_cycles;
})
get_response(rsp);
uvm_do_with(req, {trans_kind == READ; addr == local::addr;}) get_response(rsp); data = rsp.data;uvm_info(get_type_name(),$psprintf(“Done sequence: %s”,req.convert2string()), UVM_HIGH)
endtask: body

endclass: apb_master_write_read_sequence

class apb_master_burst_write_sequence extends apb_master_base_sequence;
rand bit [31:0] addr;
rand bit [31:0] data[];
constraint cstr{
soft data.size() inside {4, 8, 16, 32};
foreach(data[i]) soft data[i] == addr + (i << 2);
}

`uvm_object_utils(apb_master_burst_write_sequence)
function new(string name="");
super.new(name);
endfunction : new

virtual task body();
uvm_info(get_type_name(),"Starting sequence", UVM_HIGH) foreach(data[i]) beginuvm_do_with(req, {trans_kind == WRITE;
addr == local::addr + (i<<2);
data == local::data[i];
idle_cycles == 0;
})
get_response(rsp);
end
uvm_do_with(req, {trans_kind == IDLE;}) get_response(rsp);uvm_info(get_type_name(),$psprintf(“Done sequence: %s”,req.convert2string()), UVM_HIGH)
endtask: body
endclass: apb_master_burst_write_sequence

class apb_master_burst_read_sequence extends apb_master_base_sequence;
rand bit [31:0] addr;
rand bit [31:0] data[];
constraint cstr{
soft data.size() inside {4, 8, 16, 32};
}
`uvm_object_utils(apb_master_burst_read_sequence)
function new(string name="");
super.new(name);
endfunction : new

virtual task body();
uvm_info(get_type_name(),"Starting sequence", UVM_HIGH) foreach(data[i]) beginuvm_do_with(req, {trans_kind == READ;
addr == local::addr + (i<<2);
idle_cycles == 0;
})
get_response(rsp);
data[i] = rsp.data;
end
uvm_do_with(req, {trans_kind == IDLE;}) get_response(rsp);uvm_info(get_type_name(),$psprintf(“Done sequence: %s”,req.convert2string()), UVM_HIGH)
endtask: body
endclass: apb_master_burst_read_sequence

endif // APB_MASTER_SEQ_LIB_SV /ifndef APB_MASTER_SEQUENCER_SV
`define APB_MASTER_SEQUENCER_SV

function apb_master_sequencer::new (string name, uvm_component parent);
super.new(name, parent);
endfunction : new

`endif // APB_MASTER_SEQUENCER_SV
///

ifndef APB_MASTER_SEQUENCER_SVHdefine APB_MASTER_SEQUENCER_SVH

class apb_master_sequencer extends uvm_sequencer #(apb_transfer);

//
//
// Public interface (Component users may manipulate these fields/methods)
//
//
apb_config cfg;

// Provide implementations of virtual methods such as get_type_name and create
uvm_component_utils_begin(apb_master_sequencer) // USER: Register fieldsuvm_component_utils_

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值