OpenCores
URL https://opencores.org/ocsvn/ft816float/ft816float/trunk

Subversion Repositories ft816float

[/] [ft816float/] [trunk/] [test_bench/] [fpFMA_tb.v] - Diff between revs 23 and 32

Only display areas with differences | Details | Blame | View Log

Rev 23 Rev 32
`timescale 1ns / 1ps
`timescale 1ns / 1ps
// ============================================================================
// ============================================================================
//        __
//        __
//   \\__/ o\    (C) 2019  Robert Finch, Waterloo
//   \\__/ o\    (C) 2019  Robert Finch, Waterloo
//    \  __ /    All rights reserved.
//    \  __ /    All rights reserved.
//     \/_//     robfinch<remove>@finitron.ca
//     \/_//     robfinch<remove>@finitron.ca
//       ||
//       ||
//
//
//      fpFMA_tb.v
//      fpFMA_tb.v
//              - floating point multiplier - adder test bench
//              - floating point multiplier - adder test bench
//
//
// This source file is free software: you can redistribute it and/or modify 
// This source file is free software: you can redistribute it and/or modify 
// it under the terms of the GNU Lesser General Public License as published 
// it under the terms of the GNU Lesser General Public License as published 
// by the Free Software Foundation, either version 3 of the License, or     
// by the Free Software Foundation, either version 3 of the License, or     
// (at your option) any later version.                                      
// (at your option) any later version.                                      
//                                                                          
//                                                                          
// This source file is distributed in the hope that it will be useful,      
// This source file is distributed in the hope that it will be useful,      
// but WITHOUT ANY WARRANTY; without even the implied warranty of           
// but WITHOUT ANY WARRANTY; without even the implied warranty of           
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the            
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the            
// GNU General Public License for more details.                             
// GNU General Public License for more details.                             
//                                                                          
//                                                                          
// You should have received a copy of the GNU General Public License        
// You should have received a copy of the GNU General Public License        
// along with this program.  If not, see <http://www.gnu.org/licenses/>.    
// along with this program.  If not, see <http://www.gnu.org/licenses/>.    
//                                                                          
//                                                                          
//      Floating Point Multiplier / Divider
//      Floating Point Multiplier / Divider
//
//
//      This multiplier/divider handles denormalized numbers.
//      This multiplier/divider handles denormalized numbers.
//      The output format is of an internal expanded representation
//      The output format is of an internal expanded representation
//      in preparation to be fed into a normalization unit, then
//      in preparation to be fed into a normalization unit, then
//      rounding. Basically, it's the same as the regular format
//      rounding. Basically, it's the same as the regular format
//      except the mantissa is doubled in size, the leading two
//      except the mantissa is doubled in size, the leading two
//      bits of which are assumed to be whole bits.
//      bits of which are assumed to be whole bits.
//
//
//
//
// ============================================================================
// ============================================================================
 
 
module fpFMA_tb();
module fpFMA_tb();
reg rst;
reg rst;
reg clk;
reg clk;
reg [12:0] adr;
reg [15:0] adr;
reg [127:0] mem [0:8191];
reg [131:0] mems [0:24000];
reg [127:0] memo [0:9000];
reg [131:0] memso [0:24000];
reg [255:0] memd [0:8191];
reg [259:0] memd [0:24000];
reg [255:0] memdo [0:9000];
reg [259:0] memdo [0:24000];
 
reg [515:0] memq [0:24000];
 
reg [515:0] memqo [0:24000];
reg [31:0] a,b,c;
reg [31:0] a,b,c;
wire [31:0] a5,b5,c5;
reg [3:0] rm, rmd, rmq;
wire [31:0] o;
wire [31:0] o;
reg [63:0] ad,bd,cd;
reg [63:0] ad,bd,cd;
wire [63:0] ad5,bd5,cd5,ad17,bd17,cd17;
 
wire [63:0] od;
wire [63:0] od;
reg [4:0] cnt;
reg [127:0] aq,bq,cq;
 
wire [127:0] oq;
 
reg [7:0] cnt;
 
 
initial begin
initial begin
        rst = 1'b0;
        rst = 1'b0;
        clk = 1'b0;
        clk = 1'b0;
        adr = 0;
        adr = 0;
        cnt = 0;
        cnt = 0;
//      $readmemh("d:/cores6/rtfItanium/v1/rtl/fpUnit/test_bench/fpFMA_tv.txt", mem);
        $readmemh("d:/cores6/nvio/v2/rtl/fpUnit/test_bench/fpFMA_tvs.txt", mems);
        $readmemh("d:/cores6/rtfItanium/v1/rtl/fpUnit/test_bench/fpFMA_tvd.txt", memd);
        $readmemh("d:/cores6/nvio/v2/rtl/fpUnit/test_bench/fpFMA_tvd.txt", memd);
 
        $readmemh("d:/cores6/nvio/v2/rtl/fpUnit/test_bench/fpFMA_tvq.txt", memq);
        #20 rst = 1;
        #20 rst = 1;
        #50 rst = 0;
        #50 rst = 0;
