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

Subversion Repositories esoc

[/] [esoc/] [trunk/] [Sources/] [logixa/] [esoc_search_engine_control.vhd] - Blame information for rev 46

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 42 lmaarsen
--------------------------------------------------------------------------------
2
----                                                                        ----
3
---- Ethernet Switch on Configurable Logic IP Core                          ----
4
----                                                                        ----
5
---- This file is part of the ESoCL project                                 ----
6
---- http://www.opencores.org/cores/esoc/                                   ----
7
----                                                                        ----
8
---- Description: see design description ESoCL_dd_71022001.pdf              ----
9
----                                                                        ----
10
---- To Do: see roadmap description ESoCL_dd_71022001.pdf                   ----
11
----        and/or release bulleting ESoCL_rb_71022001.pdf                  ----
12
----                                                                        ----
13
---- Author(s): L.Maarsen                                                   ----
14
---- Bert Maarsen, lmaarsen@opencores.org                                   ----
15
----                                                                        ----
16
--------------------------------------------------------------------------------
17
----                                                                        ----
18
---- Copyright (C) 2009 Authors and OPENCORES.ORG                           ----
19
----                                                                        ----
20
---- This source file may be used and distributed without                   ----
21
---- restriction provided that this copyright statement is not              ----
22
---- removed from the file and that any derivative work contains            ----
23
---- the original copyright notice and the associated disclaimer.           ----
24
----                                                                        ----
25
---- This source file is free software; you can redistribute it             ----
26
---- and/or modify it under the terms of the GNU Lesser General             ----
27
---- Public License as published by the Free Software Foundation;           ----
28
---- either version 2.1 of the License, or (at your option) any             ----
29
---- later version.                                                         ----
30
----                                                                        ----
31
---- This source is distributed in the hope that it will be                 ----
32
---- useful, but WITHOUT ANY WARRANTY; without even the implied             ----
33
---- warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR                ----
34
---- PURPOSE. See the GNU Lesser General Public License for more            ----
35
---- details.                                                               ----
36
----                                                                        ----
37
---- You should have received a copy of the GNU Lesser General              ----
38
---- Public License along with this source; if not, download it             ----
39
---- from http://www.opencores.org/lgpl.shtml                               ----
40
----                                                                        ----
41
--------------------------------------------------------------------------------
42
-- Object        : Entity work.esoc_search_engine_control
43
-- Last modified : Mon Apr 14 12:49:59 2014.
44
--------------------------------------------------------------------------------
45
 
46
 
47
 
48
library ieee, std, work;
49
use ieee.std_logic_1164.all;
50
use std.textio.all;
51
use ieee.numeric_std.all;
52
use work.package_esoc_configuration.all;
53
 
54
entity esoc_search_engine_control is
55
  port(
56
    clk_control               : in     std_logic;
57
    clk_search                : in     std_logic;
58
    ctrl_address              : in     std_logic_vector(15 downto 0);
59
    ctrl_rd                   : in     std_logic;
60
    ctrl_rddata               : out    std_logic_vector(31 downto 0);
61
    ctrl_wait                 : out    std_logic;
62
    ctrl_wr                   : in     std_logic;
63
    ctrl_wrdata               : in     std_logic_vector(31 downto 0);
64
    reset                     : in     std_logic;
65
    search_entry_age_time     : out    std_logic_vector(11 downto 0);
66
    search_entry_age_time_ena : out    std_logic;
67
    search_sa_drop_cnt        : in     std_logic;
68
    search_sa_overload_cnt    : in     std_logic);
69
end entity esoc_search_engine_control;
70
 
71
--------------------------------------------------------------------------------
72
-- Object        : Architecture work.esoc_search_engine_control.esoc_search_engine_control
73
-- Last modified : Mon Apr 14 12:49:59 2014.
74
--------------------------------------------------------------------------------
75
 
76
 
77
architecture esoc_search_engine_control of esoc_search_engine_control is
78
---------------------------------------------------------------------------------------------------------------
79
-- registers
80
---------------------------------------------------------------------------------------------------------------
81
constant reg_search_engine_sa_overload_count_add: integer                           := 2;
82
signal reg_search_engine_sa_overload_count: std_logic_vector(31 downto 0);
83
signal reg_search_engine_sa_overload_count_i: std_logic_vector(31 downto 0);
84
constant reg_search_engine_sa_overload_count_rst: std_logic_vector(31 downto 0)     := X"00000000";
85
 
