pcissors,-Synopsys PCIe VIP(1) 环境类介绍 - rand bit ep = 1'
设备类
svt_pcie_device_agent
svt_pcie_device_agent作为VIP的顶层类,对应1个RC或EP。其中driver_app用于发起TLP传输,requester_app用于大量memory访问传输,target_app用于接收响应TLP包,再下层svt_pcie_agent又包含对应协议TL、DL、PL层的子类。
VIP支持同时进行多组应用传输,所以driver_app和target_app为数组形式,VIP定义数组索引为application id。
VIP doc目录中pcie_layers.pdf有详细层级数据流图包含analysis_port和callback点,下面逐层说明。
svt_pcie_driver_app
driver_app用于发起TLP传输,可以将接口和环境进行连接,图中可以看到传输结束处还有callback点。通常和本层交互即可实现一般传输功能,可能一些错误注入等特殊场景才会用到下层。
svt_pcie_target_app
target用于应答,和driver_app平级。其实在tx之前和rx之后有两处callback点,但图中没标。
svt_pcie_tl
对应协议的TL层。也可以不使用driver_app层,定义用户application id(需要≥0x20),直接给本层发送svt_pcie_tlp包传输,然后从rx_tlp_peek_port端口接收svt_pcie_tlp包传输。
svt_pcie_dl
对应协议的DL层。
svt_pcie_pl
对应协议的PL层。
配置类
和pcie_device_agent对应,device_configuration也包含driver、requester和target子类,用于事务的配置;此外还包含协议的TL、DL和PL层配置。
svt_pcie_device_configuration
|--->driver_cfg[$] (type=svt_pcie_driver_app_configuration)
|--->requester_app (type=svt_pcie_requester_app_configuration)
|--->target_cfg[$] (type=svt_pcie_target_app_configuration) 拼多多帮助力入口
|--->pcie_cfg (type=svt_pcie_configuration)
|
|--->tl_cfg (type=svt_pcie_tl_configuration)
|--->dl_cfg (type=svt_pcie_dl_configuration)
|--->pl_cfg (type=svt_pcie_pl_configuration)
svt_pcie_device_configuration
参数包括例化模式配置,后续会说明unified VIP模式。
unified_if:值为null指示agent对应single instance model,非null指示对应unified model,后面小节会介绍unified。
unified_vip:1指示unified VIP模式,0指示single instantiation模式
svt_pcie_vif unified_if;
bit unified_vip = 1'b0;
参数包括使能、RC/EP和协议版本等基本配置。此外VIP包含HDL module,需要通过model_instance_scope指定module的hierarchical路径。
bit is_active = 1;
string model_instance_scope;
rand bit device_is_root = 1'b1;
rand pcie_spec_ver_enum pcie_spec_ver = PCIE_SPEC_VER_2_1;
rand pipe_spec_ver_enum pipe_spec_ver = PIPE_SPEC_VER_2;
svt_pcie_configuration
和pcie_agent对应,包含TL、DL、PL层子类。
rand svt_pcie_tl_configuration tl_cfg;
rand svt_pcie_dl_configuration dl_cfg;
rand svt_pcie_pl_configuration pl_cfg;
rand svt_pcie_mpl_phy_configuration mpl_cfg;
参数包括使能传输和symbol log打印。
enable_transaction_logging = 1;
transaction_log_filename = "pcie_trans.log"
enable_symbol_logging = 1'b1;
symbol_log_filename = "symbol.log";
参数包括使能fsdb存储trans信息,可以在verdi的protocol debug mode查看每一包传输。使能还需要再vcs编译步骤+define+SVT_PCIE_INCLUDE_AC_PA。
bit enable_tl_xml_gen = 1'b0;
bit enable_dl_xml_gen = 1'b0;
bit enable_pl_xml_gen = 1'b0;
svt_xml_writer::format_type_enum pa_format_type;
svt_pcie_pl_configuration
参数包括链路信息,还有很多链路时序参数,不再列举。
link_width:link的lane的数量。
rand int unsigned link_number = 0;
int unsigned link_width = 1;
还支持跳过部分建链步骤,skip_polling_active为略过Polling.Active态(本应发送1024个TS1);skip_initial_link_training为略过整个建链过程,复位后直接L0态。
rand bit skip_initial_link_training=SVT_PCIE_SKIP_INITIAL_LINK_TRAINING_DEFAULT;
rand bit skip_polling_active = SVT_PCIE_SKIP_POLLING_ACTIVE_DEFAULT;
状态类
svt_pcie_device_status
状态类同样和pcie_device_agent对应,svt_pcie_device_status除子类外无其他变量,tl/dl/pl状态类常会用到,包含各种传输的计数值,此外pl子类中还有链路状态。
svt_pcie_device_status
|--->driver_cfg [$] (type=svt_pcie_driver_app_status)
|--->io_target_status (type=svt_pcie_io_target_status)
|--->mem_target_status (type=svt_pcie_mem_target_status)
|--->requester_app (type=svt_pcie_requester_app_status)
|--->target_status [$] (type=svt_pcie_target_app_status)
|--->pcie_status (type=svt_pcie_status)
|
|--->tl_status (type=svt_pcie_tl_status)
|--->dl_status (type=svt_pcie_dl_status)
|--->pl_status (type=svt_pcie_pl_status)
sequencer类
svt_pcie_device_virtual_sequencer
svt_pcie_device_virtual_sequencer类同样和svt_pcie_device_agent对应。
带service的sequencer一般用于配置和状态控制,不带的一般用于TLP/DLLP传输
此外还有svt_pcie_device_system_virtual_sequencer类,包含2个svt_pcie_device_virtual_sequencer和1个svt_pcie_global_shadow_service_sequencer成员,对应1个RC、1个EP和1个shadow memory的典型系统。
传输类
svt_pcie_driver_app_transaction
参数包括传输类型和TLP包信息。
payload:传输的数据,对于传输类型IO_WR、CFG_WR长度为1。
block:driver_app传输队列的block控制,配置为1时,当前传输完成driver才会传输下一数据进队列。
其余参数可以参照协议TLP定义,不再说明。
rand bit [31:0] payload[];
rand transaction_type_enum transaction_type = MEM_RD;
rand bit [63:0] address = 64'h0;
rand bit [9:0] length = 10'h0;
rand bit [3:0] first_dw_be = 4'b0000;
rand bit [3:0] last_dw_be = 4'b1111;
rand bit [2:0] traffic_class = 'h0;
rand bit [1:0] address_translation = 'h0;
rand bit ep = 1'b0;
rand bit block = 1'b0;
interface
svt_pcie_vif
phy_interface_type:PIPE、SERDES、PMA、APP
device_is_root:1表示RC
reg [7:0] link_id;
reg [3:0] port_id;
real pcie_spec_ver;
real pipe_spec_ver;
reg [5:0] num_physical_lanes;
reg [5:0] num_pma_interface_bits;
reg [5:0] num_pipe_interface_bits;
reg [3:0] phy_interface_type;
reg device_is_root;
svt_pcie_serdes_if ser_if(clkreq_n, wake_n);
svt_pcie_pma_if pma_if(clkreq_n, wake_n);
svt_pcie_pipe_if pipe_if(clkreq_n, wake_n);
svt_pcie_app_if app_if();
svt_pcie_ext_clk_if ext_clk_if();