-
Notifications
You must be signed in to change notification settings - Fork 0
/
ExtractKtaParameters_process_p0.vhd
344 lines (306 loc) · 10.7 KB
/
ExtractKtaParameters_process_p0.vhd
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
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
----------------------------------------------------------------------------------
-- Company:
-- Engineer:
--
-- Create Date: 22:48:47 06/13/2023
-- Design Name:
-- Module Name: ExtractKtaParameters_process_p0 - Behavioral
-- Project Name:
-- Target Devices:
-- Tool versions:
-- Description:
--
-- Dependencies:
--
-- Revision:
-- Revision 0.01 - File Created
-- Additional Comments:
--
----------------------------------------------------------------------------------
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
-- Uncomment the following library declaration if using
-- arithmetic functions with Signed or Unsigned values
use IEEE.NUMERIC_STD.ALL;
-- Uncomment the following library declaration if instantiating
-- any Xilinx primitives in this code.
--library UNISIM;
--use UNISIM.VComponents.all;
use work.p_fphdl_package3.all;
entity ExtractKtaParameters_process_p0 is
generic (
constant C_COL : integer := 32;
constant C_ROW : integer := 24
);
port (
i_clock : in std_logic;
i_reset : in std_logic;
i_run : in std_logic;
i2c_mem_ena : out STD_LOGIC;
i2c_mem_addra : out STD_LOGIC_VECTOR(11 DOWNTO 0);
i2c_mem_douta : in STD_LOGIC_VECTOR(7 DOWNTO 0);
nibble_out1,nibble_out2 : out std_logic_vector (3 downto 0);
nibble_out3 : out std_logic_vector (2 downto 0);
nibble_in1,nibble_in2,nibble_in3 : in std_logic_vector (31 downto 0);
o_dia : out std_logic_vector (31 downto 0);
o_addra : out std_logic_vector (9 downto 0);
o_write_enable : out std_logic;
ktarcee_oo,ktarcee_eo,ktarcee_oe,ktarcee_ee : out std_logic_vector (7 downto 0);
ktarcee : in std_logic_vector (7 downto 0);
mem_signed256_ivalue : out std_logic_vector (7 downto 0); -- input hex from 0 to 255
mem_signed256_ovalue : in std_logic_vector (31 downto 0); -- output signed -128 to 127 in SP float
o_rdy : out std_logic;
o_col : out std_logic_vector (0 to 4);
o_row : out std_logic_vector (0 to 4);
signal mulfpa : out STD_LOGIC_VECTOR(31 DOWNTO 0);
signal mulfpb : out STD_LOGIC_VECTOR(31 DOWNTO 0);
signal mulfpond : out STD_LOGIC;
signal mulfpsclr : out STD_LOGIC;
signal mulfpce : out STD_LOGIC;
signal mulfpr : in STD_LOGIC_VECTOR(31 DOWNTO 0);
signal mulfprdy : in STD_LOGIC;
signal addfpa : out STD_LOGIC_VECTOR(31 DOWNTO 0);
signal addfpb : out STD_LOGIC_VECTOR(31 DOWNTO 0);
signal addfpond : out STD_LOGIC;
signal addfpsclr : out STD_LOGIC;
signal addfpce : out STD_LOGIC;
signal addfpr : in STD_LOGIC_VECTOR(31 DOWNTO 0);
signal addfprdy : in STD_LOGIC;
signal divfpa : out STD_LOGIC_VECTOR(31 DOWNTO 0);
signal divfpb : out STD_LOGIC_VECTOR(31 DOWNTO 0);
signal divfpond : out STD_LOGIC;
signal divfpsclr : out STD_LOGIC;
signal divfpce : out STD_LOGIC;
signal divfpr : in STD_LOGIC_VECTOR(31 DOWNTO 0);
signal divfprdy : in STD_LOGIC
);
end ExtractKtaParameters_process_p0;
architecture Behavioral of ExtractKtaParameters_process_p0 is
signal mulfpa_internal : STD_LOGIC_VECTOR(31 DOWNTO 0);
signal mulfpb_internal : STD_LOGIC_VECTOR(31 DOWNTO 0);
signal mulfpond_internal : STD_LOGIC;
signal mulfpsclr_internal : STD_LOGIC;
signal mulfpce_internal : STD_LOGIC;
signal mulfpr_internal : STD_LOGIC_VECTOR(31 DOWNTO 0);
signal mulfprdy_internal : STD_LOGIC;
signal addfpa_internal : STD_LOGIC_VECTOR(31 DOWNTO 0);
signal addfpb_internal : STD_LOGIC_VECTOR(31 DOWNTO 0);
signal addfpond_internal : STD_LOGIC;
signal addfpsclr_internal : STD_LOGIC;
signal addfpce_internal : STD_LOGIC;
signal addfpr_internal : STD_LOGIC_VECTOR(31 DOWNTO 0);
signal addfprdy_internal : STD_LOGIC;
signal divfpa_internal : STD_LOGIC_VECTOR(31 DOWNTO 0);
signal divfpb_internal : STD_LOGIC_VECTOR(31 DOWNTO 0);
signal divfpond_internal : STD_LOGIC;
signal divfpsclr_internal : STD_LOGIC;
signal divfpce_internal : STD_LOGIC;
signal divfpr_internal : STD_LOGIC_VECTOR(31 DOWNTO 0);
signal divfprdy_internal : STD_LOGIC;
signal col : integer range 0 to C_COL-1;
signal row : integer range 0 to C_ROW-1;
begin
mulfpa <= mulfpa_internal;
mulfpb <= mulfpb_internal;
mulfpond <= mulfpond_internal;
mulfpsclr <= mulfpsclr_internal;
mulfpce <= mulfpce_internal;
mulfpr_internal <= mulfpr;
mulfprdy_internal <= mulfprdy;
addfpa <= addfpa_internal;
addfpb <= addfpb_internal;
addfpond <= addfpond_internal;
addfpsclr <= addfpsclr_internal;
addfpce <= addfpce_internal;
addfpr_internal <= addfpr;
addfprdy_internal <= addfprdy;
divfpa <= divfpa_internal;
divfpb <= divfpb_internal;
divfpond <= divfpond_internal;
divfpsclr <= divfpsclr_internal;
divfpce <= divfpce_internal;
divfpr_internal <= divfpr;
divfprdy_internal <= divfprdy;
p0 : process (i_clock) is
type states is (idle,
kta0,kta1,kta2,kta3,kta4,
kta5,kta6,kta7,kta8,kta9,
kta10,kta11,kta12,kta13,kta14,
kta15,kta16,kta17,kta18,kta19,
kta20,kta21,kta22,kta23,kta24,
kta25,kta26,kta27,kta28,
ending);
variable state : states;
variable vktaRemScale : std_logic_vector (31 downto 0);
variable vktaColumnScale : std_logic_vector (31 downto 0);
variable vktaRowScale : std_logic_vector (31 downto 0);
variable vktaRemScale1 : std_logic_vector (3 downto 0);
variable vktaColumnScale1 : std_logic_vector (3 downto 0);
variable vktaRowScale1 : std_logic_vector (3 downto 0);
variable valphaRef1: std_logic_vector (15 downto 0);
variable valphaRef : std_logic_vector (15 downto 0);
variable fptmp1,fptmp2 : std_logic_vector (31 downto 0);
variable vktacolumnj,ktarowi,vktarowi,valphaReference_ft,vAlphaPixel_ft,ktarcee_ft,kta_ft : std_logic_vector (31 downto 0);
variable temp1,vAlphaPixel : std_logic_vector (15 downto 0);
variable i : integer range 0 to (C_ROW*C_COL)-1;
begin
if (rising_edge (i_clock)) then
if (i_reset = '1') then
state := idle;
nibble_out1 <= (others => '0');
nibble_out2 <= (others => '0');
nibble_out3 <= (others => '0');
o_write_enable <= '0';
o_rdy <= '0';
addfpsclr_internal <= '1';
mulfpsclr_internal <= '1';
divfpsclr_internal <= '1';
mulfpa_internal <= (others => '0');
mulfpb_internal <= (others => '0');
addfpa_internal <= (others => '0');
addfpb_internal <= (others => '0');
divfpa_internal <= (others => '0');
divfpb_internal <= (others => '0');
addfpond_internal <= '0';
mulfpond_internal <= '0';
divfpond_internal <= '0';
addfpce_internal <= '0';
mulfpce_internal <= '0';
divfpce_internal <= '0';
o_addra <= (others => '0');
o_dia <= (others => '0');
i2c_mem_ena <= '0';
i2c_mem_addra <= (others => '0');
i := 0;
o_col <= (others => '0');
o_row <= (others => '0');
else
case (state) is
when idle =>
if (i_run = '1') then
state := kta0;
i2c_mem_ena <= '1';
o_write_enable <= '1';
else
state := idle;
i2c_mem_ena <= '0';
o_write_enable <= '0';
end if;
when kta0 => state := kta1;
addfpsclr_internal <= '0';
mulfpsclr_internal <= '0';
divfpsclr_internal <= '0';
o_rdy <= '0';
when kta1 => state := kta2;
i2c_mem_addra <= std_logic_vector (to_unsigned (108, 12)); -- 2436 LSB - ktarcee_oo 54*2+0
when kta2 => state := kta3;
when kta3 => state := kta4;
i2c_mem_addra <= std_logic_vector (to_unsigned (109, 12)); -- 2436 MSB - ktarcee_eo 54*2+1
ktarcee_oo <= i2c_mem_douta;
when kta4 => state := kta5;
when kta5 => state := kta6;
i2c_mem_addra <= std_logic_vector (to_unsigned (110, 12)); -- 2437 LSB - ktarcee_oe 54*2+2
ktarcee_eo <= i2c_mem_douta;
when kta6 => state := kta7;
when kta7 => state := kta8;
i2c_mem_addra <= std_logic_vector (to_unsigned (111, 12)); -- 2437 MSB - ktarcee_ee 54*2+3
ktarcee_oe <= i2c_mem_douta;
when kta8 => state := kta9;
when kta9 => state := kta10;
ktarcee_ee <= i2c_mem_douta;
when kta10 => state := kta11;
mem_signed256_ivalue <= ktarcee;
when kta11 => state := kta12;
when kta12 => state := kta13;
ktarcee_ft := mem_signed256_ovalue;
when kta13 => state := kta14;
i2c_mem_addra <= std_logic_vector (to_unsigned (113, 12)); -- 2438 LSB - ktascale1/ktascale2 54*2+5
when kta14 => state := kta15;
when kta15 => state := kta16;
nibble_out1 <= i2c_mem_douta (7 downto 4); -- ktascale1
nibble_out2 <= i2c_mem_douta (3 downto 0); -- ktascale2
when kta16 => state := kta17;
i2c_mem_addra <= std_logic_vector (to_unsigned (129+(2*i), 12)); -- kta LSB 1
when kta17 => state := kta18;
when kta18 => state := kta19;
nibble_out3 <= i2c_mem_douta (3 downto 1); -- kta_ee 3bit
when kta19 => state := kta20;
mulfpce_internal <= '1';
mulfpa_internal <= nibble_in3; -- kta_ee
mulfpb_internal <= nibble_in2; -- 2^ktascale2
mulfpond_internal <= '1';
-- --report "vAlphaPixel : " & real'image (ap_slv2fp (out_nibble3));
-- --report "vktaRemScale : " & real'image (ap_slv2fp (vktaRemScale));
when kta20 => --6
if (mulfprdy_internal = '1') then state := kta21;
kta_ft := mulfpr_internal;
mulfpce_internal <= '0';
mulfpond_internal <= '0';
mulfpsclr_internal <= '1';
else state := kta20; end if;
when kta21 => state := kta22; --7
mulfpsclr_internal <= '0';
addfpce_internal <= '1';
addfpa_internal <= kta_ft; -- kta_ee*2^ktascale2
addfpb_internal <= ktarcee_ft; -- ktarcee
addfpond_internal <= '1';
-- --report "vAlphaPixel : " & real'image (ap_slv2fp (out_nibble3));
-- --report "vktaRemScale : " & real'image (ap_slv2fp (vktaRemScale));
when kta22 => --6
if (addfprdy_internal = '1') then state := kta23;
kta_ft := addfpr_internal;
addfpce_internal <= '0';
addfpond_internal <= '0';
addfpsclr_internal <= '1';
else state := kta22; end if;
when kta23 => state := kta24; --7
addfpsclr_internal <= '0';
divfpce_internal <= '1';
divfpa_internal <= kta_ft; -- ktarcee+kta_ee*2^ktascale2
divfpb_internal <= nibble_in1; -- 2^ktascale1
divfpond_internal <= '1';
-- --report "vAlphaPixel : " & real'image (ap_slv2fp (out_nibble3));
-- --report "vktaRemScale : " & real'image (ap_slv2fp (vktaRemScale));
when kta24 => --6
if (divfprdy_internal = '1') then state := kta25;
kta_ft := divfpr_internal;
divfpce_internal <= '0';
divfpond_internal <= '0';
divfpsclr_internal <= '1';
else state := kta24; end if;
when kta25 => state := kta26; --7
divfpsclr_internal <= '0';
when kta26 => state := kta27; --22
o_write_enable <= '1';
o_addra <= std_logic_vector (to_unsigned (i, 10)); -- kta
o_dia <= kta_ft;
report_error ("================kta_ft "&integer'image(i)&" ",kta_ft,0.0);
when kta27 =>
i := i + 1;
o_write_enable <= '0';
if (col = C_COL-1) then
col <= 0;
state := kta28;
else
col <= col + 1;
state := kta10;
end if;
o_col <= std_logic_vector (to_unsigned (col, 5));
when kta28 =>
o_write_enable <= '0';
if (row = C_ROW-1) then
row <= 0;
state := ending;
else
row <= row + 1;
state := kta10;
end if;
o_row <= std_logic_vector (to_unsigned (row, 5));
when ending => state := idle;
o_rdy <= '1';
when others => null;
end case;
end if;
end if;
end process p0;
end Behavioral;