-
Notifications
You must be signed in to change notification settings - Fork 16
/
exponential.v
157 lines (148 loc) · 2.97 KB
/
exponential.v
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
`timescale 1ns / 1ps
`define DATALENGTH 32
`define INPUTMAX 5
`define IDLE 2'b00
`define INPUTSTREAM 2'b01
`define OP 2'b10
module exponential (
input wire Clock,
input wire Reset,
input wire Str,
input wire [`DATALENGTH-1:0] Datain,
output reg Ack,
output reg [`DATALENGTH-1:0] DataOut
);
wire [`DATALENGTH-1:0] one, oversix, half;
//reg [`DATALENGTH-1:0] T0R,T1R,T2R,TsR,TdR,TcR, DoR;
reg [`DATALENGTH-1:0] Count;
reg [`DATALENGTH-1:0] T0;
wire [`DATALENGTH-1:0] T1,T2,Ts,Td,Tc,To,Tsh;
wire wa_add_1,wb_add_1,wz_add_1;
wire wa_add_2,wb_add_2,wz_add_2;
wire wa_add_3,wb_add_3,wz_add_3;
wire wa_mul_1,wb_mul_1,wz_mul_1;
wire wa_mul_2,wb_mul_2,wz_mul_2;
wire wa_sh_1,wb_sh_1,wz_sh_1;
wire wa_div_1,wb_div_1,wz_div_1;
assign one = 32'h3f800000;
assign oversix = 32'h3e2aaaab ;
assign half = 32'h3f000000;
adder A1 (
one,
T0,
Str,
Str,
Str,
Clock,
Reset,
T1,
wz_add_1,
wa_add_1,
wb_add_1);
multiplier Ms (
T0,
T0,
wa_add_1,
wb_add_1,
wz_add_1,
Clock,
Reset,
Ts,
wz_mul_1,
wa_mul_1,
wb_mul_1);
multiplier Msh (
half,
Ts,
wa_mul_1,
wb_mul_1,
wz_mul_1,
Clock,
Reset,
Tsh,
wz_sh_1,
wa_sh_1,
wb_sh_1);
adder A2 (
T1,
Tsh,
wa_sh_1,
wb_sh_1,
wz_sh_1,
Clock,
Reset,
T2,
wz_add_2,
wa_add_2,
wb_add_2);
multiplier Mc (
Ts,
Ts,
wa_add_2,
wb_add_2,
wz_add_2,
Clock,
Reset,
Tc,
wz_mul_2,
wa_mul_2,
wb_mul_2);
multiplier Dm (
Tc,
oversix,
wa_mul_2,
wb_mul_2,
wz_mul_2,
Clock,
Reset,
Td,
wz_div_1,
wa_div_1,
wb_div_1
);
adder A3 (
Td,
T2,
wa_div_1,
wb_div_1,
wz_div_1,
Clock,
Reset,
To,
wz_add_3,
wa_add_3,
wb_add_3);
integer i;
always @(posedge Clock or negedge Reset) begin
if(Reset) begin
T0 <= 0;
DataOut <= 0;
Ack <= 0;
Count <= 0;
// T1 <= 0;
// T2 <= 0;
// Ts <= 0;
// Tc <= 0;
// Td <= 0;
end else begin
if (Str) begin
T0 <= Datain;
DataOut <= To;
if (Count == 140)
Ack <= 1;
Count <= Count +1;
end
else
T0 <= 32'hz;
// T1R <= T1;
// TsR <= Ts;
// T2R <= T2;
// TcR <= Tc;
// T1 <= T0 + 1 ;
// Ts <= T0 * T0;
// T2 <= T1 + (Ts >> 2);
// Tc <= Ts* T0;
// DataOut <= T2 + (Tc /6);
end
end
endmodule