20261031
This commit is contained in:
@@ -0,0 +1,204 @@
|
||||
// ============================================================================
|
||||
// pcie_vhost_xtor.sv
|
||||
// SCE-MI transactor bridging the software Virtual Host (C++ on workstation)
|
||||
// and the PCIe Gen5 endpoint core inside ZeBu Server 4.
|
||||
//
|
||||
// Port/parameter usage matches the ZeBu-flavor SCE-MI models shipped in
|
||||
// $VCS_HOME/etc/unizfe/verilog (Q-2020.03-SP2-1-Z):
|
||||
// - SceMiClockControl provides Uclock/Ureset and takes ReadyForCclock.
|
||||
// - SceMiClockPort generates the controlled Cclock/Creset for the DUT.
|
||||
// - SceMiMessageOutPort: TransmitReady is an INPUT (producer valid),
|
||||
// ReceiveReady is an OUTPUT (port can accept the message).
|
||||
//
|
||||
// Message formats (must match sw/vhost/pcie_vhost_zebu.cpp):
|
||||
// Request message (host -> DUT), 256 bit:
|
||||
// [1:0] kind, [9:2] tag, [19:10] len_dw, [83:20] addr (64b),
|
||||
// [211:84] data (up to 4 DW), [212] last
|
||||
// Completion message (DUT -> host), 144 bit:
|
||||
// [127:0] data, [135:128] tag, [136] last, [139:137] status
|
||||
// DMA requests/completions reuse the same formats on dedicated ports.
|
||||
// IRQ event port: 8 bit, value 0x01 = MSI fired by the DUT.
|
||||
// ============================================================================
|
||||
`timescale 1ns/1ps
|
||||
|
||||
module pcie_vhost_xtor
|
||||
import pcie_pkg::*;
|
||||
(
|
||||
output logic dut_clk,
|
||||
output logic rst_n,
|
||||
output logic [3:0] link_speed,
|
||||
output logic [5:0] link_width,
|
||||
output logic link_up,
|
||||
|
||||
// DUT downstream request channel
|
||||
output logic req_valid,
|
||||
input logic req_ready,
|
||||
output tlp_kind_e req_kind,
|
||||
output logic [63:0] req_addr,
|
||||
output logic [9:0] req_len_dw,
|
||||
output logic [127:0] req_data,
|
||||
output logic req_last,
|
||||
output logic [7:0] req_tag,
|
||||
|
||||
// DUT completion channel
|
||||
input logic cpl_valid,
|
||||
output logic cpl_ready,
|
||||
input logic [127:0] cpl_data,
|
||||
input logic [7:0] cpl_tag,
|
||||
input logic cpl_last,
|
||||
input logic [2:0] cpl_status,
|
||||
|
||||
// DUT DMA request channel (EP -> host)
|
||||
input logic dma_req_valid,
|
||||
output logic dma_req_ready,
|
||||
input tlp_kind_e dma_req_kind,
|
||||
input logic [63:0] dma_req_addr,
|
||||
input logic [9:0] dma_req_len_dw,
|
||||
input logic [127:0] dma_req_data,
|
||||
input logic dma_req_last,
|
||||
input logic [7:0] dma_req_tag,
|
||||
|
||||
// DUT DMA completion channel (host -> EP)
|
||||
output logic dma_cpl_valid,
|
||||
input logic dma_cpl_ready,
|
||||
output logic [127:0] dma_cpl_data,
|
||||
output logic [7:0] dma_cpl_tag,
|
||||
output logic dma_cpl_last,
|
||||
|
||||
input logic irq_msi
|
||||
);
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
// SCE-MI clock infrastructure (ZeBu flavor)
|
||||
// ------------------------------------------------------------------
|
||||
logic uclock, ureset;
|
||||
logic dut_creset;
|
||||
|
||||
SceMiClockControl #(
|
||||
.ClockNum (1)
|
||||
) u_clock_ctrl (
|
||||
.Uclock (uclock),
|
||||
.Ureset (ureset),
|
||||
.ReadyForCclock (1'b1), // simple xtor: always ready
|
||||
.CclockEnabled (),
|
||||
.ReadyForCclockNegEdge (1'b0),
|
||||
.CclockNegEdgeEnabled ()
|
||||
);
|
||||
|
||||
SceMiClockPort #(
|
||||
.ClockNum (1),
|
||||
.RatioNumerator (1),
|
||||
.RatioDenominator (1),
|
||||
.ResetCycles (16)
|
||||
) u_clock_port (
|
||||
.Cclock (dut_clk),
|
||||
.Creset (dut_creset)
|
||||
);
|
||||
|
||||
assign rst_n = ~dut_creset; // Creset is active high
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
// Virtual link training: link comes up at Gen5 x16 shortly after reset
|
||||
// ------------------------------------------------------------------
|
||||
logic [5:0] link_cnt;
|
||||
always_ff @(posedge dut_clk or posedge dut_creset) begin
|
||||
if (dut_creset) begin
|
||||
link_cnt <= '0;
|
||||
link_up <= 1'b0;
|
||||
link_speed <= 4'd0;
|
||||
link_width <= 6'd0;
|
||||
end else if (!link_up) begin
|
||||
link_cnt <= link_cnt + 6'd1;
|
||||
if (link_cnt == 6'd31) begin
|
||||
link_up <= 1'b1;
|
||||
link_speed <= LINK_SPEED_GEN5; // 32.0 GT/s
|
||||
link_width <= LINK_WIDTH_X16; // x16
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
// SCE-MI message ports
|
||||
// ------------------------------------------------------------------
|
||||
logic req_in_xmit_ready;
|
||||
logic [255:0] req_in_msg;
|
||||
SceMiMessageInPort #(.PortWidth(256)) u_req_in (
|
||||
.ReceiveReady (req_ready && rst_n),
|
||||
.Message (req_in_msg),
|
||||
.TransmitReady (req_in_xmit_ready)
|
||||
);
|
||||
|
||||
logic [143:0] cpl_out_msg;
|
||||
SceMiMessageOutPort #(.PortWidth(144)) u_cpl_out (
|
||||
.TransmitReady (cpl_valid),
|
||||
.ReceiveReady (cpl_ready),
|
||||
.Message (cpl_out_msg)
|
||||
);
|
||||
|
||||
logic [255:0] dma_req_out_msg;
|
||||
SceMiMessageOutPort #(.PortWidth(256)) u_dma_req_out (
|
||||
.TransmitReady (dma_req_valid),
|
||||
.ReceiveReady (dma_req_ready),
|
||||
.Message (dma_req_out_msg)
|
||||
);
|
||||
|
||||
logic dma_cpl_in_xmit_ready;
|
||||
logic [143:0] dma_cpl_in_msg;
|
||||
SceMiMessageInPort #(.PortWidth(144)) u_dma_cpl_in (
|
||||
.ReceiveReady (dma_cpl_ready && rst_n),
|
||||
.Message (dma_cpl_in_msg),
|
||||
.TransmitReady (dma_cpl_in_xmit_ready)
|
||||
);
|
||||
|
||||
// MSI event: hold a sticky pending bit until the port accepts it
|
||||
logic irq_pending;
|
||||
logic irq_out_rcv_ready;
|
||||
SceMiMessageOutPort #(.PortWidth(8)) u_irq_out (
|
||||
.TransmitReady (irq_pending),
|
||||
.ReceiveReady (irq_out_rcv_ready),
|
||||
.Message (8'h01)
|
||||
);
|
||||
|
||||
always_ff @(posedge dut_clk or posedge dut_creset) begin
|
||||
if (dut_creset) begin
|
||||
irq_pending <= 1'b0;
|
||||
end else begin
|
||||
if (irq_msi) begin
|
||||
irq_pending <= 1'b1;
|
||||
end else if (irq_pending && irq_out_rcv_ready) begin
|
||||
irq_pending <= 1'b0;
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
// Host request -> DUT (one message = one TLP beat)
|
||||
// ------------------------------------------------------------------
|
||||
assign req_valid = req_in_xmit_ready && rst_n;
|
||||
assign req_kind = tlp_kind_e'(req_in_msg[1:0]);
|
||||
assign req_tag = req_in_msg[9:2];
|
||||
assign req_len_dw = req_in_msg[19:10];
|
||||
assign req_addr = req_in_msg[83:20];
|
||||
assign req_data = req_in_msg[211:84];
|
||||
assign req_last = req_in_msg[212];
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
// DUT completion -> host
|
||||
// ------------------------------------------------------------------
|
||||
assign cpl_out_msg = {4'h0, cpl_status, cpl_last, cpl_tag, cpl_data};
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
// DUT DMA request -> host memory model
|
||||
// ------------------------------------------------------------------
|
||||
assign dma_req_out_msg = {43'h0, dma_req_last, dma_req_data, dma_req_addr,
|
||||
dma_req_len_dw, dma_req_tag, 2'(dma_req_kind)};
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
// Host completion -> DUT DMA engine
|
||||
// ------------------------------------------------------------------
|
||||
assign dma_cpl_valid = dma_cpl_in_xmit_ready && rst_n;
|
||||
assign dma_cpl_data = dma_cpl_in_msg[127:0];
|
||||
assign dma_cpl_tag = dma_cpl_in_msg[135:128];
|
||||
assign dma_cpl_last = dma_cpl_in_msg[136];
|
||||
|
||||
endmodule : pcie_vhost_xtor
|
||||
Reference in New Issue
Block a user