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

Subversion Repositories keras_to_fpga

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

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 qaztronic
//////////////////////////////////////////////////////////////////////
2
////                                                              ////
3
//// Copyright (C) 2018 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
 
30
  // --------------------------------------------------------------------
31
  wire clk_100mhz;
32
  wire tb_clk = clk_100mhz;
33
  wire tb_rst;
34
 
35
  tb_base #(.PERIOD(10_000)) tb(clk_100mhz, tb_rst);
36
 
37
  // --------------------------------------------------------------------
38
  wire clk = clk_100mhz;
39
  wire reset = tb_rst;
40
  wire aclk = clk;
41
  wire aresetn = ~reset;
42
 
43
  // --------------------------------------------------------------------
44
  logic        accumulate = 1; // accumulate.accumulate
45
  wire [1:0]  aclr = {reset, reset};       //       aclr.aclr
46
  logic [31:0] ay = $shortrealtobits(5.5);         //         ay.ay
47
  logic [31:0] az = $shortrealtobits(2.0);         //         az.az
48
  logic        ena = 1;        //        ena.ena
49
 
50
  // --------------------------------------------------------------------
51
  wire [31:0] mac_result;      //     result.result
52
 
53
  mac mac(.result(mac_result), .*);
54
 
55
  // --------------------------------------------------------------------
56
  wire [31:0] subt_result;      //     result.result
57
  wire [31:0] ax = az;         //         ax.ax
58
 
59
  fp_adder subt(.result(subt_result), .*);
60
 
61
  // --------------------------------------------------------------------
62
  shortreal mac_result_w;
63
 
64
  always @(mac_result)
65
  begin
66
    mac_result_w = $bitstoshortreal(mac_result);
67
    $display("^^^ %16.t | mac_result | %f\n", $time, mac_result_w);
68
  end
69
 
70
  // --------------------------------------------------------------------
71
  shortreal subt_result_w;
72
 
73
  always @(subt_result)
74
  begin
75
    subt_result_w = $bitstoshortreal(subt_result);
76
    $display("^^^ %16.t | subt_result | %f\n", $time, subt_result_w);
77
  end
78
 
79
  // --------------------------------------------------------------------
80
  initial
81
  begin
82
    $display("^^^ %16.t | Testbench begun.\n", $time);
83
    wait(~reset)
84
 
85
    repeat(16) @(posedge clk);
86
    ay = $shortrealtobits(-7563.547);
87
    az = $shortrealtobits(-10.0);
88
 
89
    repeat(16) @(posedge clk);
90
    ay = $shortrealtobits(436.55);
91
    az = $shortrealtobits(0.0);
92
 
93
    repeat(16) @(posedge clk);
94
    ay = $shortrealtobits(0.0);
95
    az = $shortrealtobits(0.0);
96
 
97
    repeat(16) @(posedge clk);
98
    ay = $shortrealtobits(-4.1212);
99
    az = $shortrealtobits(1.111);
100
 
101
    repeat(16) @(posedge clk);
102
    accumulate = 0;
103
 
104
    repeat(16) @(posedge clk);
105
    ay = $shortrealtobits(115444.65456);
106
    az = $shortrealtobits(654.5425);
107
 
108
    repeat(16) @(posedge clk);
109
    ay = $shortrealtobits(436.55);
110
    az = $shortrealtobits(0.0);
111
 
112
    repeat(16) @(posedge clk);
113
    ay = $shortrealtobits(0.0);
114
    az = $shortrealtobits(0.0);
115
 
116
    repeat(16) @(posedge clk);
117
    ay = $shortrealtobits(10.0);
118
    az = $shortrealtobits(33.333);
119
 
120
    repeat(16) @(posedge clk);
121
    ay = $shortrealtobits(-4.1212);
122
    az = $shortrealtobits(1.111);
123
 
124
    repeat(16) @(posedge clk);
125
    $display("^^^ %16.t | Testbench done.\n", $time);
126
    $stop();
127
  end
128
 
129
// --------------------------------------------------------------------
130
endmodule

powered by: WebSVN 2.1.0

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