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_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
//                              
14
// Dependencies:        SinglePathAdderConversion
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
        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
                                        a_number_i_next = 35'b01001111111000000000000000000000000;
55
                                        statusI = $fscanf(f,"%35b %35b\n",b_number_i_next,c_number_i_next);
56
                                        statusJ = $fscanf(f,"%1b %35b\n",unnecessary,result_next);
57
                                        i = i + 1;
58
                                        @(posedge clk);
59
                                        @(posedge clk);
60
                                        @(posedge clk);
61
                                        if (correct)
62
                                                correct_cases = correct_cases + 1;
63
                                        else
64
                                                begin
65
                                                        incorrect_cases = incorrect_cases + 1;
66
                                                        $display("Error occured at index #%d",i);
67
                                                end
68
                        end
69
                        $display("Correct cases: %d \nIncorrect cases: %d", correct_cases, incorrect_cases);
70
                        $display("\tPercentage = %f ", correct_cases/200.07);
71
                        $stop();
72
      end
73
 
74
        assign correct = (result_next[31:0] == resulting_number_o[31:0] || result_next[31:0] == 32'd0)? 1 : 0;
75
 
76
        always #2       clk = ~clk;
77
 
78
        Multiply_AccumulateConversion #(
79
                                                .size_mantissa  (25))
80
                Multiply_AccumulateConversion_instance (
81
                                                                                .conversion(add),
82
                                                                                .c_number_i                     (c_number_i_next        ),
83
                                                                                .a_number_i         (a_number_i_next    ),
84
                                                                                .b_number_i         (b_number_i_next    ),
85
                                                                                .sub                (1'b0               ),
86
                                                                                .resulting_number_o     (resulting_number_o ));
87
endmodule

powered by: WebSVN 2.1.0

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