rs_encoder_N7K5.vhd
Go to the documentation of this file.
1 -------------------------------------------------------
6 -------------------------------------------------------
7 
9 LIBRARY ieee;
10 USE ieee.std_logic_1164.all;
11 
13 USE work.lpgbtfpga_package.all;
14 
16 ENTITY rs_encoder_N7K5 IS
17  GENERIC (
18  N : integer := 7;
19  K : integer := 5;
20  SYMB_BITWIDTH : integer := 3
21  );
22  PORT (
23  msg : in std_logic_vector((K*SYMB_BITWIDTH)-1 downto 0);
24  parity : out std_logic_vector(((N-K)*SYMB_BITWIDTH)-1 downto 0)
25  );
26 END rs_encoder_N7K5;
27 
29 ARCHITECTURE behavioral OF rs_encoder_N7K5 IS
30 
31  -- Dependant parameters
32  constant P : integer := N-K;
33  constant POL_BW : integer := SYMB_BITWIDTH*P;
34  constant STG_BW : integer := SYMB_BITWIDTH*(P+1);
35 
36  TYPE reg_arr IS ARRAY(integer RANGE <>) OF std_logic_vector((STG_BW-1) downto 0);
37  SIGNAL stageOut : reg_arr((K-1) downto 0);
38  SIGNAL multOut : reg_arr((K-1) downto 0);
39 
40 
41 BEGIN --========#### Architecture Body ####========--
42 
43  -- ---------------- The Parallel LFSR HDL description ---------------- --
44 
45  -- In the first layer, the rightmost node is an addition to zero, so
46  -- we route it directly to the stage output
47  stageOut(0)(((SYMB_BITWIDTH+POL_BW)-1) downto POL_BW) <= msg((SYMB_BITWIDTH-1) downto 0);
48 
49  -- Since in the first layer there are no adders, the stageOut is
50  -- connected to the multiplier output. Hence, the multOut is set to zero.
51  multOut(0)(((SYMB_BITWIDTH*P)-1) downto 0) <= (OTHERS => '0');
52 
53  -- The rightmost multOut is never USEd (we only add the input codeword
54  -- with the previous node), so it is set to zero. On the other hand,
55  -- the leftmost node only performs multiplication, so multOut is
56  -- routed to stageOut.
57  multOut(0)(((SYMB_BITWIDTH+POL_BW)-1) downto POL_BW) <= (OTHERS => '0');
58 
59  multAndStage_gen: FOR i IN 1 TO (K-1) GENERATE
60  multOut(i)(((SYMB_BITWIDTH+POL_BW)-1) downto POL_BW) <= (OTHERS => '0');
61  stageOut(i)((SYMB_BITWIDTH-1) downto 0) <= multOut(i)((SYMB_BITWIDTH-1) downto 0);
62  END GENERATE;
63 
64  -- Generates the instances of the GF(2^m) of the LFSR parallel network
65  -- The first line is a particular CASE...
66 
67  -- The GF multiplications units in the first stage
68  stageOut(0)(2) <= msg(1);
69  stageOut(0)(1) <= msg(0) xor msg(2);
70  stageOut(0)(0) <= msg(2);
71  stageOut(0)(3) <= msg(2) xor msg(0);
72  stageOut(0)(4) <= msg(1) xor msg(0) xor msg(2);
73  stageOut(0)(5) <= msg(2) xor msg(1);
74 
75  -- The remaining stages..
76  GF_gen: FOR i IN 1 TO (K-1) GENERATE
77 
78  -- The GF add units
79  stageOut(i)((POL_BW+SYMB_BITWIDTH-1) downto POL_BW) <= msg(((1+i)*SYMB_BITWIDTH)-1 downto i*SYMB_BITWIDTH) xor stageOut(i-1)((SYMB_BITWIDTH*(P-1)+SYMB_BITWIDTH)-1 downto SYMB_BITWIDTH*(P-1));
80 
81  -- The GF multiplication units
82  multOut(i)(2) <= stageOut(i)(POL_BW+1);
83  multOut(i)(1) <= stageOut(i)(POL_BW) xor stageOut(i)(POL_BW+2);
84  multOut(i)(0) <= stageOut(i)(POL_BW+2);
85 
86  multOut(i)(3) <= stageOut(i)(POL_BW+2) xor stageOut(i)(POL_BW+0);
87  multOut(i)(4) <= stageOut(i)(POL_BW+1) xor stageOut(i)(POL_BW+0) xor stageOut(i)(POL_BW+2);
88  multOut(i)(5) <= stageOut(i)(POL_BW+2) xor stageOut(i)(POL_BW+1);
89 
90  GF_internal_gen: FOR j IN 1 TO (P-1) GENERATE
91 
92  stageOut(i)(((j+1)*SYMB_BITWIDTH)-1 downto SYMB_BITWIDTH*j) <= multOut(i)(((j+1)*SYMB_BITWIDTH)-1 downto SYMB_BITWIDTH*j) xor stageOut(i-1)((j*SYMB_BITWIDTH)-1 downto SYMB_BITWIDTH*(j-1));
93 
94  END GENERATE;
95 
96  END GENERATE;
97 
98  -- Parity computing..
99  Parity_gen: FOR l IN 0 TO (P-1) GENERATE
100  parity(((l+1)*SYMB_BITWIDTH)-1 downto l*SYMB_BITWIDTH) <= stageOut(K-1)((STG_BW-(l+1)*SYMB_BITWIDTH)-1 downto STG_BW-(l+2)*SYMB_BITWIDTH);
101  END GENERATE;
102 
103 END behavioral;
104 --=================================================================================================--
105 --#################################################################################################--
106 --=================================================================================================--
in msgstd_logic_vector%(%(K%*%SYMB_BITWIDTH)%-%1%%%downto%%%0%)
Message to be encoded.
rs_encoder_N7K5 - N7K5 Reed-Solomon encoder
_library_ ieeeieee
Include the IEEE VHDL standard LIBRARY.
out paritystd_logic_vector%(%((N%-%K)%*%SYMB_BITWIDTH)%-%1%%%downto%%%0%)
FEC output.