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

Subversion Repositories ft816float

[/] [ft816float/] [trunk/] [rtl/] [verilog2/] [mult114x114.sv] - Blame information for rev 33

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 33 robfinch
// ============================================================================
2
//        __
3
//   \\__/ o\    (C) 2019  Robert Finch, Waterloo
4
//    \  __ /    All rights reserved.
5
//     \/_//     robfinch@finitron.ca
6
//       ||
7
//
8
// This source file is free software: you can redistribute it and/or modify
9
// it under the terms of the GNU Lesser General Public License as published
10
// by the Free Software Foundation, either version 3 of the License, or
11
// (at your option) any later version.
12
//
13
// This source file is distributed in the hope that it will be useful,
14
// but WITHOUT ANY WARRANTY; without even the implied warranty of
15
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
// GNU General Public License for more details.
17
//
18
// You should have received a copy of the GNU General Public License
19
// along with this program.  If not, see .
20
//
21
// Latency 16 clocks.
22
// ============================================================================
23
 
24
// Thanks to Karatsuba
25
 
26
module mult114x114(clk, ce, a, b, p);
27
input clk;
28
input ce;
29
input [113:0] a;
30
input [113:0] b;
31
output reg [227:0] p;
32
 
33
reg [113:0] p1d;
34
wire [113:0] z0, z2, p1;
35
reg [113:0] z1;
36
wire [113:0] ad, bd;
37
reg [57:0] a1, b1;
38
reg [56:0] a2, b2;
39
wire sgn;
40
 
41
always @(posedge clk)
42
        if (ce) a1 <= a[56:0] - a[113:57];
43
always @(posedge clk)
44
        if (ce) b1 <= b[113:57] - b[56:0];
45
always @(posedge clk)
46
        if (ce) a2 <= a1[57] ? -a1 : a1;
47
always @(posedge clk)
48
        if (ce) b2 <= b1[57] ? -b1 : b1;
49
 
50
delay3 #(114) uda (.clk(clk), .ce(1'b1), .i(a), .o(ad));
51
delay3 #(114) udb (.clk(clk), .ce(1'b1), .i(b), .o(bd));
52
vtdl #(1) uds (.clk(clk), .ce(1'b1), .a(4'd12), .d(a1[57]^b1[57]), .q(sgn));
53
 
54
mult57x57 u1 (
55
  .CLK(clk),
56
  .CE(ce),
57
  .A(ad[113:57]),
58
  .B(bd[113:57]),
59
  .P(z2)
60
);
61
 
62
mult57x57 u2 (
63
  .CLK(clk),
64
  .CE(ce),
65
  .A(ad[56:0]),
66
  .B(bd[56:0]),
67
  .P(z0)
68
);
69
 
70
mult57x57 u3 (
71
  .CLK(clk),
72
  .CE(ce),
73
  .A(a2),
74
  .B(b2),
75
  .P(p1)
76
);
77
 
78
always @(posedge clk)
79
        if (ce) p1d <= sgn ? -p1 : p1;
80
 
81
always @(posedge clk)
82
        if (ce) z1 <= p1d + z2 + z0;
83
 
84
always @(posedge clk)
85
        if (ce) p <= {z2,z0} + {z1,57'd0};
86
 
87
endmodule

powered by: WebSVN 2.1.0

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