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

Subversion Repositories spi_boot

[/] [spi_boot/] [tags/] [rel_1_0_rev_A/] [bench/] [vhdl/] [tb_pack-p.vhd] - Blame information for rev 74

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 4 arniml
-------------------------------------------------------------------------------
2
--
3
-- SD/MMC Bootloader
4
--
5
-- $Id: tb_pack-p.vhd,v 1.1 2005-02-08 21:09:20 arniml Exp $
6
--
7
-------------------------------------------------------------------------------
8
 
9
library ieee;
10
use ieee.std_logic_1164.all;
11
use ieee.numeric_std.all;
12
 
13
package tb_pack is
14
 
15
  function calc_crc(payload : in std_logic_vector) return std_logic_vector;
16
  function calc_crc(payload : in unsigned) return unsigned;
17
 
18
end tb_pack;
19
 
20
 
21
package body tb_pack is
22
 
23
  function calc_crc(payload : in std_logic_vector) return std_logic_vector is
24
 
25
    variable crc_v  : std_logic_vector(6 downto 0);
26
    variable temp_v : std_logic;
27
 
28
  begin
29
 
30
    crc_v := (others => '0');
31
 
32
    for i in payload'high downto payload'low loop
33
      temp_v := payload(i) xor crc_v(6);
34
 
35
      crc_v(6 downto 4) := crc_v(5 downto 3);
36
      crc_v(3) := crc_v(2) xor temp_v;
37
      crc_v(2 downto 1) := crc_v(1 downto 0);
38
      crc_v(0) := temp_v;
39
    end loop;
40
 
41
    return crc_v;
42
  end calc_crc;
43
 
44
  function calc_crc(payload : in unsigned) return unsigned is
45
  begin
46
    return unsigned(calc_crc(std_logic_vector(payload)));
47
  end calc_crc;
48
 
49
end tb_pack;
50
 
51
 
52
-------------------------------------------------------------------------------
53
-- File History:
54
--
55
-- $Log: not supported by cvs2svn $
56
-------------------------------------------------------------------------------

powered by: WebSVN 2.1.0

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