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/] [DualPathFPAdderMappedConversions/] [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:        DualPathFPAdder
15
//
16
// Revision: 
17
// Revision 0.01 - File Created
18
// Additional Comments: 
19
//
20
//////////////////////////////////////////////////////////////////////////////////
21
`define input_file "test_add.input"
22
 
23
module tb_adder;
24
 
25
        parameter [1:0] add = 2'd0;
26
        parameter [1:0] fp2int = 2'd1;
27
        parameter [1:0] int2fp = 2'd2;
28
 
29
        reg clk, rst, start;
30
        reg [34:0] a_number_i_next;
31
        reg [34:0] b_number_i_next;
32
        reg unnecessary;
33
        reg [34:0] result_next;
34
        wire [34:0] resulting_number_o;
35
        integer f;
36
        integer i;
37
        real correct_cases, incorrect_cases;
38
        integer statusI, statusJ;
39
 
40
        wire correct;
41
 
42
        initial
43
                begin
44
                        i = 0;
45
                        correct_cases = 0;
46
                        incorrect_cases = 0;
47
                        clk = 1;
48
                        rst = 0;
49
                        f = $fopen(`input_file, "r");
50
                        while (!$feof(f))
51
                                begin
52
                                        statusI = $fscanf(f,"%35b %35b\n",a_number_i_next,b_number_i_next);
53
                                        statusJ = $fscanf(f,"%1b %35b\n",unnecessary,result_next);
54
                                        i = i + 1;
55
                                        @(posedge clk);
56
                                        @(posedge clk);
57
                                        @(posedge clk);
58
                                        if (correct)
59
                                                correct_cases = correct_cases + 1;
60
                                        else
61
                                                begin
62
                                                        incorrect_cases = incorrect_cases + 1;
63
                                                        $display("Error occured at index #%d \n \tExpDiff = %d\n",i, a_number_i_next[31:24] - b_number_i_next[31:24]);
64
                                                end
65
                        end
66
                        $display("Correct cases: %d \nIncorrect cases: %d", correct_cases, incorrect_cases);
67
                        $display("\tPercentage = %f ", correct_cases/200.07);
68
                        $stop();
69
      end
70
 
71
        assign correct = (result_next[31:0] == resulting_number_o[31:0] || result_next[31:0] == 32'd0)? 1 : 0;
72
 
73
        always #2       clk = ~clk;
74
 
75
        DualPathAdderConversion #(
76
                                                .size_mantissa  (25))
77
                DualPathAdderConversion_instance (
78
                                                                                .conversion(add),
79
                                                                                .a_number_i         (a_number_i_next    ),
80
                                                                                .b_number_i         (b_number_i_next    ),
81
                                                                                .sub                (1'b0               ),
82
                                                                                .resulted_number_o      (resulting_number_o ));
83
endmodule

powered by: WebSVN 2.1.0

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