OpenCores
URL https://opencores.org/ocsvn/qaz_libs/qaz_libs/trunk

Subversion Repositories qaz_libs

[/] [qaz_libs/] [trunk/] [PCIe/] [sim/] [tests/] [tb_chnl_convolution/] [tb_chnl_convolution.sv] - Blame information for rev 32

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 32 qaztronic
//////////////////////////////////////////////////////////////////////
2
////                                                              ////
3
//// Copyright (C) 2017 Authors and OPENCORES.ORG                 ////
4
////                                                              ////
5
//// This source file may be used and distributed without         ////
6
//// restriction provided that this copyright statement is not    ////
7
//// removed from the file and that any derivative work contains  ////
8
//// the original copyright notice and the associated disclaimer. ////
9
////                                                              ////
10
//// This source file is free software; you can redistribute it   ////
11
//// and/or modify it under the terms of the GNU Lesser General   ////
12
//// Public License as published by the Free Software Foundation; ////
13
//// either version 2.1 of the License, or (at your option) any   ////
14
//// later version.                                               ////
15
////                                                              ////
16
//// This source is distributed in the hope that it will be       ////
17
//// useful, but WITHOUT ANY WARRANTY; without even the implied   ////
18
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      ////
19
//// PURPOSE.  See the GNU Lesser General Public License for more ////
20
//// details.                                                     ////
21
////                                                              ////
22
//// You should have received a copy of the GNU Lesser General    ////
23
//// Public License along with this source; if not, download it   ////
24
//// from http://www.opencores.org/lgpl.shtml                     ////
25
////                                                              ////
26
//////////////////////////////////////////////////////////////////////
27
 
28
 
29
module tb_top();
30
 
31
  // --------------------------------------------------------------------
32
  // test bench clock & reset
33
  wire clk_100mhz;
34
  wire tb_clk = clk_100mhz;
35
  wire tb_rst;
36
 
37
  tb_base #(.PERIOD(10_000)) tb(clk_100mhz, tb_rst);
38
 
39
 
40
  // --------------------------------------------------------------------
41
  //
42
  wire tb_rst_s;
43
  wire aclk     = tb_clk;
44
  wire aresetn  = ~tb_rst_s;
45
 
46
  sync_reset sync_reset_i(tb_clk, tb_rst, tb_rst_s);
47
 
48
 
49
  // --------------------------------------------------------------------
50
  //
51
  import tb_chnl_convolution_pkg::*;
52
 
53
 
54
  // --------------------------------------------------------------------
55
  //
56
  riffa_chnl_if #(.N(N)) chnl_bus();
57
 
58
 
59
  // --------------------------------------------------------------------
60
  //
61
        wire CLK = tb_clk;
62
        wire RST = tb_rst_s;
63
  assign chnl_bus.rx_clk = CLK;
64
  assign chnl_bus.tx_clk = CLK;
65
 
66
  chnl_convolution #(.C_PCI_DATA_WIDTH(C_PCI_DATA_WIDTH))
67
    dut
68
    (
69
      .CHNL_RX_CLK(chnl_bus.rx_clk),
70
      .CHNL_RX(chnl_bus.rx),
71
      .CHNL_RX_ACK(chnl_bus.rx_ack),
72
      .CHNL_RX_LAST(chnl_bus.rx_last),
73
      .CHNL_RX_LEN(chnl_bus.rx_len),
74
      .CHNL_RX_OFF(chnl_bus.rx_off),
75
      .CHNL_RX_DATA(chnl_bus.rx_data),
76
      .CHNL_RX_DATA_VALID(chnl_bus.rx_data_valid),
77
      .CHNL_RX_DATA_REN(chnl_bus.rx_data_ren),
78
      .CHNL_TX_CLK(chnl_bus.tx_clk),
79
      .CHNL_TX(chnl_bus.tx),
80
      .CHNL_TX_ACK(chnl_bus.tx_ack),
81
      .CHNL_TX_LAST(chnl_bus.tx_last),
82
      .CHNL_TX_LEN(chnl_bus.tx_len),
83
      .CHNL_TX_OFF(chnl_bus.tx_off),
84
      .CHNL_TX_DATA(chnl_bus.tx_data),
85
      .CHNL_TX_DATA_VALID(chnl_bus.tx_data_valid),
86
      .CHNL_TX_DATA_REN(chnl_bus.tx_data_ren),
87
      .*
88
    );
89
 
90
 
91
  // --------------------------------------------------------------------
92
  //
93
  tb_chnl_convolution_class #(.N(N)) a_h;
94
 
95
  initial
96
    a_h = new(chnl_bus);
97
 
98
 
99
  // --------------------------------------------------------------------
100
  // sim models
101
  //  |   |   |   |   |   |   |   |   |   |   |   |   |   |   |   |   |
102
  // \|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/
103
  //  '   '   '   '   '   '   '   '   '   '   '   '   '   '   '   '   '
104
 
105
  // --------------------------------------------------------------------
106
  //
107
  int rx_count = 0;
108
  wire rx_en = chnl_bus.rx_data_valid & chnl_bus.rx_data_ren;
109
 
110
  always_ff @(posedge chnl_bus.tx_clk)
111
    if(chnl_bus.rx)
112
    begin
113
      if(rx_en)
114
        rx_count++;
115
    end
116
    else
117
      rx_count = 0;
118
 
119
 
120
  // --------------------------------------------------------------------
121
  //
122
  int tx_count = 0;
123
  wire tx_en = chnl_bus.tx_data_valid & chnl_bus.tx_data_ren;
124
 
125
  always_ff @(posedge chnl_bus.tx_clk)
126
    if(chnl_bus.tx)
127
    begin
128
      if(tx_en)
129
        tx_count++;
130
    end
131
    else
132
      tx_count = 0;
133
 
134
 
135
 
136
  //  '   '   '   '   '   '   '   '   '   '   '   '   '   '   '   '   '
137
  // /|\-/|\-/|\-/|\-/|\-/|\-/|\-/|\-/|\-/|\-/|\-/|\-/|\-/|\-/|\-/|\-/|\
138
  //  |   |   |   |   |   |   |   |   |   |   |   |   |   |   |   |   |
139
  // sim models
140
  // --------------------------------------------------------------------
141
 
142
 
143
 
144
  // --------------------------------------------------------------------
145
  // test
146
  the_test test( tb_clk, tb_rst );
147
 
148
  initial
149
    begin
150
 
151
      test.run_the_test();
152
 
153
      $display("^^^---------------------------------");
154
      $display("^^^ %16.t | Testbench done.", $time);
155
      $display("^^^---------------------------------");
156
 
157
      $display("^^^---------------------------------");
158
 
159
      $stop();
160
 
161
    end
162
 
163
endmodule
164
 
165
 
166
 

powered by: WebSVN 2.1.0

© copyright 1999-2020 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.