-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexponent_finder.v
More file actions
75 lines (66 loc) · 1.5 KB
/
exponent_finder.v
File metadata and controls
75 lines (66 loc) · 1.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
`timescale 1ns / 1ps
//////////////////////////////////////////////////////////////////////////////////
// Company:
// Engineer:
//
// Create Date: 23:45:15 04/19/2015
// Design Name:
// Module Name: exponent_finder
// Project Name:
// Target Devices:
// Tool versions:
// Description:
//
// Dependencies:
//
// Revision:
// Revision 0.01 - File Created
// Additional Comments:
//
//////////////////////////////////////////////////////////////////////////////////
module exponent_finder(
input clk,
input [63:0] boundary,
input input_enable,
input [8:0] base,
output reg [7:0] exponent,
output reg ready
);
reg [7:0] next_exponent;
reg next_ready;
reg [10:0] temp_product;
reg [10:0] next_temp_product;
initial begin
next_ready = 0;
next_exponent = 0;
next_temp_product = 1;
end
always @(posedge clk) begin
ready <= next_ready;
exponent <= next_exponent;
temp_product <= next_temp_product;
end
always @(*) begin
if (input_enable) begin
if (temp_product < boundary) begin
next_temp_product = temp_product * base;
next_ready = 0;
next_exponent = exponent + 1;
end else begin
next_temp_product = temp_product;
next_ready = 1;
next_exponent = exponent;
end
end else begin
if (ready) begin
next_ready = 1;
next_exponent = exponent;
next_temp_product = 1;
end else begin
next_temp_product = 1;
next_ready = 0;
next_exponent = 0;
end
end
end
endmodule