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

Subversion Repositories rs_dec_enc

[/] [rs_dec_enc/] [trunk/] [bench/] [test.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 {test} architecture {test}}
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 IEEE.math_real.all;
49
use IEEE.STD_LOGIC_TEXTIO.all;
50
use std.textio.all;
51
use type1.all;
52
library UNISIM;
53
use UNISIM.VCOMPONENTS.ALL;
54
 
55
 
56
entity test is
57
 
58
        --generic( G_range:  integer := 4;
59
--      A_range:  integer := 9);
60
end test;
61
 
62
--}} End of automatically maintained section
63
 
64
architecture test of test is
65
signal i,j,k,m : integer := 0;
66
 
67
 
68
 
69
component RS_EN4 is
70
 
71
        --generic( G_range:  integer := 4;
72
--      A_range:  integer := 9);
73
         port(
74
                 CLK : in STD_LOGIC;
75
                 RST : in STD_LOGIC;
76
                 D_IN : in STD_LOGIC_VECTOR(7 downto 0);
77
                 STR : in STD_LOGIC;
78
                 RD : in STD_LOGIC;
79
                 D_OUT : out STD_LOGIC_VECTOR(7 downto 0);
80
                 SNB : out STD_LOGIC
81
             );
82
end component;
83
 
84
component RS_DEC4 is
85
         port(
86
                 CLK : in STD_LOGIC;
87
                 RST : in STD_LOGIC;
88
                 STR : in STD_LOGIC;
89
                 D_IN : in STD_LOGIC_VECTOR(7 downto 0);
90
                 RD : in STD_LOGIC;
91
                 D_OUT : out STD_LOGIC_VECTOR(7 downto 0);
92
                 S_er : out STD_LOGIC;
93
                 S_ok : out STD_LOGIC;
94
                 SNB : out STD_LOGIC
95
             );
96
end component;
97
 
98
 
99
 
100
 
101
 
102
 
103
 
104
 
105
 
106
signal clk,rst: std_logic := '1';
107
 
108
 
109
signal rgA0 : tregA1 :=
110
(x"01",x"02",x"03",x"04",x"05",x"06",x"07",x"08",x"09",x"0A",x"0B",x"0C"
111
,others=>x"A5");
112
signal rgA10 : tregA1 := (x"45",x"00",x"00",x"27", others=>x"00");
113
 
114
signal   d_in,d_out11,d_out12,d_out,adr,tst2,d_out1,d_in1 : std_logic_vector(7 downto 0);
115
signal   str,rd,snb,pp,rd1,rd11,str1 : std_logic := '0';
116
 
117
signal snb_sindr,snb2,snb3,snb4 : std_logic;
118
signal   d_sindr : std_logic_vector(7 downto 0);
119
signal   x2,x3,y2,y3 : std_logic_vector(7 downto 0);
120
signal u,cntc,cntc1 : integer := 0;
121
signal pp31 : std_logic;
122
signal rgA1,rgA2,rgA3 : tregA;
123
signal r1 : std_logic;
124
signal aq: real;
125
signal s_er, s_ok : std_logic;
126
signal prov : std_logic := '0';
127
 
128
signal c1,c2,c3,c4,cc : std_logic;
129
begin
130
 
131
        rst <= '0' after 25 ns;
132
        clk <= not clk after 5 ns;
133
        c1 <= clk after 1 ns;
134
        c2 <= clk after 2 ns;
135
        c3 <= clk after 3 ns;
136
        c4 <= clk after 4 ns;
137
        cc <= clk xor c1 xor c2 xor c3 xor c4;
138
 
139
                   snb2 <= snb;
140
 
141
 
142
-- vector after encoding                
143
        process(clk)
144
begin
145
        if clk = '1' and clk'event then
146
                if rd1 = '1' then
147
                rgA1(A_range - 1 downto 1) <= rgA1(A_range - 2 downto 0);
148
                rgA1(0) <= d_out12;
149
                end if;
150
        end if;
151
end process;
152
 
153
-- vector after decoding                
154
        process(clk)
155
begin
156
        if clk = '1' and clk'event then
157
                if rd11 = '1' then
158
                rgA2(A_range - 1 downto 1) <= rgA2(A_range - 2 downto 0);
159
                rgA2(0) <= d_out1;
160
                end if;
161
        end if;
162
end process;
163
 
164
process
165
variable cnt : integer;
166
begin
167
        cnt := 0;
168
        str1 <= '0';
169
        wait for 1000 ns;
170
        -- старт для кодера
171
        wait until clk = '1';
172
        str1 <= '1';
173
        wait until clk = '1';
174
        str1 <= '0';
175
        -- data for encoding
176
        for i in 0 to A_range -5 loop
177
        d_in1 <= rgA0(cnt);
178
        cnt := cnt + 1;
179
        wait until clk = '1';
180
        end loop;
181
        -- после окончания потока данных на вход кодера выставляютя нули (потом уберу)
182
        cnt := 0;
183
        d_in1 <= x"00";
184
        wait until clk = '1';
185
        -- waiting for encoding to finish
186
        wait until snb3 = '1';
187
        wait for 1 ps;
188
        -- adding errors
189
        d_out11 <=      d_out xor rgA10(cnt);
190
        -- receiving data for decoding
191
        rd1 <= '1';
192
        wait until clk = '1';
193
        for i in 0 to A_range -1 loop
194
        wait for 1 ps;
195
                d_out11 <=      d_out12 xor rgA10(cnt);
196
                cnt := cnt + 1;
197
        wait until clk = '1';
198
        end loop;
199
        -- end of receiving
200
        rd1 <= '0';
201
        wait until clk = '1';
202
        -- waiting the end of decoding
203
        wait until snb4 = '1';
204
        wait until clk = '1';
205
        -- read the result
206
        rd11 <= '1';
207
        wait until clk = '1';
208
        for i in 0 to A_range -1 loop
209
        wait until clk = '1';
210
        end loop;
211
        rd11 <= '0';
212
        wait until clk = '1';
213
        -- compare received data with the original data
214
        if rgA2 = rgA1 then prov <= '1'; else prov <= '0'; end if;
215
        wait until clk = '1';
216
        -- change the data vector and error vector
217
        rgA0 <= (rgA0(A_range - 1) + rgA0(0)) & rgA0(0 to A_range - 2);
218
        rgA10 <= rgA10(1 to A_range - 1) & rgA10(0);
219
 
220
end process;
221
 
222
 
223
--- encoder
224
u_rs_en1 : RS_EN4
225
         port map(
226
                 CLK => clk, RST => rst,
227
                 D_IN => d_in1,
228
                 STR => str1,
229
                 RD => rd1,
230
                 D_OUT => d_out12,
231
                 SNB => snb3
232
             );
233
 
234
-- decoder  
235
u_rs_dec1 :  RS_DEC4
236
         port map(
237
                 CLK => clk, RST => rst,
238
                 D_IN => d_out11,
239
                 STR => snb3,
240
                 RD => rd11,
241
                 D_OUT => d_out1,
242
                 S_er =>s_er,
243
                 S_ok => s_ok,
244
                 SNB => snb4
245
             );
246
-- culculate cycles                                                 
247
process(clk,rst)
248
begin
249
        if rst = '1' then
250
                cntc <= 0;
251
                cntc1 <= 0;
252
        elsif clk = '1' and clk'event then
253
                if snb3 = '1' then cntc <= 0; else cntc <= cntc + 1; end if;
254
                if snb4 = '1' then cntc1 <= cntc; end if;
255
        end if;
256
end process;
257
 
258
 
259
 
260
 
261
end test;

powered by: WebSVN 2.1.0

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