OpenCores
URL https://opencores.org/ocsvn/crc802154/crc802154/trunk

Subversion Repositories crc802154

[/] [crc802154/] [trunk/] [rtl/] [mac_crc_16.vhd] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 entactogen
 
2
-- Copyright (c) 2013 Antonio de la Piedra
3
 
4
-- This program is free software: you can redistribute it and/or modify
5
-- it under the terms of the GNU General Public License as published by
6
-- the Free Software Foundation, either version 3 of the License, or
7
-- (at your option) any later version.
8
 
9
-- This program is distributed in the hope that it will be useful,
10
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
11
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
-- GNU General Public License for more details.
13
 
14
-- You should have received a copy of the GNU General Public License
15
-- along with this program.  If not, see <http://www.gnu.org/licenses/>.
16
 
17
library IEEE;
18
use IEEE.STD_LOGIC_1164.ALL;
19
use IEEE.STD_LOGIC_ARITH.ALL;
20
use IEEE.STD_LOGIC_UNSIGNED.ALL;
21
 
22
entity mac_crc_16 is
23
        port (crc_clk: in std_logic;
24
              crc_rst : in std_logic;
25
              crc_en : in std_logic;
26
              crc_bit_input: in std_logic;
27
              crc_16_output : out std_logic_vector(15 downto 0));
28
end mac_crc_16;
29
 
30
architecture rtl of mac_crc_16 is
31
        signal g_reg_s : std_logic_vector(15 downto 0);
32
begin
33
 
34
        crc_check: process(crc_clk, crc_rst, crc_bit_input)
35
                variable g_reg_v: std_logic_vector(0 to 15) := (others =>'0');
36
 
37
                variable s1: std_logic := '0';
38
                variable s2: std_logic := '0';
39
                variable s3: std_logic := '0';
40
        begin
41
                if rising_edge(crc_clk) then
42
                        if crc_rst = '1' then
43
                                g_reg_v := (others=>'0');
44
 
45
                                s1 := '0';
46
                                s2 := '0';
47
                                s3 := '0';
48
 
49
                        elsif crc_en = '1' then
50
                                s1 := crc_bit_input xor g_reg_v(0);
51
                                s2 := s1 xor g_reg_v(11);
52
                                s3 := s1 xor g_reg_v(4);
53
 
54
                                g_reg_v := g_reg_v(1 to 15) & s1;
55
                                g_reg_v(10) := s2;
56
                                g_reg_v(3) := s3;
57
                        end if;
58
 
59
                end if;
60
 
61
                g_reg_s <= g_reg_v;
62
 
63
        end process;
64
 
65
        crc_16_output <= g_reg_s;
66
 
67
end rtl;
68
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.