1 |
2 |
wfjm |
-- $Id: gen_crc8_tbl_check.vhd 314 2010-07-09 17:38:41Z mueller $
|
2 |
|
|
--
|
3 |
|
|
-- Copyright 2007- by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
|
4 |
|
|
--
|
5 |
|
|
-- This program is free software; you may redistribute and/or modify it under
|
6 |
|
|
-- the terms of the GNU General Public License as published by the Free
|
7 |
|
|
-- Software Foundation, either version 2, or at your option any later version.
|
8 |
|
|
--
|
9 |
|
|
-- This program is distributed in the hope that it will be useful, but
|
10 |
|
|
-- WITHOUT ANY WARRANTY, without even the implied warranty of MERCHANTABILITY
|
11 |
|
|
-- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
12 |
|
|
-- for complete details.
|
13 |
|
|
--
|
14 |
|
|
------------------------------------------------------------------------------
|
15 |
|
|
-- Module Name: gen_crc8_tbl - sim
|
16 |
|
|
-- Description: stand-alone program to test crc8 transition table
|
17 |
|
|
--
|
18 |
|
|
-- Dependencies: -
|
19 |
|
|
--
|
20 |
|
|
-- Revision History:
|
21 |
|
|
-- Date Rev Version Comment
|
22 |
|
|
-- 2007-10-12 88 1.0.1 avoid ieee.std_logic_unsigned, use cast to unsigned
|
23 |
|
|
-- 2007-07-08 65 1.0 Initial version
|
24 |
|
|
------------------------------------------------------------------------------
|
25 |
|
|
|
26 |
|
|
library ieee;
|
27 |
|
|
use ieee.std_logic_1164.all;
|
28 |
|
|
use ieee.std_logic_arith.all;
|
29 |
|
|
use ieee.std_logic_textio.all;
|
30 |
|
|
use std.textio.all;
|
31 |
|
|
|
32 |
|
|
--use work.slvtypes.all;
|
33 |
|
|
--use work.comlib.all;
|
34 |
|
|
|
35 |
|
|
entity gen_crc8_tbl_check is
|
36 |
|
|
end gen_crc8_tbl_check;
|
37 |
|
|
|
38 |
|
|
architecture sim of gen_crc8_tbl_check is
|
39 |
|
|
begin
|
40 |
|
|
|
41 |
|
|
process
|
42 |
|
|
type crc8_tbl_type is array (0 to 255) of integer;
|
43 |
|
|
|
44 |
|
|
variable crc8_tbl : crc8_tbl_type := -- generated with gen_crc8_tbl
|
45 |
|
|
( 0, 29, 58, 39, 116, 105, 78, 83,
|
46 |
|
|
232, 245, 210, 207, 156, 129, 166, 187,
|
47 |
|
|
205, 208, 247, 234, 185, 164, 131, 158,
|
48 |
|
|
37, 56, 31, 2, 81, 76, 107, 118,
|
49 |
|
|
135, 154, 189, 160, 243, 238, 201, 212,
|
50 |
|
|
111, 114, 85, 72, 27, 6, 33, 60,
|
51 |
|
|
74, 87, 112, 109, 62, 35, 4, 25,
|
52 |
|
|
162, 191, 152, 133, 214, 203, 236, 241,
|
53 |
|
|
19, 14, 41, 52, 103, 122, 93, 64,
|
54 |
|
|
251, 230, 193, 220, 143, 146, 181, 168,
|
55 |
|
|
222, 195, 228, 249, 170, 183, 144, 141,
|
56 |
|
|
54, 43, 12, 17, 66, 95, 120, 101,
|
57 |
|
|
148, 137, 174, 179, 224, 253, 218, 199,
|
58 |
|
|
124, 97, 70, 91, 8, 21, 50, 47,
|
59 |
|
|
89, 68, 99, 126, 45, 48, 23, 10,
|
60 |
|
|
177, 172, 139, 150, 197, 216, 255, 226,
|
61 |
|
|
38, 59, 28, 1, 82, 79, 104, 117,
|
62 |
|
|
206, 211, 244, 233, 186, 167, 128, 157,
|
63 |
|
|
235, 246, 209, 204, 159, 130, 165, 184,
|
64 |
|
|
3, 30, 57, 36, 119, 106, 77, 80,
|
65 |
|
|
161, 188, 155, 134, 213, 200, 239, 242,
|
66 |
|
|
73, 84, 115, 110, 61, 32, 7, 26,
|
67 |
|
|
108, 113, 86, 75, 24, 5, 34, 63,
|
68 |
|
|
132, 153, 190, 163, 240, 237, 202, 215,
|
69 |
|
|
53, 40, 15, 18, 65, 92, 123, 102,
|
70 |
|
|
221, 192, 231, 250, 169, 180, 147, 142,
|
71 |
|
|
248, 229, 194, 223, 140, 145, 182, 171,
|
72 |
|
|
16, 13, 42, 55, 100, 121, 94, 67,
|
73 |
|
|
178, 175, 136, 149, 198, 219, 252, 225,
|
74 |
|
|
90, 71, 96, 125, 46, 51, 20, 9,
|
75 |
|
|
127, 98, 69, 88, 11, 22, 49, 44,
|
76 |
|
|
151, 138, 173, 176, 227, 254, 217, 196
|
77 |
|
|
);
|
78 |
|
|
|
79 |
|
|
variable crc : integer := 0;
|
80 |
|
|
variable oline : line;
|
81 |
|
|
|
82 |
|
|
begin
|
83 |
|
|
|
84 |
|
|
loop_i: for i in 0 to 255 loop
|
85 |
|
|
write(oline, i, right, 4);
|
86 |
|
|
write(oline, string'(": cycle length = "));
|
87 |
|
|
crc := i;
|
88 |
|
|
loop_n: for n in 1 to 256 loop
|
89 |
|
|
crc := crc8_tbl(crc);
|
90 |
|
|
if crc = i then
|
91 |
|
|
write(oline, n, right, 4);
|
92 |
|
|
writeline(output, oline);
|
93 |
|
|
exit loop_n;
|
94 |
|
|
end if;
|
95 |
|
|
end loop; -- n
|
96 |
|
|
end loop; -- i
|
97 |
|
|
wait;
|
98 |
|
|
end process;
|
99 |
|
|
|
100 |
|
|
end sim;
|