86
constant reg_search_engine_sa_drop_count_add: integer                               := 1;
87
signal reg_search_engine_sa_drop_count: std_logic_vector(31 downto 0);
88
signal reg_search_engine_sa_drop_count_i: std_logic_vector(31 downto 0);
89
constant reg_search_engine_sa_drop_count_rst: std_logic_vector(31 downto 0)         := X"00000000";
90
 
91
constant reg_search_engine_stat_ctrl_add: integer                                   := 0;
92
signal reg_search_engine_stat_ctrl: std_logic_vector(31 downto 0);
93
constant reg_search_engine_stat_ctrl_rst: std_logic_vector(31 downto 0)             := X"8000012C";
94
constant reg_search_engine_stat_ctrl_rst_sim: std_logic_vector(31 downto 0)         := X"00000002";
95
  alias  reg_search_engine_stat_ctrl_age_timer_ena : std_logic is reg_search_engine_stat_ctrl(31);
96
  alias  reg_search_engine_stat_ctrl_age_timer     : std_logic_vector(11 downto 0) is reg_search_engine_stat_ctrl(11 downto 0);
97
 
98
---------------------------------------------------------------------------------------------------------------
99
-- signals
100
---------------------------------------------------------------------------------------------------------------
101
signal search_sa_cnt_update_ack_sync: std_logic_vector(esoc_meta_ffs-1 downto 0);
102
signal search_sa_cnt_update_sync    : std_logic_vector(esoc_meta_ffs-1 downto 0);
103
signal search_sa_cnt_update         : std_logic;
104
signal search_sa_cnt_update_ack     : std_logic;
105
 
