Synopsys PCIe VIP(1) 介绍和类说明
Synopsys PCIe VIP 是基于 UVM 的协议验证方案支持 PCIe 2.1至6.0 规范可配置为 Root Complex 或 Endpoint 模式并完整实现了事务层、数据链路层和物理层。VIP 提供灵活的配置接口、状态监控和序列控制能力支持多通道应用传输。本文围绕该 VIP 的环境类展开简要介绍以下五个核心组件svt_pcie_device_agent设备顶层类对应 RC/EP 设备发起 TLP/DLLP 和响应接收。svt_pcie_device_configuration配置顶层类包含各子层配置参数并控制 VIP 的工作模式。svt_pcie_device_status状态顶层类记录设备各层的传输计数和链路状态信息。svt_pcie_driver_app_transaction传输类定义传输的数值、类型、地址等关键字段。svt_pcie_device_virtual_sequencer序列器顶层类用于配置状态、发送 TLP/DLLP 。通过对这些类的梳理可以快速理解Synopsys PCIe VIP的架构层次为后续验证环境搭建和测试开发奠定基础。设备类svt_pcie_device_agentsvt_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_appdriver_app 用于发起 TLP 传输可以将接口和环境进行连接图中可以看到 driver_app 包含发送 TLP 和接收 Cpl、CplD 两个通路接收结束处还有 callback 点。通常和 driver_app 交互即可实现一般传输功能一些错误注入等特殊场景才会用到下层。svt_pcie_target_apptarget_app 用于应答和 driver_app 平级。图中可以看到 target_app 同样包含发送应答 Clp、ClpD 和接收存储、IO、配置类型 TLP 两个通路其实在发之前和收之后有两处 callback 点只不过图中没标出。svt_pcie_tlsvt_pcie_tl 对应协议的 TL 层。也可以不使用 driver_app 层定义用户 application id需要 ≥0x20前面数值 VIP 自己会使用直接给本层发送 svt_pcie_tlp 包传输然后从 rx_tlp_peek_port 端口接收 svt_pcie_tlp 包传输。svt_pcie_dlsvt_pcie_dl 对应协议的DL层可以传递来自 svt_pcie_tl 的 TLP 包同时添加序号和 LRCR 也可以直接传递来自端口的 DLLP 包接收通道为逆处理过程同样包含 port 和 callback 点。svt_pcie_plsvt_pcie_pl 对应协议的PL层在本层会实现建链TS1、TS1 等有序集生成同时传递来自 svt_pcie_dl 的 TLP、DLLP 包。配置类和 pcie_device_agent 对应device_configuration 也包含 driver、 requester 和 target 子类用于事务的配置此外还包含协议的 TL、DL和PL 层配置。svt_pcie_device_configuration |--- driver_cfg[$] (typesvt_pcie_driver_app_configuration) |--- requester_app (typesvt_pcie_requester_app_configuration) |--- target_cfg[$] (typesvt_pcie_target_app_configuration) |--- pcie_cfg (typesvt_pcie_configuration) | |--- tl_cfg (typesvt_pcie_tl_configuration) |--- dl_cfg (typesvt_pcie_dl_configuration) |--- pl_cfg (typesvt_pcie_pl_configuration)svt_pcie_device_configurationsvt_pcie_device_configuration 参数包括例化模式配置下篇文章会说明unified VIP 定义。unified_if值为null指示agent对应single instance model非null指示对应unified model后面小节会介绍unified。unified_vip1指示unified VIP模式0指示single instantiation模式svt_pcie_vif unified_if; bit unified_vip 1b0;参数还包括使能、RC/EP 和协议版本等基本配置。此外 VIP 包含 HDL module需要通过 model_instance_scope 指定 module 的 hierarchical 路径。bit is_active 1; string model_instance_scope; rand bit device_is_root 1b1; 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_configurationsvt_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.logenable_symbol_logging 1b1; symbol_log_filename symbol.log;参数还包括使能 fsdb 存储 trans 信息可以在 verdi 的 protocol debug mode查看每一包传输。使能还需要再vcs编译步骤defineSVT_PCIE_INCLUDE_AC_PA。bit enable_tl_xml_gen 1b0; bit enable_dl_xml_gen 1b0; bit enable_pl_xml_gen 1b0; svt_xml_writer::format_type_enum pa_format_type;svt_pcie_pl_configurationsvt_pcie_pl_configuration 参数包括链路信息还有很多链路时序参数不再列举。link_widthlink的lane的数量。rand int unsigned link_number 0; int unsigned link_width 1;还支持跳过部分建链步骤skip_polling_active 为略过 Polling.Active 态本应发送1024个TS1skip_initial_link_training 为略过整个建链过程复位后直接 L0 态。rand bit skip_initial_link_trainingSVT_PCIE_SKIP_INITIAL_LINK_TRAINING_DEFAULT; rand bit skip_polling_active SVT_PCIE_SKIP_POLLING_ACTIVE_DEFAULT;状态类svt_pcie_device_statussvt_pcie_device_status 同样和 pcie_device_agent 对应除子类外无其他变量tl/dl/pl 状态类常会用到包含各种传输的计数值此外 pl 子类中还有链路状态。svt_pcie_device_status |--- driver_cfg [$] (typesvt_pcie_driver_app_status) |--- io_target_status (typesvt_pcie_io_target_status) |--- mem_target_status (typesvt_pcie_mem_target_status) |--- requester_app (typesvt_pcie_requester_app_status) |--- target_status [$] (typesvt_pcie_target_app_status) |--- pcie_status (typesvt_pcie_status) | |--- tl_status (typesvt_pcie_tl_status) |--- dl_status (typesvt_pcie_dl_status) |--- pl_status (typesvt_pcie_pl_status)sequencer类svt_pcie_device_virtual_sequencersvt_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。blockdriver_app 传输队列的 block 控制配置为 1 时当前传输完成 driver 才会传输下一数据进队列。其余参数可以参照协议 TLP 定义不再说明。rand bit [31:0] payload[]; rand transaction_type_enum transaction_type MEM_RD; rand bit [63:0] address 64h0; rand bit [9:0] length 10h0; rand bit [3:0] first_dw_be 4b0000; rand bit [3:0] last_dw_be 4b1111; rand bit [2:0] traffic_class h0; rand bit [1:0] address_translation h0; rand bit ep 1b0; rand bit block 1b0;interfacesvt_pcie_vifphy_interface_type对应 PIPE、SERDES、PMA、APP 三种接口模式。device_is_root1 表示 RC0 表示 EP 设备。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();