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

Subversion Repositories xilinx_virtex_fp_library

[/] [xilinx_virtex_fp_library/] [trunk/] [GeneralPrecMAF/] [tb_adder.v] - Blame information for rev 19

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 19 constantin
`timescale 1ns / 1ps
2
//////////////////////////////////////////////////////////////////////////////////
3
// Company:     UPT
4
// Engineer:    Constantina-Elena Gavriliu
5
// 
6
// Create Date:    16:09:49 02/07/2014 
7
// Design Name: 
8
// Module Name:    tb_adder 
9
// Project Name: 
10
// Target Devices: 
11
// Tool versions: 
12
// Description: TestBench
13
//                              //do not take into consideration cases for which the operation generates a NaN or Infinity exception (with corresponding sign) when initial "special cases" are not such exceptions
14
// Dependencies:        SinglePathFPAdder
15
//
16
// Revision: 
17
// Revision 0.01 - File Created
18
// Additional Comments: 
19
//
20
//////////////////////////////////////////////////////////////////////////////////
21
 
22
`define input_file "test_add.input"
23
 
24
module tb_adder;
25
 
26
        reg clk, rst, start;
27
        reg [34:0] a_number_i_next;
28
        reg [34:0] b_number_i_next;
29
        reg [34:0] c_number_i_next;
30
        reg unnecessary;
31
        reg [34:0] result_next;
32
        wire [34:0] resulting_number_o;
33
        integer f;
34
        integer i;
35
        real correct_cases, incorrect_cases;
36
        integer statusI, statusJ;
37
 
38
        wire correct;
39
 
40
        initial
41
                begin
42
                        i = 0;
43
                        correct_cases = 0;
44
                        incorrect_cases = 0;
45
                        clk = 1;
46
                        rst = 0;
47
                        f = $fopen(`input_file, "r");
48
                        while (!$feof(f))
49
                                begin
50
                                        a_number_i_next = 35'b01001111111000000000000000000000000;
51
                                        statusI = $fscanf(f,"%35b %35b\n",b_number_i_next,c_number_i_next);
52
                                        statusJ = $fscanf(f,"%1b %35b\n",unnecessary,result_next);
53
                                        i = i + 1;
54
                                        @(posedge clk);
55
                                        @(posedge clk);
56
                                        @(posedge clk);
57
                                        if (correct)
58
                                                correct_cases = correct_cases + 1;
59
                                        else
60
                                                begin
61
                                                        incorrect_cases = incorrect_cases + 1;
62
                                                        $display("Error occured at index #%d\n",i);
63
                                                end
64
                        end
65
                        $display("Correct cases: %d \nIncorrect cases: %d", correct_cases, incorrect_cases);
66
                        $display("\tPercentage = %f ", correct_cases/200.07);
67
                        $stop();
68
      end
69
 
70
        assign correct = (result_next[31:0] == resulting_number_o[31:0] || result_next[31:0] == 32'd0)? 1 : 0;
71
 
72
        always #2       clk = ~clk;
73
 
74
        Multiply_Accumulate #(
75
                                                .size_mantissa  (25))
76
                Multiply_Accumulate_instance (
77
                                                                                .a_number_i         (a_number_i_next    ),
78
                                                                                .b_number_i         (b_number_i_next    ),
79
                                                                                .c_number_i         (c_number_i_next    ),
80
                                                                                .sub                (1'b0               ),
81
                                                                                .resulting_number_o     (resulting_number_o ));
82
endmodule

powered by: WebSVN 2.1.0

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