|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?注册
x
下面是uart_config的类声明,
class uart_config extends uvm_object;
//UART topology parameters
uvm_active_passive_enum is_tx_active = UVM_ACTIVE;
uvm_active_passive_enum is_rx_active = UVM_PASSIVE;
// UART device parameters
rand bit [7:0] baud_rate_gen; // Baud Rate Generator Register
rand bit [7:0] baud_rate_div; // Baud Rate Divider Register
// Line Control Register Fields
rand bit [1:0] char_length; // Character length (ua_lcr[1:0])
rand bit nbstop; // Number stop bits (ua_lcr[2])
rand bit parity_en ; // Parity Enable (ua_lcr[3])
rand bit [1:0] parity_mode; // Parity Mode (ua_lcr[5:4])
int unsigned chrl;
int unsigned stop_bt;
// Control Register Fields
rand bit cts_en ;
rand bit rts_en ;
// Calculated in post_randomize() so not randomized
byte unsigned char_len_val; // (8, 7 or 6)
byte unsigned stop_bit_val; // (1, 1.5 or 2)
// These default constraints can be overriden
// Constrain configuration based on UVC/RTL capabilities
// constraint c_num_stop_bits { nbstop inside {[0:1]};}
constraint c_bgen { baud_rate_gen == 1;}
constraint c_brgr { baud_rate_div == 0;}
constraint c_rts_en { rts_en == 0;}
constraint c_cts_en { cts_en == 0;}
// These declarations implement the create() and get_type_name()
// as well as enable automation of the tx_frame's fields
`uvm_object_utils_begin(uart_config)
`uvm_field_enum(uvm_active_passive_enum, is_tx_active, UVM_DEFAULT)
`uvm_field_enum(uvm_active_passive_enum, is_rx_active, UVM_DEFAULT)
`uvm_field_int(baud_rate_gen, UVM_DEFAULT + UVM_DEC)
`uvm_field_int(baud_rate_div, UVM_DEFAULT + UVM_DEC)
`uvm_field_int(char_length, UVM_DEFAULT)
`uvm_field_int(nbstop, UVM_DEFAULT )
`uvm_field_int(parity_en, UVM_DEFAULT)
`uvm_field_int(parity_mode, UVM_DEFAULT)
`uvm_object_utils_end
下面是uart_tx_agent中的声明句柄,但是没有实例化,
class uart_tx_agent extends uvm_agent;
// Active/Passive Agent configuration
//uvm_active_passive_enum is_active = UVM_ACTIVE;
// Configuration
uart_config cfg;
。。。。
function void uart_tx_agent::build_phase(uvm_phase phase);
super.build_phase(phase);
// Configure
if (cfg == null) begin
if (!uvm_config_db#(uart_config)::get(this, "", "cfg", cfg))
`uvm_warning("NOCONFIG", "Config not set for Tx agent, using default is_active field")
end
求大神指点 |
|