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/] [GeneralPrecMAFMappedConversions/] [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 [34:0] c_number_i_next;
34
        reg unnecessary;
35
        reg [34:0] result_next;
36
        wire [34:0] resulting_number_o;
37
        integer f;
38
        integer i;
39
        real correct_cases, incorrect_cases;
40
        integer statusI, statusJ;
41
 
42
        wire correct;
43
 
44
        initial
45
                begin
46
                        i = 0;
47
                        correct_cases = 0;
48
                        incorrect_cases = 0;
49
                        clk = 1;
50
                        rst = 0;
51
                        f = $fopen(`input_file, "r");
52
                        while (!$feof(f))
53
                                begin
54
                                        statusI = $fscanf(f,"%32b\n",c_number_i_next);
55
                                        statusJ = $fscanf(f,"%1b %35b\n",unnecessary,result_next);
56
                                        i = i + 1;
57
                                        @(posedge clk);
58
                                        @(posedge clk);
59
                                        @(posedge clk);
60
                                        if (correct)
61
                                                correct_cases = correct_cases + 1;
62
                                        else
63
                                                begin
64
                                                        incorrect_cases = incorrect_cases + 1;
65
                                                        $display("Error occured at index #%d",i);
66
                                                end
67
                        end
68
                        $display("percentage = %f ", correct_cases/200.00);
69
                        $stop();
70
      end
71
 
72
        assign correct = (result_next[31:0] == resulting_number_o[31:0])? 1 : 0;
73
 
74
 
75
        always #2       clk = ~clk;
76
 
77
        Multiply_AccumulateConversion #(
78
                                                .size_mantissa  (25))
79
                Multiply_AccumulateConversion_instance (
80
                                                                                .conversion(int2fp),
81
                                                                                .c_number_i                     (c_number_i_next        ),
82
                                                                                .a_number_i         (a_number_i_next    ),
83
                                                                                .b_number_i         (b_number_i_next    ),
84
                                                                                .sub                (1'b0               ),
85
                                                                                .resulting_number_o     (resulting_number_o ));
86
endmodule

powered by: WebSVN 2.1.0

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