106
signal ctrl_rddata_i: std_logic_vector(ctrl_rddata'high downto 0);
107
signal ctrl_wait_i: std_logic;
108
signal ctrl_bus_enable: std_logic;
109
 
110
begin
111
 
112
--=============================================================================================================
113
-- Process                : access registers when addressed or provide data  to the ctrl_rddata_i bus
114
-- Description  : 
115
--=============================================================================================================    
116
registers:  process(clk_control, reset)
117
            begin
118
              if reset = '1' then
119
                -- Reset value depends on esoc mode, simulation requires short aging timer
120
                if esoc_mode = simulation then
121
                  reg_search_engine_stat_ctrl <= reg_search_engine_stat_ctrl_rst_sim;
122
                else
123
                  reg_search_engine_stat_ctrl <= reg_search_engine_stat_ctrl_rst;
124
                end if;
125
 
126
                ctrl_rddata_i   <= (others => '0');
127
                ctrl_wait_i     <= '1';
128
                ctrl_bus_enable <= '0';
129
 
130
              elsif clk_control'event and clk_control = '1' then
131
                ctrl_wait_i     <= '1';
132
                ctrl_bus_enable <= '0';
133
 
134
                -- continu if memory space of this entity is addressed
135
                if (to_integer(unsigned(ctrl_address)) >= esoc_search_engine_base) and (to_integer(unsigned(ctrl_address)) < esoc_search_engine_base + esoc_search_engine_size) then
136
                  -- claim the bus for ctrl_wait and ctrl_rddata
137
                  ctrl_bus_enable <= '1';
138
 
139
                  -- 
140
                        -- READ CYCLE started, unit addressed?
141
                        --
142
                        if ctrl_rd = '1' then
143
                                -- Check register address and provide data when addressed
144
                          case to_integer(unsigned(ctrl_address)) - esoc_search_engine_base is
145
                            when reg_search_engine_sa_overload_count_add  =>  if search_sa_cnt_update_ack = '1' then
146
                                                                          ctrl_rddata_i <= reg_search_engine_sa_overload_count;
147
                                                                          ctrl_wait_i <= '0';
148
                                                                        end if;
149
 
150
                      when reg_search_engine_sa_drop_count_add      =>  if search_sa_cnt_update_ack = '1' then
151
                                                                          ctrl_rddata_i <= reg_search_engine_sa_drop_count;
152
                                                                          ctrl_wait_i <= '0';
153
                                                                        end if;
154
 
155
                      when reg_search_engine_stat_ctrl_add          =>  ctrl_rddata_i <= reg_search_engine_stat_ctrl;
156
                                                                        ctrl_wait_i <= '0';
157
 
158
                      when others                                   =>  NULL;
159
                    end case;
160
 
161
                  --
162
                  -- WRITE CYCLE started, unit addressed?
163
                  --
164
                  elsif ctrl_wr = '1' then
165
                        -- Check address and accept data when addressed
166
                        case to_integer(unsigned(ctrl_address)) - esoc_search_engine_base is
167
                      when reg_search_engine_stat_ctrl_add  =>  reg_search_engine_stat_ctrl <= ctrl_wrdata;
168
                                                                ctrl_wait_i <= '0';
169
 
170
                      when others                           =>  NULL;
171
                    end case;
172
                  end if;
173
                end if;
174
              end if;
175
            end process;
176
 
177
            -- Create tristate outputs
178
            ctrl_wait   <= ctrl_wait_i    when ctrl_bus_enable = '1' else 'Z';
179
            ctrl_rddata <= ctrl_rddata_i  when ctrl_bus_enable = '1' else (others => 'Z');
180
 
181
            -- use register content
182
            search_entry_age_time     <= reg_search_engine_stat_ctrl_age_timer;
183
            search_entry_age_time_ena <= reg_search_engine_stat_ctrl_age_timer_ena;
184
 
185
--=============================================================================================================
186
-- Process                : Update counters and transfer values from search clock domain to control clock domain
187
-- Description  : 
188
--=============================================================================================================    
189
sync1a: process(clk_search, reset)
190
        begin
191
          if reset = '1' then
192
            reg_search_engine_sa_drop_count_i <= reg_search_engine_sa_drop_count_rst;
193
            reg_search_engine_sa_overload_count_i <= reg_search_engine_sa_overload_count_rst;
194
 
195
          elsif clk_search'event and clk_search = '1' then
196
            -- Update source address DROP counter
197
            if search_sa_drop_cnt = '1' then
198
              reg_search_engine_sa_drop_count_i <= std_logic_vector(to_unsigned(to_integer(unsigned(reg_search_engine_sa_drop_count_i)) + 1,reg_search_engine_sa_drop_count_i'length));
199
            end if;
200
 
201
            -- Update source address OVERLOAD counter
202
            if search_sa_overload_cnt = '1' then
203
              reg_search_engine_sa_overload_count_i <= std_logic_vector(to_unsigned(to_integer(unsigned(reg_search_engine_sa_overload_count_i)) + 1,reg_search_engine_sa_overload_count_i'length));
204
            end if;
205
          end if;
206
        end process;
207
 
208
sync1b: process(clk_search, reset)
209
        begin
210
          if reset = '1' then
211
            search_sa_cnt_update  <= '0';
212
            search_sa_cnt_update_ack_sync <= (others => '0');
213
            reg_search_engine_sa_drop_count <= reg_search_engine_sa_drop_count_rst;
214
            reg_search_engine_sa_overload_count <= reg_search_engine_sa_overload_count_rst;
215
 
216
          elsif clk_search'event and clk_search = '1' then
217
            -- synchronise update acknowledge indication
218
            search_sa_cnt_update_ack_sync <= search_sa_cnt_update_ack & search_sa_cnt_update_ack_sync(search_sa_cnt_update_ack_sync'high downto 1);
219
 
220
            -- no running update? start updating the other clock domain, use a copy of the counters, because they can change during the update!
221
            if search_sa_cnt_update = '0' and search_sa_cnt_update_ack_sync(0) = '0' then
222
              search_sa_cnt_update <= '1';
223
              reg_search_engine_sa_drop_count <= reg_search_engine_sa_drop_count_i;
224
              reg_search_engine_sa_overload_count <= reg_search_engine_sa_overload_count_i;
225
 
226
            -- finalize update when acknowledge is received
227
            elsif search_sa_cnt_update_ack_sync(0) = '1' then
228
              search_sa_cnt_update <= '0';
229
            end if;
230
          end if;
231
        end process;
232
 
233
sync1c: process(clk_control, reset)
234
        begin
235
          if reset = '1' then
236
            search_sa_cnt_update_sync  <= (others => '0');
237
 
238
          -- synchronise counter update indication
239
          elsif clk_control'event and clk_control = '1' then
240
            search_sa_cnt_update_sync <= search_sa_cnt_update & search_sa_cnt_update_sync(search_sa_cnt_update_sync'high downto 1);
241
          end if;
242
        end process;
243
 
244
        -- send update acknowledge
245
        search_sa_cnt_update_ack <=  search_sa_cnt_update_sync(0);
246
 
247
end architecture esoc_search_engine_control ; -- of esoc_search_engine_control
248
 

powered by: WebSVN 2.1.0

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