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

Subversion Repositories xmatchpro

[/] [xmatchpro/] [trunk/] [xmw4-comdec/] [xmatch_sim7/] [src/] [parser.vhd] - Blame information for rev 9

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 9 eejlny
--This library is free software; you can redistribute it and/or
2
--modify it under the terms of the GNU Lesser General Public
3
--License as published by the Free Software Foundation; either
4
--version 2.1 of the License, or (at your option) any later version.
5
 
6
--This library is distributed in the hope that it will be useful,
7
--but WITHOUT ANY WARRANTY; without even the implied warranty of
8
--MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
9
--Lesser General Public License for more details.
10
 
11
--You should have received a copy of the GNU Lesser General Public
12
--License along with this library; if not, write to the Free Software
13
--Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
14
 
15
-- e_mail : j.l.nunez-yanez@byacom.co.uk
16
 
17
---------------------------------------------
18
--  ENTITY       = PARSER                  --
19
--  version      = 1.0                     --
20
--  last update  = 30/05/00                --
21
--  author       = Jose Nunez              --
22
---------------------------------------------
23
 
24
 
25
-- FUNCTION
26
-- The parser is the core of the parsing unit
27
 
28
--  PIN LIST
29
 
30
--  DATA_IN    = data to be parse from the buffer
31
--  MASK = 4 bit indicatin how many bytes of the 32 are valid
32
--  DATA_OUT_32  = output data to the search register
33
--  MASK = to know the length of the tuple
34
--  SPACE_TUPLE = tuple formed only by spaces
35
--  CLEAR    = asynchronous clear
36
--  CLK      = master clock
37
 
38
 
39
library ieee;
40
use ieee.std_logic_1164.all;
41
library dzx;
42
use dzx.bit_arith.all;
43
use dzx.bit_utils.all;
44
 
45
entity PARSER is
46
port (
47
          DATA_IN : in bit_vector(55 downto 0);
48
          LENGTH_IN : in bit_vector(2 downto 0);
49
          ENABLE : in bit; -- hold the state when the buffer is empty but still more data in the block
50
          FINISH : in bit; -- last block is over
51
          DATA_SEARCH : out bit_vector(31 downto 0);
52
          DATA_OUT : out bit_vector(55 downto 0);
53
          MASK : out bit_vector(4 downto 0);
54
          LENGTH_OUT : out bit_vector(2 downto 0)
55
);
56
end PARSER;
57
 
58
 
59
architecture STRUCTURAL of PARSER is
60
 
61
 
62
signal VECTOR_PARSER, NORMAL_MASK, SPACE_MASK, TEMP_MASK: bit_vector(3 downto 0);
63
signal DATA_PARSER : bit_vector(31 downto 0);
64
signal SPACE : bit;
65
 
66
 
67
begin
68
 
69
DATA_PARSER <= DATA_IN(55 downto 24); -- parse only the more significant 4 bytes
70
 
71
COMPARATOR : process (DATA_PARSER)
72
begin
73
        for I in 3 downto 0 loop
74
                if DATA_PARSER(8*I+7 downto 8*I)="00100000" then -- comparing with 32
75
                        VECTOR_PARSER(I)<='1';
76
                else
77
                        VECTOR_PARSER(I)<='0';
78
                end if;
79
        end loop;
80
end process COMPARATOR;
81
 
82
 
83
NORMAL_WORD : process(VECTOR_PARSER)
84
variable A_ROW,B_ROW: bit_vector(3 downto 0);
85
 
86
begin
87
for I in 0 to 1 loop
88
        A_ROW(2*I) := VECTOR_PARSER(2*I) or VECTOR_PARSER(2*I+1);
89
        A_ROW(2*I+1) := VECTOR_PARSER(2*I+1);
90
end loop;
91
 
92
for I in 0 to 1 loop
93
        B_ROW(I) := A_ROW(I) or A_ROW(2);
94
        B_ROW(I+2) := A_ROW(I+2);
95
end loop;
96
 
97
NORMAL_MASK <= not('0' & B_ROW(3 downto 1));
98
 
99
end process NORMAL_WORD;
100
 
101
 
