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

Subversion Repositories theia_gpu

[/] [theia_gpu/] [branches/] [icarus_version/] [rtl/] [Module_FixedPointSquareRoot.v] - Blame information for rev 176

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

Line No. Rev Author Line
1 158 diegovalve
`timescale 1ns / 1ps
2
`include "aDefinitions.v"
3
 
4
 
5
//LUT contains LUT for numbers up to 100 in FIXED point scale 17
6
module SQUAREROOT_LUT
7
(
8
        input  wire[`WIDTH-1:0]                  I,
9
        output reg [`WIDTH-1:0]          O
10
);
11
 
12
 
13
always @( I )
14
begin
15
        case (I)
16
        32'h0: O = 32'h0;
17
32'h20000: O = 32'h20000;
18
32'h40000: O = 32'h2d413;
19
32'h60000: O = 32'h376cf;
20
32'h80000: O = 32'h40000;
21
32'ha0000: O = 32'h478dd;
22
32'hc0000: O = 32'h4e623;
23
32'he0000: O = 32'h54a9f;
24
32'h100000: O = 32'h5a827;
25
32'h120000: O = 32'h60000;
26
32'h140000: O = 32'h65316;
27
32'h160000: O = 32'h6a21c;
28
32'h180000: O = 32'h6ed9e;
29
32'h1a0000: O = 32'h7360a;
30
32'h1c0000: O = 32'h77bba;
31
32'h1e0000: O = 32'h7bef7;
32
32'h200000: O = 32'h80000;
33
32'h220000: O = 32'h83f07;
34
32'h240000: O = 32'h87c3b;
35
32'h260000: O = 32'h8b7c1;
36
32'h280000: O = 32'h8f1bb;
37
32'h2a0000: O = 32'h92a47;
38
32'h2c0000: O = 32'h9617e;
39
32'h2e0000: O = 32'h99777;
40
32'h300000: O = 32'h9cc47;
41
32'h320000: O = 32'ha0000;
42
32'h340000: O = 32'ha32b2;
43
32'h360000: O = 32'ha646e;
44
32'h380000: O = 32'ha953f;
45
32'h3a0000: O = 32'hac534;
46
32'h3c0000: O = 32'haf456;
47
32'h3e0000: O = 32'hb22b2;
48
32'h400000: O = 32'hb504f;
49
32'h420000: O = 32'hb7d37;
50
32'h440000: O = 32'hba972;
51
32'h460000: O = 32'hbd508;
52
32'h480000: O = 32'hc0000;
53
32'h4a0000: O = 32'hc2a5f;
54
32'h4c0000: O = 32'hc542e;
55
32'h4e0000: O = 32'hc7d70;
56
32'h500000: O = 32'hca62c;
57
32'h520000: O = 32'hcce66;
58
32'h540000: O = 32'hcf623;
59
32'h560000: O = 32'hd1d68;
60
32'h580000: O = 32'hd4439;
61
32'h5a0000: O = 32'hd6a99;
62
32'h5c0000: O = 32'hd908d;
63
32'h5e0000: O = 32'hdb618;
64
32'h600000: O = 32'hddb3d;
65
32'h620000: O = 32'he0000;
66
32'h640000: O = 32'he2463;
67
32'h660000: O = 32'he4869;
68
32'h680000: O = 32'he6c15;
69
32'h6a0000: O = 32'he8f6a;
70
32'h6c0000: O = 32'heb26a;
71
32'h6e0000: O = 32'hed517;
72
32'h700000: O = 32'hef775;
73
32'h720000: O = 32'hf1983;
74
32'h740000: O = 32'hf3b46;
75
32'h760000: O = 32'hf5cbf;
76
32'h780000: O = 32'hf7def;
77
32'h7a0000: O = 32'hf9ed9;
78
32'h7c0000: O = 32'hfbf7d;
79
32'h7e0000: O = 32'hfdfdf;
80
32'h800000: O = 32'h100000;
81
32'h820000: O = 32'h101fe0;
82
32'h840000: O = 32'h103f81;
83
32'h860000: O = 32'h105ee6;
84
32'h880000: O = 32'h107e0f;
85
32'h8a0000: O = 32'h109cfd;
86
32'h8c0000: O = 32'h10bbb3;
87
32'h8e0000: O = 32'h10da30;
88
32'h900000: O = 32'h10f876;
89
32'h920000: O = 32'h111687;
90
32'h940000: O = 32'h113463;
91
32'h960000: O = 32'h11520c;
92
32'h980000: O = 32'h116f83;
93
32'h9a0000: O = 32'h118cc8;
94
32'h9c0000: O = 32'h11a9dc;
95
32'h9e0000: O = 32'h11c6c1;
96
32'ha00000: O = 32'h11e377;
97
32'ha20000: O = 32'h120000;
98
32'ha40000: O = 32'h121c5b;
99
32'ha60000: O = 32'h12388a;
100
32'ha80000: O = 32'h12548e;
101
32'haa0000: O = 32'h127068;
102
32'hac0000: O = 32'h128c17;
103
32'hae0000: O = 32'h12a79e;
104
32'hb00000: O = 32'h12c2fc;
105
32'hb20000: O = 32'h12de32;
106
32'hb40000: O = 32'h12f942;
107
32'hb60000: O = 32'h13142b;
108
32'hb80000: O = 32'h132eee;
109
32'hba0000: O = 32'h13498c;
110
32'hbc0000: O = 32'h136406;
111
32'hbe0000: O = 32'h137e5b;
112
32'hc00000: O = 32'h13988e;
113
32'hc20000: O = 32'h13b29d;
114
32'hc40000: O = 32'h13cc8a;
115
32'hc60000: O = 32'h13e655;
116
 
117
default:
118
begin
119
// $display("Shit, got %d",I << `SCALE);
120
 O = 32'hfffffff;
121
end
122
        endcase
123
 
124
end //always    
125
endmodule
126
 
127
module FixedPointSquareRoot
128
(
129
        input wire                                                      Clock,
130
        input wire                                                      Reset,
131
        input wire[`LONG_WIDTH-1:0]      Operand,
132
        input wire                                                      iInputReady,
133
        output  wire                                            OutputReady,
134
        output  wire [`WIDTH-1:0]                Result
135
);
136
 
137
FFD_POSEDGE_SYNCRONOUS_RESET # (1) FFwMultiplicationOutputReadyC_Dealy1
138
(
139
        .Clock( Clock ),
140
        .Reset( Reset ),
141
        .Enable(1'b1 ),
142
        .D( iInputReady ),
143
        .Q( OutputReady )
144
);
145
 
146
wire [`WIDTH-1:0] wResult;
147
SQUAREROOT_LUT SQRT
148
(
149
.I({Operand[`WIDTH-1:`SCALE],{`SCALE{1'b0}}}), //Aproximate the Square root to an integer value
150
.O(wResult)
151
);
152
 
153
FFD_POSEDGE_SYNCRONOUS_RESET # (`WIDTH) FFRESULT
154
(
155
        .Clock( Clock ),
156
        .Reset( Reset ),
157
        .Enable(1'b1 ),
158
        .D( wResult ),
159
        .Q( Result )
160
);
161
endmodule
162
 

powered by: WebSVN 2.1.0

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