1 |
4 |
DFC |
--
|
2 |
|
|
-- crc32_gen_fsm.vhd: FSM for crc32_gen module
|
3 |
|
|
-- Copyright (C) 2011 CESNET
|
4 |
|
|
-- Author(s): Lukas Kekely <xkekel00@stud.fit.vutbr.cz>
|
5 |
|
|
--
|
6 |
|
|
-- Redistribution and use in source and binary forms, with or without
|
7 |
|
|
-- modification, are permitted provided that the following conditions
|
8 |
|
|
-- are met:
|
9 |
|
|
-- 1. Redistributions of source code must retain the above copyright
|
10 |
|
|
-- notice, this list of conditions and the following disclaimer.
|
11 |
|
|
-- 2. Redistributions in binary form must reproduce the above copyright
|
12 |
|
|
-- notice, this list of conditions and the following disclaimer in
|
13 |
|
|
-- the documentation and/or other materials provided with the
|
14 |
|
|
-- distribution.
|
15 |
|
|
-- 3. Neither the name of the Company nor the names of its contributors
|
16 |
|
|
-- may be used to endorse or promote products derived from this
|
17 |
|
|
-- software without specific prior written permission.
|
18 |
|
|
--
|
19 |
|
|
-- This software is provided ``as is'', and any express or implied
|
20 |
|
|
-- warranties, including, but not limited to, the implied warranties of
|
21 |
|
|
-- merchantability and fitness for a particular purpose are disclaimed.
|
22 |
|
|
-- In no event shall the company or contributors be liable for any
|
23 |
|
|
-- direct, indirect, incidental, special, exemplary, or consequential
|
24 |
|
|
-- damages (including, but not limited to, procurement of substitute
|
25 |
|
|
-- goods or services; loss of use, data, or profits; or business
|
26 |
|
|
-- interruption) however caused and on any theory of liability, whether
|
27 |
|
|
-- in contract, strict liability, or tort (including negligence or
|
28 |
|
|
-- otherwise) arising in any way out of the use of this software, even
|
29 |
|
|
-- if advised of the possibility of such damage.
|
30 |
|
|
--
|
31 |
|
|
-- $Id$
|
32 |
|
|
--
|
33 |
|
|
-- TODO:
|
34 |
|
|
--
|
35 |
|
|
--
|
36 |
|
|
|
37 |
|
|
library IEEE;
|
38 |
|
|
use IEEE.std_logic_1164.all;
|
39 |
|
|
-- ----------------------------------------------------------------------------
|
40 |
|
|
-- Entity declaration
|
41 |
|
|
-- ----------------------------------------------------------------------------
|
42 |
|
|
entity crc32_gen_fsm is
|
43 |
|
|
port(
|
44 |
|
|
CLK: in std_logic;
|
45 |
|
|
RESET: in std_logic;
|
46 |
|
|
DI_DV: in std_logic;
|
47 |
|
|
EOP: in std_logic;
|
48 |
|
|
TCTL: out std_logic
|
49 |
|
|
);
|
50 |
|
|
end entity crc32_gen_fsm;
|
51 |
|
|
|
52 |
|
|
-- ----------------------------------------------------------------------------
|
53 |
|
|
-- Architecture declaration
|
54 |
|
|
-- ----------------------------------------------------------------------------
|
55 |
|
|
architecture crc32_gen_fsm_arch of crc32_gen_fsm is
|
56 |
|
|
|
57 |
|
|
type fsm_states is (SL, SC);
|
58 |
|
|
signal curr_state, next_state : fsm_states;
|
59 |
|
|
|
60 |
|
|
begin
|
61 |
|
|
-- -------------------------------------------------------
|
62 |
|
|
sync_logic : process(RESET, CLK)
|
63 |
|
|
begin
|
64 |
|
|
if (RESET = '1') then
|
65 |
|
|
curr_state <= SL;
|
66 |
|
|
elsif (CLK'event AND CLK = '1') then
|
67 |
|
|
curr_state <= next_state;
|
68 |
|
|
end if;
|
69 |
|
|
end process sync_logic;
|
70 |
|
|
|
71 |
|
|
-- -------------------------------------------------------
|
72 |
|
|
next_state_logic : process(curr_state, DI_DV, EOP)
|
73 |
|
|
begin
|
74 |
|
|
case (curr_state) is
|
75 |
|
|
when SL =>
|
76 |
|
|
if EOP = '0' AND DI_DV = '1' then
|
77 |
|
|
next_state <= SC;
|
78 |
|
|
else
|
79 |
|
|
next_state <= SL;
|
80 |
|
|
end if;
|
81 |
|
|
when SC =>
|
82 |
|
|
if EOP = '1' AND DI_DV = '1' then
|
83 |
|
|
next_state <= SL;
|
84 |
|
|
else
|
85 |
|
|
next_state <= SC;
|
86 |
|
|
end if;
|
87 |
|
|
when others => next_state <= SL;
|
88 |
|
|
end case;
|
89 |
|
|
end process next_state_logic;
|
90 |
|
|
|
91 |
|
|
-- -------------------------------------------------------
|
92 |
|
|
output_logic : process(curr_state, DI_DV, EOP)
|
93 |
|
|
begin
|
94 |
|
|
case (curr_state) is
|
95 |
|
|
when SL =>
|
96 |
|
|
TCTL <= '1';
|
97 |
|
|
when SC =>
|
98 |
|
|
TCTL <= '0';
|
99 |
|
|
when others =>
|
100 |
|
|
TCTL <= '1';
|
101 |
|
|
end case;
|
102 |
|
|
end process output_logic;
|
103 |
|
|
|
104 |
|
|
end architecture crc32_gen_fsm_arch;
|
105 |
|
|
|