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

Subversion Repositories keras_to_fpga

[/] [keras_to_fpga/] [trunk/] [sim/] [tests/] [tb_mnist_mlp/] [tb_top.sv] - Blame information for rev 2

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 qaztronic
//////////////////////////////////////////////////////////////////////
2
////                                                              ////
3
//// Copyright (C) 2019 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
module tb_top;
29
  import uvm_pkg::*;
30
  `include "uvm_macros.svh"
31
  import tb_top_pkg::*;
32
 
33
  // --------------------------------------------------------------------
34
  wire clk_100mhz;
35
  wire tb_clk = clk_100mhz;
36
  wire tb_rst;
37
 
38
  tb_base #(.PERIOD(10_000)) tb(clk_100mhz, tb_rst);
39
 
40
  // --------------------------------------------------------------------
41
  wire aclk = clk_100mhz;
42
  wire tb_rst_s;
43
  wire aresetn = ~tb_rst_s;
44
 
45
  sync_reset sync_reset(aclk, tb_rst, tb_rst_s);
46
 
47
  // --------------------------------------------------------------------
48
  axis_if #(.N(N), .U(U)) axis_in(.*);
49
  axis_if #(.N(N), .U(U)) axis_out(.*);
50
  axis_if #(.N(N), .U(U)) axis_stub(.*);
51
 
52
  // --------------------------------------------------------------------
53
  mnist_mlp_top #(.N(N), .DIR(DIR)) dut(.*);
54
 
55
  // // --------------------------------------------------------------------
56
  // bind dut axis_checker #(.N(N), .U(U)) dut_b(.*);
57
 
58
  // --------------------------------------------------------------------
59
  // tb_dut_config #(N, U) cfg_h = new(axis_in, axis_out);
60
  tb_dut_config #(N, U) cfg_h = new(axis_in, axis_stub);
61
  assign axis_out.tready = 1;
62
 
63
  initial
64
  begin
65
    cfg_h.init( .pixels_per_line(AW)
66
              , .lines_per_frame(AH)
67
              , .bits_per_pixel(B * 8)
68
              );
69
    uvm_config_db #(tb_dut_config #(N, U))::set(null, "*", "tb_dut_config", cfg_h);
70
    run_test("t_debug");
71
 
72
    // repeat(16) @(posedge aclk);
73
    // $stop;
74
  end
75
 
76
  // // --------------------------------------------------------------------
77
  // int in_index = 0;
78
  // real in_data;
79
 
80
  // initial
81
    // fork
82
      // forever @(negedge aclk)
83
        // if(axis_in.tvalid & axis_in.tready)
84
        // begin
85
          // in_data = $bitstoshortreal(axis_in.tdata);
86
          // $display("%s", {20{"-"}});
87
          // $display("%d | binary   |input = %h", in_index, axis_in.tdata);
88
          // $display("%d | IEEE 754 |input = %9.7F", in_index, in_data);
89
          // if(axis_in.tlast)
90
          // begin
91
            // $display("%s", {20{"+"}});
92
            // in_index++;
93
          // end
94
        // end
95
    // join_none
96
 
97
  // --------------------------------------------------------------------
98
  int out_index = 0;
99
  real out_data;
100
 
101
  initial
102
    fork
103
      forever @(negedge aclk)
104
        if(axis_out.tvalid & axis_out.tready)
105
        begin
106
          out_data = $bitstoshortreal(axis_out.tdata);
107
          $display("%s", {20{"-"}});
108
          $display("%d | binary   |result = %h", out_index, axis_out.tdata);
109
          $display("%d | IEEE 754 |result = %9.7F", out_index, out_data);
110
          out_index++;
111
        end
112
    join_none
113
 
114
// --------------------------------------------------------------------
115
endmodule

powered by: WebSVN 2.1.0

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