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

Subversion Repositories rs_dec_enc

[/] [rs_dec_enc/] [trunk/] [rtl/] [RS_EN4.vhd] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 unicore
---------------------------------------------------------------------
2
----                                                             ----
3
----  Reed Solomon decoder/encoder IP core                       ----
4
----                                                             ----
5
----  Authors: Anatoliy Sergienko, Volodya Lepeha                ----
6
----  Company: Unicore Systems http://unicore.co.ua              ----
7
----                                                             ----
8
----  Downloaded from: http://www.opencores.org                  ----
9
----                                                             ----
10
---------------------------------------------------------------------
11
----                                                             ----
12
---- Copyright (C) 2006-2010 Unicore Systems LTD                 ----
13
---- www.unicore.co.ua                                           ----
14
---- o.uzenkov@unicore.co.ua                                     ----
15
----                                                             ----
16
---- This source file may be used and distributed without        ----
17
---- restriction provided that this copyright statement is not   ----
18
---- removed from the file and that any derivative work contains ----
19
---- the original copyright notice and the associated disclaimer.----
20
----                                                             ----
21
---- THIS SOFTWARE IS PROVIDED "AS IS"                           ----
22
---- AND ANY EXPRESSED OR IMPLIED WARRANTIES,                    ----
23
---- INCLUDING, BUT NOT LIMITED TO, THE IMPLIED                  ----
24
---- WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT              ----
25
---- AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.        ----
26
---- IN NO EVENT SHALL THE UNICORE SYSTEMS OR ITS                ----
27
---- CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,            ----
28
---- INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL            ----
29
---- DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT         ----
30
---- OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,               ----
31
---- DATA, OR PROFITS; OR BUSINESS INTERRUPTION)                 ----
32
---- HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,              ----
33
---- WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT              ----
34
---- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING                 ----
35
---- IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,                 ----
36
---- EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.          ----
37
----                                                             ----
38
---------------------------------------------------------------------
39
 
40
--{{ Section below this comment is automatically maintained
41
--   and may be overwritten
42
--{entity {RS_EN4} architecture {RS_EN4}}
43
 
44
library IEEE;
45
use IEEE.STD_LOGIC_1164.all;
46
use ieee.std_logic_arith.all;
47
use ieee.std_logic_unsigned.all;
48
use type1.all;
49
 
50
entity RS_EN4 is
51
 
52
--      generic( G_range:  integer := 4;
53
--              A_range:  integer := 9);
54
        port(
55
                CLK : in STD_LOGIC;
56
                RST : in STD_LOGIC;
57
                D_IN : in STD_LOGIC_VECTOR(7 downto 0);
58
                STR : in STD_LOGIC;
59
                RD : in STD_LOGIC;
60
                D_OUT : out STD_LOGIC_VECTOR(7 downto 0);
61
                SNB : out STD_LOGIC
62
                );
63
end RS_EN4;
64
 
65
--}} End of automatically maintained section
66
 
67
architecture RS_EN4 of RS_EN4 is type trom is array(0 to 255) of integer;
68
 
69
        --  GV4 : 1, 30,216,231,116      
70
 
71
        constant rm30 : trom :=
72
        (0,30,60,34,120,102,68,90,240,238,204,210,136,150,180,170,253,227,193,223,133,155,185,
73
        167,13,19,49,47,117,107,73,87,231,249,219,197,159,129,163,189,23,9,43,53,111,113,83,
74
        77,26,4,38,56,98,124,94,64,234,244,214,200,146,140,174,176,211,205,239,241,171,181,151,
75
        137,35,61,31,1,91,69,103,121,46,48,18,12,86,72,106,116,222,192,226,252,166,184,154,132,
76
        52,42,8,22,76,82,112,110,196,218,248,230,188,162,128,158,201,215,245,235,177,175,141,
77
        147,57,39,5,27,65,95,125,99,187,165,135,153,195,221,255,225,75,85,119,105,51,45,15,17,
78
        70,88,122,100,62,32,2,28,182,168,138,148,206,208,242,236,92,66,96,126,36,58,24,6,172,
79
        178,144,142,212,202,232,246,161,191,157,131,217,199,229,251,81,79,109,115,41,55,21,11,
80
        104,118,84,74,16,14,44,50,152,134,164,186,224,254,220,194,149,139,169,183,237,243,209,
81
        207,101,123,89,71,29,3,33,63,143,145,179,173,247,233,203,213,127,97,67,93,7,25,59,37,
82
        114,108,78,80,10,20,54,40,130,156,190,160,250,228,198,216);
