Hardware Reference
In-Depth Information
21
signal i, i_reg: natural range 0 to N;
22
23 begin
24
25
--Auxiliary register:
26
process (clk, rst)
27
begin
28
if rst='1' then
29
i_reg <= 0;
30
y_reg
<
= (others =
>
'0');
31
elsif rising_edge(clk) then
32
i_reg <= i;
33
y_reg <= y;
34
end if;
35
end process;
36
37
--FSM state register:
38
process (clk, rst)
39
begin
40
if rst='1' then
41
pr_state <= idle;
42
elsif rising_edge(clk) then
43
pr_state <= nx_state;
44
end if;
45
end process;
46
47
--FSM combinational logic:
48
process (all)
49
begin
50
case pr_state is
51
when idle =>
52
i <= 0;
53
y <= y_reg;
54
done <= '1';
55
if dv='1' and x='0' then
56
nx_state <= store0;
57
elsif dv='1' and x='1' then
58
nx_state <= store1;
59
else
60
nx_state <= idle;
61
end if;
62
when store0 =>
63
i <= i_reg + 1;
64
y <= y_reg;
65
y(i-1) <= '0';
66
done <= '0';
67
if i=N then
68
nx_state <= idle;
69
elsif x='1' then
70
nx_state
<
= store1;
71
else
72
nx_state
<
= store0;
73
end if;
74
when store1 =>
75
i <= i_reg + 1;
76
y
<
= y_reg;
Search WWH ::




Custom Search