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

Subversion Repositories ft816float

[/] [ft816float/] [trunk/] [rtl/] [verilog/] [FT816Float_tb.v] - Blame information for rev 39

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 3 robfinch
`timescale 1ns / 1ps
2
// ============================================================================
3
//        __
4
//   \\__/ o\    (C) 2014  Robert Finch, Stratford
5
//    \  __ /    All rights reserved.
6
//     \/_//     robfinch<remove>@finitron.ca
7
//       ||
8
//
9
// FT816Float_tb.v
10
//  - Test Bench for triple precision floating point accelerator
11
//
12
// This source file is free software: you can redistribute it and/or modify 
13
// it under the terms of the GNU Lesser General Public License as published 
14
// by the Free Software Foundation, either version 3 of the License, or     
15
// (at your option) any later version.                                      
16
//                                                                          
17
// This source file is distributed in the hope that it will be useful,      
18
// but WITHOUT ANY WARRANTY; without even the implied warranty of           
19
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the            
20
// GNU General Public License for more details.                             
21
//                                                                          
22
// You should have received a copy of the GNU General Public License        
23
// along with this program.  If not, see <http://www.gnu.org/licenses/>.    
24
//                                                                          
25
// ============================================================================
26
//
27
module FT816Float_tb();
28
 
29
reg clk;
30
reg rst;
31
reg vda;
32
reg rw;
33
reg [23:0] ad;
34
wire [7:0] db;
35
reg [7:0] dbo;
36
wire rdy;
37
reg [7:0] state;
38
reg [7:0] retstate;
39
reg fix2flt;
40
reg [95:0] value;
41
 
42
initial begin
43
        #1 clk <= 1'b0;
44
        #5 rst <= 1'b1;
45
        #100 rst <= 1'b0;
46
end
47
 
48
always #5 clk <= ~clk;
49
 
50
assign db = rw ? {8{1'bz}} : dbo;
51
 
52
FT816Float u1 (
53
        .rst(rst),
54
        .clk(clk),
55
        .vda(vda),
56
        .rw(rw),
57
        .ad(ad),
58
        .db(db),
59
        .rdy(rdy)
60
);
61
 
62
 
63
always @(posedge clk)
64
if (rst)
65
        state <= 8'h00;
66
else begin
67
state <= state + 8'd1;
68
case(state)
69
8'h00:  begin
70
                        value <= 96'h00000000000000004D20000;   // MAXINT
71
                        fix2flt <= 1'b1;
72
                        state <= 8'h80;
73
                        retstate <= 8'h01;
74
                         b_write(24'hFEA20F,8'd17);     // prime bus
75
                end
76
8'h01:  if (rdy) b_write(24'hFEA20F,8'd17); else state <= state;// SWAP
77
8'h03:  if (rdy) b_read(24'hFEA20F); else state <= state;
78
8'h04:  if (rdy) begin
79
                        if (db[7]) state <= state - 1;
80
                end
81
                else
82
                        state <= state;
83
8'h05:  begin
84
                        value <= 96'h000000000000000004D20000;  // MAXINT
85
                        fix2flt <= 1'b1;
86
                        state <= 8'h80;
87
                        retstate <= 8'h06;
88
                end
89
8'h06:  if (rdy) b_write(24'hFEA20F,8'h06); else state <= state;// MUL
90
8'h08:  if (rdy) b_read(24'hFEA20F); else state <= state;
91
8'h09:  if (rdy) begin
92
                        if (db[7]) state <= state - 1;
93
                end
94
                else
95
                        state <= state;
96
8'h20:  state <= state;
97
// This subroutine writes a value to FAC1.
98
8'h80:  if (rdy) b_write(24'hFEA200,value[7:0]); else state <= state;
99
8'h81:  if (rdy) b_write(24'hFEA201,value[15:8]); else state <= state;
100
8'h82:  if (rdy) b_write(24'hFEA202,value[23:16]); else state <= state;
101
8'h83:  if (rdy) b_write(24'hFEA203,value[31:24]); else state <= state;
102
8'h84:  if (rdy) b_write(24'hFEA204,value[39:32]); else state <= state;
103
8'h85:  if (rdy) b_write(24'hFEA205,value[47:40]); else state <= state;
104
8'h86:  if (rdy) b_write(24'hFEA206,value[55:48]); else state <= state;
105
8'h87:  if (rdy) b_write(24'hFEA207,value[63:56]); else state <= state;
106
8'h88:  if (rdy) b_write(24'hFEA208,value[71:64]); else state <= state;
107
8'h89:  if (rdy) b_write(24'hFEA209,value[79:72]); else state <= state;
108
8'h8A:  if (rdy) b_write(24'hFEA20A,value[87:80]); else state <= state;
109
8'h8B:  if (rdy) begin b_write(24'hFEA20B,value[95:88]); if (fix2flt) state <= 8'h90; else state <= retstate; end else state <= state;
110
8'h90:  if (rdy) b_write(24'hFEA20F,8'h05); else state <= state;// FIX2FLT
111
8'h92:  if (rdy) b_read(24'hFEA20F); else state <= state;
112
8'h93:  if (rdy) begin
113
                        if (db[7]) state <= state - 1;
114
                        else state <= retstate;
115
                end
116
                else
117
                        state <= state;
118
endcase
119
end
120
 
121
task b_write;
122
input [23:0] adr;
123
input [7:0] dat;
124
begin
125
        vda <= 1'b1;
126
        rw <= 1'b0;
127
        ad <= adr;
128
        dbo <= dat;
129
end
130
endtask
131
 
132
task b_read;
133
input [23:0] adr;
134
begin
135
        vda <= 1'b1;
136
        rw <= 1'b1;
137
        ad <= adr;
138
end
139
endtask
140
 
141
endmodule

powered by: WebSVN 2.1.0

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