83
 
84
 
85
        constant rm216 : trom :=
86
        (0,216,173,117,71,159,234,50,142,86,35,251,201,17,100,188,1,217,172,116,70,158,235,51,143,
87
        87,34,250,200,16,101,189,2,218,175,119,69,157,232,48,140,84,33,249,203,19,102,190,3,219,
88
        174,118,68,156,233,49,141,85,32,248,202,18,103,191,4,220,169,113,67,155,238,54,138,82,39,
89
        255,205,21,96,184,5,221,168,112,66,154,239,55,139,83,38,254,204,20,97,185,6,222,171,115,65,
90
        153,236,52,136,80,37,253,207,23,98,186,7,223,170,114,64,152,237,53,137,81,36,252,206,22,99,
91
        187,8,208,165,125,79,151,226,58,134,94,43,243,193,25,108,180,9,209,164,124,78,150,227,59,
92
        135,95,42,242,192,24,109,181,10,210,167,127,77,149,224,56,132,92,41,241,195,27,110,182,11,
93
        211,166,126,76,148,225,57,133,93,40,240,194,26,111,183,12,212,161,121,75,147,230,62,130,90,
94
        47,247,197,29,104,176,13,213,160,120,74,146,231,63,131,91,46,246,196,28,105,177,14,214,163,
95
        123,73,145,228,60,128,88,45,245,199,31,106,178,15,215,162,122,72,144,229,61,129,89,44,244,
96
        198,30,107,179
97
        );
98
 
99
 
100
        constant rm231 : trom :=
101
        (0,231,211,52,187,92,104,143,107,140,184,95,208,55,3,228,214,49,5,226,109,138,190,89,189,
102
        90,110,137,6,225,213,50,177,86,98,133,10,237,217,62,218,61,9,238,97,134,178,85,103,128,
103
        180,83,220,59,15,232,12,235,223,56,183,80,100,131,127,152,172,75,196,35,23,240,20,243,
104
        199,32,175,72,124,155,169,78,122,157,18,245,193,38,194,37,17,246,121,158,170,77,206,41,
105
        29,250,117,146,166,65,165,66,118,145,30,249,205,42,24,255,203,44,163,68,112,151,115,148,
106
        160,71,200,47,27,252,254,25,45,202,69,162,150,113,149,114,70,161,46,201,253,26,40,207,251,
107
        28,147,116,64,167,67,164,144,119,248,31,43,204,79,168,156,123,244,19,39,192,36,195,247,16,
108
        159,120,76,171,153,126,74,173,34,197,241,22,242,21,33,198,73,174,154,125,129,102,82,181,58,
109
        221,233,14,234,13,57,222,81,182,130,101,87,176,132,99,236,11,63,216,60,219,239,8,135,96,84,
110
        179,48,215,227,4,139,108,88,191,91,188,136,111,224,7,51,212,230,1,53,210,93,186,142,105,141,
111
        106,94,185,54,209,229,2
112
        );
113
 
114
        constant rm116 : trom :=