end
end
 
 
always #5
always #5
        clk = ~clk;
        clk = ~clk;
 
 
delay5 #(32) u2 (clk, 1'b1, a, a5);
 
delay5 #(32) u3 (clk, 1'b1, b, b5);
 
delay5 #(32) u4 (clk, 1'b1, c, c5);
 
delay5 #(64) u5 (clk, 1'b1, ad, ad5);
 
delay5 #(64) u6 (clk, 1'b1, bd, bd5);
 
delay5 #(64) u7 (clk, 1'b1, cd, cd5);
 
vtdl #(64,32) u8 (clk, 1'b1, 5'd16, ad, ad17);
 
vtdl #(64,32) u9 (clk, 1'b1, 5'd16, bd, bd17);
 
vtdl #(64,32) u10 (clk, 1'b1, 5'd16, cd, cd17);
 
 
 
always @(posedge clk)
 
        cnt <= cnt + 1;
 
 
 
always @(posedge clk)
always @(posedge clk)
if (rst)
if (rst) begin
        adr = 0;
        adr <= 0;
else
        cnt <= 0;
 
end else
begin
begin
        if (cnt==1)
        cnt <= cnt + 1;
 
        if (cnt==54)
 
                cnt <= 0;
 
        if (cnt==4)
        begin
        begin
                a <= mem[adr][31: 0];
                a <= mems[adr][31: 0];
                b <= mem[adr][63:32];
                b <= mems[adr][63:32];
                c <= mem[adr][95:64];
                c <= mems[adr][95:64];
 
                rm <= mems[adr][131:128];
                ad <= memd[adr][63: 0];
                ad <= memd[adr][63: 0];
                bd <= memd[adr][127:64];
                bd <= memd[adr][127:64];
                cd <= memd[adr][191:128];
                cd <= memd[adr][191:128];
 
                rmd <= memd[adr][259:256];
 
                aq <= memq[adr][127: 0];
 
                bq <= memq[adr][255:128];
 
                cq <= memq[adr][383:256];
 
                rmq <= memq[adr][515:512];
        end
        end
        if (cnt==31)
        if (cnt==53)
        begin
        begin
                adr <= adr + 1;
                adr <= adr + 1;
//              memo[adr] <= {o,c17,b17,a17};
                memso[adr] <= {rm,o,c,b,a};
//              memdo[adr] <= {od,cd17,bd17,ad17};
                memdo[adr] <= {rmd,od,cd,bd,ad};
                memdo[adr] <= {od,cd,bd,ad};
                memqo[adr] <= {rmq,oq,cq,bq,aq};
 
                //memdo[adr] <= {rmd,od,cdx,bdx,adx};
                if (adr==8191) begin
                if (adr==8191) begin
                        //$writememh("d:/cores6/rtfItanium/v1/rtl/fpUnit/test_bench/fpFMA_tvo.txt", memo);
                        $writememh("d:/cores6/nvio/v2/rtl/fpUnit/test_bench/fpFMA_tvso.txt", memso);
                        $writememh("d:/cores6/rtfItanium/v1/rtl/fpUnit/test_bench/fpFMA_tvdo.txt", memdo);
                        $writememh("d:/cores6/nvio/v2/rtl/fpUnit/test_bench/fpFMA_tvdo.txt", memdo);
 
                        $writememh("d:/cores6/nvio/v2/rtl/fpUnit/test_bench/fpFMA_tvqo.txt", memqo);
                        $finish;
                        $finish;
                end
                end
        end
        end
end
end
 
 
//fpFMAnr #(32) u1 (clk, 1'b1, a, b, o, 3'b000);//, sign_exe, inf, overflow, underflow);
fpFMAnr #(32) u1 (clk, 1'b1, 1'b0, rm[2:0], c, b, a, o);//, sign_exe, inf, overflow, underflow);
fpFMAnr #(64) u11 (clk, 1'b1, 1'b0, 3'b000, ad, bd, cd, od);//, sign_exe, inf, overflow, underflow);
fpFMAnr #(64) u16 (clk, 1'b1, 1'b0, rmd[2:0], ad, bd, cd, od);//, sign_exe, inf, overflow, underflow);
 
fpFMAnr #(128) u17 (clk, 1'b1, 1'b0, rmq[2:0], cq, bq, aq, oq);//, sign_exe, inf, overflow, underflow);
 
//fpFMAnr #(64) u15 (clk, 1'b1, 1'b0, rmd[2:0], ad, bd, cd, od);//, inf, overflow, underflow, inexact);
 
 
endmodule
endmodule
 
 

powered by: WebSVN 2.1.0

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