1 |
2 |
kavi |
-- File automatically generated by "cdfg2hdl".
|
2 |
|
|
-- Filename: cordic.vhd
|
3 |
|
|
-- Date: 27 November 2010 08:42:54 PM
|
4 |
|
|
-- Author: Nikolaos Kavvadias (C) 2009, 2010
|
5 |
|
|
|
6 |
|
|
library IEEE;
|
7 |
|
|
use WORK.operpack.all;
|
8 |
|
|
use WORK.cordic_cdt_pkg.all;
|
9 |
|
|
use IEEE.std_logic_1164.all;
|
10 |
|
|
use IEEE.numeric_std.all;
|
11 |
|
|
|
12 |
|
|
|
13 |
|
|
entity cordic is
|
14 |
|
|
port (
|
15 |
|
|
clk : in std_logic;
|
16 |
|
|
reset : in std_logic;
|
17 |
|
|
start : in std_logic;
|
18 |
|
|
direction : in std_logic_vector(15 downto 0);
|
19 |
|
|
mode : in std_logic_vector(15 downto 0);
|
20 |
|
|
xin : in std_logic_vector(15 downto 0);
|
21 |
|
|
yin : in std_logic_vector(15 downto 0);
|
22 |
|
|
zin : in std_logic_vector(15 downto 0);
|
23 |
|
|
xout : out std_logic_vector(15 downto 0);
|
24 |
|
|
yout : out std_logic_vector(15 downto 0);
|
25 |
|
|
zout : out std_logic_vector(15 downto 0);
|
26 |
|
|
done : out std_logic;
|
27 |
|
|
ready : out std_logic
|
28 |
|
|
);
|
29 |
|
|
end cordic;
|
30 |
|
|
|
31 |
|
|
architecture fsmd of cordic is
|
32 |
|
|
type state_type is (S_ENTRY, S_EXIT, S_001_001, S_002_001, S_003_001, S_004_001);
|
33 |
|
|
signal current_state, next_state: state_type;
|
34 |
|
|
signal cordic_hyp_steps : cordic_hyp_steps_type := (
|
35 |
|
|
14 => "0000000000001101",
|
36 |
|
|
13 => "0000000000001101",
|
37 |
|
|
12 => "0000000000001100",
|
38 |
|
|
11 => "0000000000001011",
|
39 |
|
|
10 => "0000000000001010",
|
40 |
|
|
9 => "0000000000001001",
|
41 |
|
|
8 => "0000000000001000",
|
42 |
|
|
7 => "0000000000000111",
|
43 |
|
|
6 => "0000000000000110",
|
44 |
|
|
5 => "0000000000000101",
|
45 |
|
|
4 => "0000000000000100",
|
46 |
|
|
3 => "0000000000000100",
|
47 |
|
|
2 => "0000000000000011",
|
48 |
|
|
1 => "0000000000000010",
|
49 |
|
|
|
50 |
|
|
others => (others => '0'));
|
51 |
|
|
signal cordic_tab : cordic_tab_type := (
|
52 |
|
|
41 => "0000000000000001",
|
53 |
|
|
40 => "0000000000000011",
|
54 |
|
|
39 => "0000000000000111",
|
55 |
|
|
38 => "0000000000001111",
|
56 |
|
|
37 => "0000000000011111",
|
57 |
|
|
36 => "0000000000111111",
|
58 |
|
|
35 => "0000000001111111",
|
59 |
|
|
34 => "0000000011111111",
|
60 |
|
|
33 => "0000000111111111",
|
61 |
|
|
32 => "0000001111111110",
|
62 |
|
|
31 => "0000011111110101",
|
63 |
|
|
30 => "0000111110101101",
|
64 |
|
|
29 => "0001110110101100",
|
65 |
|
|
28 => "0011001001000011",
|
66 |
|
|
27 => "0000000000000010",
|
67 |
|
|
26 => "0000000000000100",
|
68 |
|
|
25 => "0000000000001000",
|
69 |
|
|
24 => "0000000000010000",
|
70 |
|
|
23 => "0000000000100000",
|
71 |
|
|
22 => "0000000001000000",
|
72 |
|
|
21 => "0000000010000000",
|
73 |
|
|
20 => "0000000100000000",
|
74 |
|
|
19 => "0000001000000000",
|
75 |
|
|
18 => "0000010000000000",
|
76 |
|
|
17 => "0000100000000000",
|
77 |
|
|
16 => "0001000000000000",
|
78 |
|
|
15 => "0010000000000000",
|
79 |
|
|
14 => "0100000000000000",
|
80 |
|
|
13 => "0000000000000010",
|
81 |
|
|
12 => "0000000000000100",
|
82 |
|
|
11 => "0000000000001000",
|
83 |
|
|
10 => "0000000000010000",
|
84 |
|
|
9 => "0000000000100000",
|
85 |
|
|
8 => "0000000001000000",
|
86 |
|
|
7 => "0000000010000000",
|
87 |
|
|
6 => "0000000100000000",
|
88 |
|
|
5 => "0000001000000000",
|
89 |
|
|
4 => "0000010000000001",
|
90 |
|
|
3 => "0000100000001010",
|
91 |
|
|
2 => "0001000001011000",
|
92 |
|
|
1 => "0010001100100111",
|
93 |
|
|
|
94 |
|
|
others => (others => '0'));
|
95 |
|
|
signal t5_next : std_logic_vector(15 downto 0);
|
96 |
|
|
signal t5_reg : std_logic_vector(15 downto 0);
|
97 |
|
|
signal x2_next : std_logic_vector(15 downto 0);
|
98 |
|
|
signal x2_reg : std_logic_vector(15 downto 0);
|
99 |
|
|
signal y1_next : std_logic_vector(15 downto 0);
|
100 |
|
|
signal y1_reg : std_logic_vector(15 downto 0);
|
101 |
|
|
signal z2_next : std_logic_vector(15 downto 0);
|
102 |
|
|
signal z2_reg : std_logic_vector(15 downto 0);
|
103 |
|
|
signal k_next : std_logic_vector(15 downto 0);
|
104 |
|
|
signal k_reg : std_logic_vector(15 downto 0);
|
105 |
|
|
signal zero_next : std_logic_vector(15 downto 0);
|
106 |
|
|
signal zero_reg : std_logic_vector(15 downto 0);
|
107 |
|
|
signal one_next : std_logic_vector(15 downto 0);
|
108 |
|
|
signal one_reg : std_logic_vector(15 downto 0);
|
109 |
|
|
signal t1_next : std_logic_vector(15 downto 0);
|
110 |
|
|
signal t1_reg : std_logic_vector(15 downto 0);
|
111 |
|
|
signal tabval_next : std_logic_vector(15 downto 0);
|
112 |
|
|
signal tabval_reg : std_logic_vector(15 downto 0);
|
113 |
|
|
signal x_next : std_logic_vector(15 downto 0);
|
114 |
|
|
signal x_reg : std_logic_vector(15 downto 0);
|
115 |
|
|
signal y_next : std_logic_vector(15 downto 0);
|
116 |
|
|
signal y_reg : std_logic_vector(15 downto 0);
|
117 |
|
|
signal z_next : std_logic_vector(15 downto 0);
|
118 |
|
|
signal z_reg : std_logic_vector(15 downto 0);
|
119 |
|
|
signal ldirection_next : std_logic_vector(15 downto 0);
|
120 |
|
|
signal ldirection_reg : std_logic_vector(15 downto 0);
|
121 |
|
|
signal lmode_next : std_logic_vector(15 downto 0);
|
122 |
|
|
signal lmode_reg : std_logic_vector(15 downto 0);
|
123 |
|
|
signal t4_next : std_logic_vector(15 downto 0);
|
124 |
|
|
signal t4_reg : std_logic_vector(15 downto 0);
|
125 |
|
|
signal ybyk_next : std_logic_vector(15 downto 0);
|
126 |
|
|
signal ybyk_reg : std_logic_vector(15 downto 0);
|
127 |
|
|
signal t7_next : std_logic_vector(15 downto 0);
|
128 |
|
|
signal t7_reg : std_logic_vector(15 downto 0);
|
129 |
|
|
signal d_next : std_logic_vector(15 downto 0);
|
130 |
|
|
signal d_reg : std_logic_vector(15 downto 0);
|
131 |
|
|
signal t0_next : std_logic_vector(15 downto 0);
|
132 |
|
|
signal t0_reg : std_logic_vector(15 downto 0);
|
133 |
|
|
signal offset_next : std_logic_vector(15 downto 0);
|
134 |
|
|
signal offset_reg : std_logic_vector(15 downto 0);
|
135 |
|
|
signal kfinal_next : std_logic_vector(15 downto 0);
|
136 |
|
|
signal kfinal_reg : std_logic_vector(15 downto 0);
|
137 |
|
|
signal kk_next : std_logic_vector(15 downto 0);
|
138 |
|
|
signal kk_reg : std_logic_vector(15 downto 0);
|
139 |
|
|
signal t9_next : std_logic_vector(15 downto 0);
|
140 |
|
|
signal t9_reg : std_logic_vector(15 downto 0);
|
141 |
|
|
signal t3_next : std_logic_vector(15 downto 0);
|
142 |
|
|
signal t3_reg : std_logic_vector(15 downto 0);
|
143 |
|
|
signal t2_next : std_logic_vector(15 downto 0);
|
144 |
|
|
signal t2_reg : std_logic_vector(15 downto 0);
|
145 |
|
|
signal xbyk_next : std_logic_vector(15 downto 0);
|
146 |
|
|
signal xbyk_reg : std_logic_vector(15 downto 0);
|
147 |
|
|
signal t6_next : std_logic_vector(15 downto 0);
|
148 |
|
|
signal t6_reg : std_logic_vector(15 downto 0);
|
149 |
|
|
signal t8_next : std_logic_vector(15 downto 0);
|
150 |
|
|
signal t8_reg : std_logic_vector(15 downto 0);
|
151 |
|
|
signal x1_next : std_logic_vector(15 downto 0);
|
152 |
|
|
signal x1_reg : std_logic_vector(15 downto 0);
|
153 |
|
|
signal y2_next : std_logic_vector(15 downto 0);
|
154 |
|
|
signal y2_reg : std_logic_vector(15 downto 0);
|
155 |
|
|
signal z1_next : std_logic_vector(15 downto 0);
|
156 |
|
|
signal z1_reg : std_logic_vector(15 downto 0);
|
157 |
|
|
signal zout_next : std_logic_vector(15 downto 0);
|
158 |
|
|
signal zout_reg : std_logic_vector(15 downto 0);
|
159 |
|
|
signal yout_next : std_logic_vector(15 downto 0);
|
160 |
|
|
signal yout_reg : std_logic_vector(15 downto 0);
|
161 |
|
|
signal xout_next : std_logic_vector(15 downto 0);
|
162 |
|
|
signal xout_reg : std_logic_vector(15 downto 0);
|
163 |
|
|
constant CNST_28 : std_logic_vector(15 downto 0) := "0000000000011100";
|
164 |
|
|
constant CNST_2 : std_logic_vector(15 downto 0) := "0000000000000010";
|
165 |
|
|
constant CNST_15 : std_logic_vector(15 downto 0) := "0000000000001111";
|
166 |
|
|
constant CNST_14 : std_logic_vector(15 downto 0) := "0000000000001110";
|
167 |
|
|
constant CNST_1 : std_logic_vector(15 downto 0) := "0000000000000001";
|
168 |
|
|
constant CNST_0 : std_logic_vector(15 downto 0) := "0000000000000000";
|
169 |
|
|
begin
|
170 |
|
|
-- current state logic
|
171 |
|
|
process (clk, reset)
|
172 |
|
|
begin
|
173 |
|
|
if (reset = '1') then
|
174 |
|
|
current_state <= S_ENTRY;
|
175 |
|
|
t5_reg <= (others => '0');
|
176 |
|
|
x2_reg <= (others => '0');
|
177 |
|
|
y1_reg <= (others => '0');
|
178 |
|
|
z2_reg <= (others => '0');
|
179 |
|
|
k_reg <= (others => '0');
|
180 |
|
|
zero_reg <= (others => '0');
|
181 |
|
|
one_reg <= (others => '0');
|
182 |
|
|
t1_reg <= (others => '0');
|
183 |
|
|
tabval_reg <= (others => '0');
|
184 |
|
|
x_reg <= (others => '0');
|
185 |
|
|
y_reg <= (others => '0');
|
186 |
|
|
z_reg <= (others => '0');
|
187 |
|
|
ldirection_reg <= (others => '0');
|
188 |
|
|
lmode_reg <= (others => '0');
|
189 |
|
|
t4_reg <= (others => '0');
|
190 |
|
|
ybyk_reg <= (others => '0');
|
191 |
|
|
t7_reg <= (others => '0');
|
192 |
|
|
d_reg <= (others => '0');
|
193 |
|
|
t0_reg <= (others => '0');
|
194 |
|
|
offset_reg <= (others => '0');
|
195 |
|
|
kfinal_reg <= (others => '0');
|
196 |
|
|
kk_reg <= (others => '0');
|
197 |
|
|
t9_reg <= (others => '0');
|
198 |
|
|
t3_reg <= (others => '0');
|
199 |
|
|
t2_reg <= (others => '0');
|
200 |
|
|
xbyk_reg <= (others => '0');
|
201 |
|
|
t6_reg <= (others => '0');
|
202 |
|
|
t8_reg <= (others => '0');
|
203 |
|
|
x1_reg <= (others => '0');
|
204 |
|
|
y2_reg <= (others => '0');
|
205 |
|
|
z1_reg <= (others => '0');
|
206 |
|
|
zout_reg <= (others => '0');
|
207 |
|
|
yout_reg <= (others => '0');
|
208 |
|
|
xout_reg <= (others => '0');
|
209 |
|
|
elsif (clk = '1' and clk'EVENT) then
|
210 |
|
|
current_state <= next_state;
|
211 |
|
|
t5_reg <= t5_next;
|
212 |
|
|
x2_reg <= x2_next;
|
213 |
|
|
y1_reg <= y1_next;
|
214 |
|
|
z2_reg <= z2_next;
|
215 |
|
|
k_reg <= k_next;
|
216 |
|
|
zero_reg <= zero_next;
|
217 |
|
|
one_reg <= one_next;
|
218 |
|
|
t1_reg <= t1_next;
|
219 |
|
|
tabval_reg <= tabval_next;
|
220 |
|
|
x_reg <= x_next;
|
221 |
|
|
y_reg <= y_next;
|
222 |
|
|
z_reg <= z_next;
|
223 |
|
|
ldirection_reg <= ldirection_next;
|
224 |
|
|
lmode_reg <= lmode_next;
|
225 |
|
|
t4_reg <= t4_next;
|
226 |
|
|
ybyk_reg <= ybyk_next;
|
227 |
|
|
t7_reg <= t7_next;
|
228 |
|
|
d_reg <= d_next;
|
229 |
|
|
t0_reg <= t0_next;
|
230 |
|
|
offset_reg <= offset_next;
|
231 |
|
|
kfinal_reg <= kfinal_next;
|
232 |
|
|
kk_reg <= kk_next;
|
233 |
|
|
t9_reg <= t9_next;
|
234 |
|
|
t3_reg <= t3_next;
|
235 |
|
|
t2_reg <= t2_next;
|
236 |
|
|
xbyk_reg <= xbyk_next;
|
237 |
|
|
t6_reg <= t6_next;
|
238 |
|
|
t8_reg <= t8_next;
|
239 |
|
|
x1_reg <= x1_next;
|
240 |
|
|
y2_reg <= y2_next;
|
241 |
|
|
z1_reg <= z1_next;
|
242 |
|
|
zout_reg <= zout_next;
|
243 |
|
|
yout_reg <= yout_next;
|
244 |
|
|
xout_reg <= xout_next;
|
245 |
|
|
end if;
|
246 |
|
|
end process;
|
247 |
|
|
|
248 |
|
|
-- next state and output logic
|
249 |
|
|
process (current_state, start,
|
250 |
|
|
direction,
|
251 |
|
|
mode,
|
252 |
|
|
xin,
|
253 |
|
|
yin,
|
254 |
|
|
zin,
|
255 |
|
|
xout_reg,
|
256 |
|
|
yout_reg,
|
257 |
|
|
zout_reg,
|
258 |
|
|
t5_reg, t5_next,
|
259 |
|
|
x2_reg, x2_next,
|
260 |
|
|
y1_reg, y1_next,
|
261 |
|
|
z2_reg, z2_next,
|
262 |
|
|
k_reg, k_next,
|
263 |
|
|
zero_reg, zero_next,
|
264 |
|
|
one_reg, one_next,
|
265 |
|
|
t1_reg, t1_next,
|
266 |
|
|
tabval_reg, tabval_next,
|
267 |
|
|
x_reg, x_next,
|
268 |
|
|
y_reg, y_next,
|
269 |
|
|
z_reg, z_next,
|
270 |
|
|
ldirection_reg, ldirection_next,
|
271 |
|
|
lmode_reg, lmode_next,
|
272 |
|
|
t4_reg, t4_next,
|
273 |
|
|
ybyk_reg, ybyk_next,
|
274 |
|
|
t7_reg, t7_next,
|
275 |
|
|
d_reg, d_next,
|
276 |
|
|
t0_reg, t0_next,
|
277 |
|
|
offset_reg, offset_next,
|
278 |
|
|
kfinal_reg, kfinal_next,
|
279 |
|
|
kk_reg, kk_next,
|
280 |
|
|
t9_reg, t9_next,
|
281 |
|
|
t3_reg, t3_next,
|
282 |
|
|
t2_reg, t2_next,
|
283 |
|
|
xbyk_reg, xbyk_next,
|
284 |
|
|
t6_reg, t6_next,
|
285 |
|
|
t8_reg, t8_next,
|
286 |
|
|
x1_reg, x1_next,
|
287 |
|
|
y2_reg, y2_next,
|
288 |
|
|
z1_reg, z1_next
|
289 |
|
|
)
|
290 |
|
|
begin
|
291 |
|
|
done <= '0';
|
292 |
|
|
ready <= '0';
|
293 |
|
|
t5_next <= t5_reg;
|
294 |
|
|
x2_next <= x2_reg;
|
295 |
|
|
y1_next <= y1_reg;
|
296 |
|
|
z2_next <= z2_reg;
|
297 |
|
|
k_next <= k_reg;
|
298 |
|
|
zero_next <= zero_reg;
|
299 |
|
|
one_next <= one_reg;
|
300 |
|
|
t1_next <= t1_reg;
|
301 |
|
|
tabval_next <= tabval_reg;
|
302 |
|
|
x_next <= x_reg;
|
303 |
|
|
y_next <= y_reg;
|
304 |
|
|
z_next <= z_reg;
|
305 |
|
|
ldirection_next <= ldirection_reg;
|
306 |
|
|
lmode_next <= lmode_reg;
|
307 |
|
|
t4_next <= t4_reg;
|
308 |
|
|
ybyk_next <= ybyk_reg;
|
309 |
|
|
t7_next <= t7_reg;
|
310 |
|
|
d_next <= d_reg;
|
311 |
|
|
t0_next <= t0_reg;
|
312 |
|
|
offset_next <= offset_reg;
|
313 |
|
|
kfinal_next <= kfinal_reg;
|
314 |
|
|
kk_next <= kk_reg;
|
315 |
|
|
t9_next <= t9_reg;
|
316 |
|
|
t3_next <= t3_reg;
|
317 |
|
|
t2_next <= t2_reg;
|
318 |
|
|
xbyk_next <= xbyk_reg;
|
319 |
|
|
t6_next <= t6_reg;
|
320 |
|
|
t8_next <= t8_reg;
|
321 |
|
|
x1_next <= x1_reg;
|
322 |
|
|
y2_next <= y2_reg;
|
323 |
|
|
z1_next <= z1_reg;
|
324 |
|
|
zout_next <= zout_reg;
|
325 |
|
|
yout_next <= yout_reg;
|
326 |
|
|
xout_next <= xout_reg;
|
327 |
|
|
case current_state is
|
328 |
|
|
when S_ENTRY =>
|
329 |
|
|
ready <= '1';
|
330 |
|
|
if (start = '1') then
|
331 |
|
|
next_state <= S_001_001;
|
332 |
|
|
else
|
333 |
|
|
next_state <= S_ENTRY;
|
334 |
|
|
end if;
|
335 |
|
|
when S_001_001 =>
|
336 |
|
|
zero_next <= CNST_0(15 downto 0);
|
337 |
|
|
one_next <= CNST_1(15 downto 0);
|
338 |
|
|
x_next <= xin(15 downto 0);
|
339 |
|
|
y_next <= yin(15 downto 0);
|
340 |
|
|
z_next <= zin(15 downto 0);
|
341 |
|
|
ldirection_next <= direction(15 downto 0);
|
342 |
|
|
lmode_next <= mode(15 downto 0);
|
343 |
|
|
k_next <= CNST_0(15 downto 0);
|
344 |
|
|
if (lmode_next = CNST_1(15 downto 0)) then
|
345 |
|
|
t0_next <= CNST_14(15 downto 0);
|
346 |
|
|
else
|
347 |
|
|
t0_next <= CNST_28(15 downto 0);
|
348 |
|
|
end if;
|
349 |
|
|
if (lmode_next = CNST_2(15 downto 0)) then
|
350 |
|
|
offset_next <= CNST_0(15 downto 0);
|
351 |
|
|
else
|
352 |
|
|
offset_next <= t0_next(15 downto 0);
|
353 |
|
|
end if;
|
354 |
|
|
if (lmode_next = CNST_2(15 downto 0)) then
|
355 |
|
|
kfinal_next <= CNST_15(15 downto 0);
|
356 |
|
|
else
|
357 |
|
|
kfinal_next <= CNST_14(15 downto 0);
|
358 |
|
|
end if;
|
359 |
|
|
next_state <= S_002_001;
|
360 |
|
|
when S_002_001 =>
|
361 |
|
|
if (k_reg < kfinal_reg(15 downto 0)) then
|
362 |
|
|
next_state <= S_003_001;
|
363 |
|
|
else
|
364 |
|
|
next_state <= S_004_001;
|
365 |
|
|
end if;
|
366 |
|
|
when S_003_001 =>
|
367 |
|
|
t1_next <= cordic_hyp_steps(to_integer(unsigned(k_reg(3 downto 0))));
|
368 |
|
|
if (lmode_reg /= CNST_2(15 downto 0)) then
|
369 |
|
|
kk_next <= k_reg(15 downto 0);
|
370 |
|
|
else
|
371 |
|
|
kk_next <= t1_next(15 downto 0);
|
372 |
|
|
end if;
|
373 |
|
|
t2_next <= shrv4(y_reg, kk_next, '1');
|
374 |
|
|
t3_next <= std_logic_vector(not(unsigned(t2_next(15 downto 0))) + unsigned(ONE));
|
375 |
|
|
xbyk_next <= shrv4(x_reg, kk_next, '1');
|
376 |
|
|
if (lmode_reg = CNST_1(15 downto 0)) then
|
377 |
|
|
t4_next <= zero_reg(15 downto 0);
|
378 |
|
|
else
|
379 |
|
|
t4_next <= t2_next(15 downto 0);
|
380 |
|
|
end if;
|
381 |
|
|
if (lmode_reg = CNST_2(15 downto 0)) then
|
382 |
|
|
ybyk_next <= t3_next(15 downto 0);
|
383 |
|
|
else
|
384 |
|
|
ybyk_next <= t4_next(15 downto 0);
|
385 |
|
|
end if;
|
386 |
|
|
t5_next <= std_logic_vector(signed(kk_next) + signed(offset_reg(15 downto 0)));
|
387 |
|
|
tabval_next <= cordic_tab(to_integer(unsigned(t5_next(5 downto 0))));
|
388 |
|
|
t6_next(15 downto 1) <= (others => z_reg(15));
|
389 |
|
|
t6_next(0 downto 0) <= z_reg(15 downto 15);
|
390 |
|
|
if (t6_next = CNST_0(15 downto 0)) then
|
391 |
|
|
t7_next <= zero_reg(15 downto 0);
|
392 |
|
|
else
|
393 |
|
|
t7_next <= one_reg(15 downto 0);
|
394 |
|
|
end if;
|
395 |
|
|
t8_next(15 downto 1) <= (others => y_reg(15));
|
396 |
|
|
t8_next(0 downto 0) <= y_reg(15 downto 15);
|
397 |
|
|
if (t8_next /= CNST_0(15 downto 0)) then
|
398 |
|
|
t9_next <= zero_reg(15 downto 0);
|
399 |
|
|
else
|
400 |
|
|
t9_next <= one_reg(15 downto 0);
|
401 |
|
|
end if;
|
402 |
|
|
if (ldirection_reg = CNST_0(15 downto 0)) then
|
403 |
|
|
d_next <= t7_next(15 downto 0);
|
404 |
|
|
else
|
405 |
|
|
d_next <= t9_next(15 downto 0);
|
406 |
|
|
end if;
|
407 |
|
|
x1_next <= std_logic_vector(signed(x_reg) - signed(ybyk_next(15 downto 0)));
|
408 |
|
|
x2_next <= std_logic_vector(signed(x_reg) + signed(ybyk_next(15 downto 0)));
|
409 |
|
|
y1_next <= std_logic_vector(signed(y_reg) + signed(xbyk_next(15 downto 0)));
|
410 |
|
|
y2_next <= std_logic_vector(signed(y_reg) - signed(xbyk_next(15 downto 0)));
|
411 |
|
|
z1_next <= std_logic_vector(signed(z_reg) - signed(tabval_next(15 downto 0)));
|
412 |
|
|
z2_next <= std_logic_vector(signed(z_reg) + signed(tabval_next(15 downto 0)));
|
413 |
|
|
if (d_next = CNST_0(15 downto 0)) then
|
414 |
|
|
x_next <= x1_next(15 downto 0);
|
415 |
|
|
else
|
416 |
|
|
x_next <= x2_next(15 downto 0);
|
417 |
|
|
end if;
|
418 |
|
|
if (d_next = CNST_0(15 downto 0)) then
|
419 |
|
|
y_next <= y1_next(15 downto 0);
|
420 |
|
|
else
|
421 |
|
|
y_next <= y2_next(15 downto 0);
|
422 |
|
|
end if;
|
423 |
|
|
if (d_next = CNST_0(15 downto 0)) then
|
424 |
|
|
z_next <= z1_next(15 downto 0);
|
425 |
|
|
else
|
426 |
|
|
z_next <= z2_next(15 downto 0);
|
427 |
|
|
end if;
|
428 |
|
|
k_next <= std_logic_vector(signed(k_reg) + signed(CNST_1(15 downto 0)));
|
429 |
|
|
if (k_next < kfinal_reg(15 downto 0)) then
|
430 |
|
|
next_state <= S_003_001;
|
431 |
|
|
else
|
432 |
|
|
next_state <= S_004_001;
|
433 |
|
|
end if;
|
434 |
|
|
when S_004_001 =>
|
435 |
|
|
xout_next <= x_reg(15 downto 0);
|
436 |
|
|
yout_next <= y_reg(15 downto 0);
|
437 |
|
|
zout_next <= z_reg(15 downto 0);
|
438 |
|
|
next_state <= S_EXIT;
|
439 |
|
|
when S_EXIT =>
|
440 |
|
|
done <= '1';
|
441 |
|
|
next_state <= S_ENTRY;
|
442 |
|
|
end case;
|
443 |
|
|
end process;
|
444 |
|
|
|
445 |
|
|
zout <= zout_reg;
|
446 |
|
|
yout <= yout_reg;
|
447 |
|
|
xout <= xout_reg;
|
448 |
|
|
|
449 |
|
|
end fsmd;
|