CHI协议里link的四个状态是什么
时间: 2023-12-12 17:05:00 浏览: 33
CHI协议中,link的四个状态分别是:
1. 未初始化(Not Initialized):CHI协议规定,link在复位后需要先进入未初始化状态,这时link处于空闲状态,没有连接任何设备。
2. 连接(Connected):link成功连接了主设备和从设备,处于连接状态。此时,link可以传输数据,但是不能发送请求或接收响应。
3. 激活(Active):连接状态下的link经过一系列协商和配置,成功进入激活状态。此时,link可以发送请求和接收响应,并且按照预定的协议规则进行数据交换。
4. 闲置(Idle):当link完成一次数据交换后,会进入闲置状态。此时,link处于空闲状态,可以接收新的请求或响应。
相关问题
用UVM写一个 CHI协议中LINK layer的driver
下面是一个 CHI 协议中 LINK layer 的 driver 的 UVM 代码示例:
```systemverilog
class chi_link_driver extends uvm_driver #(chi_packet);
`uvm_component_utils(chi_link_driver)
virtual function void build_phase(uvm_phase phase);
super.build_phase(phase);
// Get the virtual interface handle to the DUT
if (!uvm_config_db #(virtual chi_if)::get(this, "", "chi_if", m_if))
`uvm_fatal("NO_IF", "Virtual interface not defined for chi_link_driver")
// Create and configure the sequence item queue
m_seq_item_q = new("seq_item_q", this);
m_seq_item_q.default_priority = 100;
endfunction
virtual task run_phase(uvm_phase phase);
chi_packet pkt;
while (1) begin
// Wait for the next sequence item to be available
@(m_seq_item_q.get_with_priority(pkt))
// Send the CHI packet to the DUT using the virtual interface
m_if.write(pkt);
end
endtask
endclass
```
在上面的代码中,`chi_packet` 是一个定义了 CHI packet 的 UVM sequence item 类。`build_phase` 函数获取了指向 DUT 的虚拟接口 `m_if`,并创建了一个名为 `m_seq_item_q` 的 sequence item 队列。`run_phase` 函数使用 `m_seq_item_q` 从队列中获取下一个 sequence item 并将其发送到 DUT。这个 driver 只负责发送 CHI packet 到 DUT,接收 CHI packet 的逻辑需要在 monitor 中实现。
用UVM写一个 CHI协议中LINK layer的tx driver
下面是一个 CHI 协议中 LINK layer 的 tx driver 的 UVM 代码示例:
```systemverilog
class chi_link_tx_driver extends uvm_driver #(chi_packet);
`uvm_component_utils(chi_link_tx_driver)
virtual function void build_phase(uvm_phase phase);
super.build_phase(phase);
// Get the virtual interface handle to the DUT
if (!uvm_config_db #(virtual chi_if)::get(this, "", "chi_if", m_if))
`uvm_fatal("NO_IF", "Virtual interface not defined for chi_link_tx_driver")
// Create and configure the sequence item queue
m_seq_item_q = new("seq_item_q", this);
m_seq_item_q.default_priority = 100;
endfunction
virtual task run_phase(uvm_phase phase);
chi_packet pkt;
while (1) begin
// Wait for the next sequence item to be available
@(m_seq_item_q.get_with_priority(pkt))
// Set the tx packet type and data
m_if.tx_pkt_type = pkt.type;
m_if.tx_pkt_data = pkt.data;
// Send the CHI packet to the DUT using the virtual interface
m_if.tx_pkt_valid = 1;
repeat (10) @(posedge m_if.clk);
m_if.tx_pkt_valid = 0;
end
endtask
endclass
```
在上面的代码中,`chi_packet` 是一个定义了 CHI packet 的 UVM sequence item 类。`build_phase` 函数获取了指向 DUT 的虚拟接口 `m_if`,并创建了一个名为 `m_seq_item_q` 的 sequence item 队列。`run_phase` 函数使用 `m_seq_item_q` 从队列中获取下一个 sequence item 并将其发送到 DUT。
在发送 CHI packet 之前,该 driver 需要将 packet 的类型和数据传递给 DUT,这里使用了虚拟接口中的两个信号 `tx_pkt_type` 和 `tx_pkt_data`。然后,该 driver 设置 `tx_pkt_valid` 信号为 1,表示 CHI packet 准备就绪。为了确保 DUT 能够接收到整个 packet,这里使用了一个简单的 `repeat` 循环来等待一定的时钟周期,然后将 `tx_pkt_valid` 信号置为 0,表示传输完成。