File: pcie_dma_ctrl_tb.v

package info (click to toggle)
uhd 3.13.1.0-3
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 207,120 kB
  • sloc: cpp: 167,245; ansic: 86,841; vhdl: 53,420; python: 40,839; xml: 13,167; tcl: 5,688; makefile: 2,167; sh: 1,719; pascal: 230; csh: 94; asm: 20; perl: 11
file content (92 lines) | stat: -rw-r--r-- 2,622 bytes parent folder | download | duplicates (10)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
//
// Copyright 2013 Ettus Research LLC
// Copyright 2018 Ettus Research, a National Instruments Company
//
// SPDX-License-Identifier: LGPL-3.0-or-later
//


`timescale 500ps/1ps

module pcie_dma_ctrl_tb();
    reg clk    = 0;
    reg reset  = 1;

    always #10 clk = ~clk;

    initial begin
        #100 reset = 0;
        #200000;
        $finish;
    end
   
    function [63:0] iop2_msg_write;
        input [19:0]    address;
        input [31:0]    data;
        input           half_wd;
    begin
        //            {rd_response, wr_request, rd_request, half_word, 8'h00, address, data};
        iop2_msg_write = {1'b0,        1'b1,       1'b0,       half_wd,   8'h00, address, data};
    end
    endfunction // iop2_msg_write

    function [63:0] iop2_msg_read;
        input [19:0]    address;
        input           half_wd;
    begin
        //            {rd_response, wr_request, rd_request, half_word, 8'h00, address, data};
        iop2_msg_read = {1'b0,        1'b0,       1'b1,       half_wd,   8'h00, address, 32'h0};
    end
    endfunction // iop2_msg_read

    wire [3:0]      clear;
    wire [63:0]     frame_size;
    reg [3:0]       pkt_stb = 0;
    reg [3:0]       samp_stb = 0;
    reg [3:0]       error = 0;
    reg [7:0]       rtr_sid = 4;
    wire [3:0]      rtr_dst;

    reg [63:0]  regi_tdata;
    reg         regi_tvalid;
    wire        regi_tready;
    wire [63:0] rego_tdata;
    wire        rego_tvalid;
    reg         rego_tready;
    reg [31:0]  rego_payload;
    
    always @(posedge clk)
        if (rego_tdata[63] & rego_tvalid & rego_tready)
            rego_payload <= rego_tdata[31:0];

    initial begin
        regi_tvalid <= 0;
        rego_tready <= 0;
        while (reset) @(posedge clk);
    
        rego_tready <= 1;
        @(posedge clk);
        
        regi_tdata <= iop2_msg_write(20'h304, 32'hA, 0);
        regi_tvalid <= 1;
        @(posedge clk);
        while (~regi_tready) @(posedge clk);
        regi_tvalid <= 0;
        @(posedge clk);
    
    end // initial begin
    
    pcie_dma_ctrl #(
        .NUM_STREAMS(4), .FRAME_SIZE_W(16),
        .REG_BASE_ADDR(20'h00200), .ENABLE_ROUTER(1),
        .ROUTER_SID_W(8), .ROUTER_DST_W(4)
    ) dut (
        .clk(clk), .reset(reset),
        .regi_tdata(regi_tdata), .regi_tvalid(regi_tvalid), .regi_tready(regi_tready),
        .rego_tdata(rego_tdata), .rego_tvalid(rego_tvalid), .rego_tready(rego_tready),
        .set_clear(clear), .set_frame_size(frame_size), .sample_stb(samp_stb), .packet_stb(pkt_stb), 
        .stream_err(error), .rtr_sid(rtr_sid), .rtr_dst(rtr_dst)
    );
    

endmodule