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/] [DualPathFPAdder/] [tb_adder.v] - Blame information for rev 18

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 18 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:        DualPathFPAdder
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 unnecessary;
30
        reg [34:0] result_next;
31
        wire [34:0] resulting_number_o;
32
        integer f;
33
        integer i;
34
        real correct_cases, incorrect_cases;
35
        integer statusI, statusJ;
36
 
37
        wire correct;
38
 
39
        initial
40
                begin
41
                        i = 0;
42
                        correct_cases = 0;
43
                        incorrect_cases = 0;
44
                        clk = 1;
45
                        rst = 0;
46
                        f = $fopen(`input_file, "r");
47
                        while (!$feof(f))
48
                                begin
49
                                        statusI = $fscanf(f,"%35b %35b\n",a_number_i_next,b_number_i_next);
50
                                        statusJ = $fscanf(f,"%1b %35b\n",unnecessary,result_next);
51
                                        i = i + 1;
52
                                        @(posedge clk);
53
                                        @(posedge clk);
54
                                        @(posedge clk);
55
                                        if (correct)
56
                                                correct_cases = correct_cases + 1;
57
                                        else
58
                                                begin
59
                                                        incorrect_cases = incorrect_cases + 1;
60
                                                        $display("Error occured at index #%d \n \tExpDiff = %d\n",i, a_number_i_next[31:24] - b_number_i_next[31:24]);
61
                                                end
62
                        end
63
                        $display("Correct cases: %d \nIncorrect cases: %d", correct_cases, incorrect_cases);
64
                        $display("\tPercentage = %f ", correct_cases/200.07);
65
                        $stop();
66
      end
67
 
68
        assign correct = (result_next[31:0] == resulting_number_o[31:0] || result_next[31:0] == 32'd0)? 1 : 0;
69
 
70
        always #2       clk = ~clk;
71
 
72
        DualPathFPAdder #(
73
                                                .size_mantissa  (25))
74
                DualPathFPAdder_instance (
75
                                                                                .a_number_i         (a_number_i_next    ),
76
                                                                                .b_number_i         (b_number_i_next    ),
77
                                                                                .sub                (1'b0               ),
78
                                                                                .resulted_number_o      (resulting_number_o ));
79
endmodule

powered by: WebSVN 2.1.0

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