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

powered by: WebSVN 2.1.0

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