102
SPACE_WORD : process(VECTOR_PARSER)
103
variable A_ROW,B_ROW: bit_vector(3 downto 0);
104
 
105
begin
106
for I in 0 to 1 loop
107
        A_ROW(2*I) := VECTOR_PARSER(2*I) and VECTOR_PARSER(2*I+1);
108
        A_ROW(2*I+1) := VECTOR_PARSER(2*I+1);
109
end loop;
110
 
111
for I in 0 to 1 loop
112
        B_ROW(I) := A_ROW(I) and A_ROW(2);
113
        B_ROW(I+2) := A_ROW(I+2);
114
end loop;
115
 
116
SPACE_MASK <= B_ROW;
117
 
118
end process SPACE_WORD;
119
 
120
 
121
MASK_GENERATION: process(SPACE_MASK, NORMAL_MASK,LENGTH_IN)
122
variable INTERMEDIATE : bit_vector(3 downto 0);
123
variable OR_LENGTH : bit;
124
 
125
begin
126
 
127
OR_LENGTH := or_bits(LENGTH_IN);
128
 
129
for I in 3 downto 0 loop
130
        INTERMEDIATE(I) := not(SPACE_MASK(3)) and NORMAL_MASK(I);
131
end loop;
132
 
133
if (OR_LENGTH = '1') then
134
 
135
        TEMP_MASK <= (INTERMEDIATE or SPACE_MASK);
136
else
137
        TEMP_MASK <= "0000";
138
 
139
end if;
140
 
141
end process MASK_GENERATION;
142
 
143
 
144
LENGTH_CALCULATION : process(TEMP_MASK, LENGTH_IN, ENABLE, FINISH)
145
variable COM_LENGTH: bit_vector(2 downto 0);
146
 
147
begin
148
 
149
if (ENABLE = '1' or FINISH = '1') then
150
        case TEMP_MASK is
151
                when "1000" => COM_LENGTH := "001";
152
                when "1100" => COM_LENGTH := "010";
153
                when "1110" => COM_LENGTH := "011";
154
                when "1111" => COM_LENGTH := "100";
155
                when others => COM_LENGTH := "000";
156
        end case;
157
else
158
        COM_LENGTH := "000";
159
end if;
160
 
161
if (LENGTH_IN > COM_LENGTH) then      -- to handle the added artificial last byte
162
        LENGTH_OUT <= LENGTH_IN - COM_LENGTH;
163
else
164
        LENGTH_OUT <= "000";
165
end if;
166
 
167
end process LENGTH_CALCULATION;
168
 
169
-- space not present in tuple when space signal set to 1
170
 
171
SPACE_EXTENSION : process(TEMP_MASK, DATA_PARSER)
172
begin
173
if (TEMP_MASK(0) = '1' and DATA_PARSER(7 downto 0) /= "00100000") then
174
        SPACE <= '1';
175
else
176
        SPACE <= '0';
177
end if;
178
end process SPACE_EXTENSION;
179
 
180
 
181
 
182
MASK <= TEMP_MASK & SPACE;
183
 
184
 
185
SHIFT_OLD_DATA : process(TEMP_MASK, DATA_IN, ENABLE, FINISH)
186
 
187
begin
188
if (ENABLE = '1' or FINISH = '1') then
189
        case TEMP_MASK is
190
                when "1000" => DATA_OUT <= DATA_IN(47 downto 0) & "00000000";
191
                when "1100" => DATA_OUT <= DATA_IN(39 downto 0) & "0000000000000000";
192
                when "1110" => DATA_OUT <= DATA_IN(31 downto 0) & "000000000000000000000000";
193
                when "1111" => DATA_OUT <= DATA_IN(23 downto 0) & "00000000000000000000000000000000";
194
                when others => DATA_OUT <= "00000000000000000000000000000000000000000000000000000000";
195
        end case;
196
else
197
        DATA_OUT <= DATA_IN;
198
end if;
199
end process SHIFT_OLD_DATA;
200
 
201
DATA_SEARCH <= DATA_IN(55 downto 24);
202
 
203
end structural;
204
 
205
 

powered by: WebSVN 2.1.0

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