115
        (0,116,232,156,205,185,37,81,135,243,111,27,74,62,162,214,19,103,251,143,222,170,54,66,148,
116
        224,124,8,89,45,177,197,38,82,206,186,235,159,3,119,161,213,73,61,108,24,132,240,53,65,221,
117
        169,248,140,16,100,178,198,90,46,127,11,151,227,76,56,164,208,129,245,105,29,203,191,35,87,
118
        6,114,238,154,95,43,183,195,146,230,122,14,216,172,48,68,21,97,253,137,106,30,130,246,167,
119
        211,79,59,237,153,5,113,32,84,200,188,121,13,145,229,180,192,92,40,254,138,22,98,51,71,219,
120
        175,152,236,112,4,85,33,189,201,31,107,247,131,210,166,58,78,139,255,99,23,70,50,174,218,
121
        12,120,228,144,193,181,41,93,190,202,86,34,115,7,155,239,57,77,209,165,244,128,28,104,173,
122
        217,69,49,96,20,136,252,42,94,194,182,231,147,15,123,212,160,60,72,25,109,241,133,83,39,
123
        187,207,158,234,118,2,199,179,47,91,10,126,226,150,64,52,168,220,141,249,101,17,242,134,26,
124
        110,63,75,215,163,117,1,157,233,184,204,80,36,225,149,9,125,44,88,196,176,102,18,142,250,
125
        171,223,67,55
126
        );
127
        type treg is array(A_range downto 0) of std_logic_vector(7 downto 0);
128
        type treg1 is array(G_range + 1  downto 0) of std_logic_vector(7 downto 0);
129
        signal reg2 : treg;
130
        signal reg,reg1 : treg1;
131
        signal run,snb1 : std_logic;
132
        signal cnt : std_logic_vector(7 downto 0);
133
        signal pr30,pr216,pr231,pr116,sd : std_logic_vector(7 downto 0);
134
 
135
begin
136
 
137
        process(clk,rst)
138
        begin
139
                if rst = '1' then
140
                        reg <= (others => (others => '0'));
141
                        reg1 <= (others => (others => '0'));
142
                        cnt <= (others => '0');
143
                        run <= '0';
144
                        snb1 <= '0';
145
                elsif clk= '1' and clk'event then
146
                        if str = '1' then                               run <= '1';
147
                        elsif cnt = (A_range) then      run <= '0';
148
                        end if;
149
                        if str = '1' then                                               cnt <= (others => '0');
150
                        elsif run = '1' then                                    cnt <= cnt + 1;
151
                        end if;
152
                        if cnt = (A_range) then snb1 <= '1';
153
                        else                                                                    snb1 <= '0';
154
                        end if;
155
 
156
                        if snb1 = '1' then
157
                                reg <= (others => (others => '0'));
158
                        elsif run = '1' then
159
                                reg(4) <= (pr30 xor reg(3));
160
                                reg(3) <= (pr216 xor reg(2));
161
                                reg(2) <= (pr231 xor reg(1));
162
                                reg(1) <= (pr116 xor reg(0));
163
                                reg(0) <= D_IN;
164
                        end if;
165
 
166
                        if run = '1' then
167
                                reg2(A_range downto 1) <= reg2(A_range - 1 downto 0);
168
                                reg2(0) <=  d_in;
169
                        elsif snb1 = '1' then
170
                                reg2(4) <= reg(4);
171
                                reg2(3) <= reg(3);
172
                                reg2(2) <= reg(2);
173
                                reg2(1) <= reg(1);
174
                        elsif rd = '1' then
175
                                reg2(A_range downto 1) <= reg2(A_range - 1 downto 0);
176
                        end if;
177
                end if;
178
        end process;
179
        snb <= snb1;
180
        D_OUT <= reg2(A_range);
181
 
182
        sd <= reg(G_range );
183
 
184
        pr30  <= conv_std_logic_vector (rm30(conv_integer(sd)),8);
185
        pr216 <= conv_std_logic_vector (rm216(conv_integer(sd)),8);
186
        pr231 <= conv_std_logic_vector (rm231(conv_integer(sd)),8);
187
        pr116 <= conv_std_logic_vector (rm116(conv_integer(sd)),8);
188
 
189
 
190
end RS_EN4;

powered by: WebSVN 2.1.0

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