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

Subversion Repositories image_component_labeling_and_feature_extraction

[/] [image_component_labeling_and_feature_extraction/] [trunk/] [compuSequencer.vhd] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 malikpearl
----------------------------------------------------------------------------------
2
-- Company: 
3
-- Engineer: 
4
-- 
5
-- Create Date:    20:03:49 06/11/2009 
6
-- Design Name: 
7
-- Module Name:    compuSequencer - Behavioral 
8
-- Project Name: 
9
-- Target Devices: 
10
-- Tool versions: 
11
-- Description: 
12
--
13
-- Dependencies: 
14
--
15
-- Revision: 
16
-- Revision 0.01 - File Created
17
-- Additional Comments: 
18
--
19
----------------------------------------------------------------------------------
20
library IEEE;
21
use IEEE.STD_LOGIC_1164.ALL;
22
use IEEE.STD_LOGIC_ARITH.ALL;
23
use IEEE.STD_LOGIC_UNSIGNED.ALL;
24
 
25
---- Uncomment the following library declaration if instantiating
26
---- any Xilinx primitives in this code.
27
--library UNISIM;
28
--use UNISIM.VComponents.all;
29
 
30
entity compuSequencer is
31
    Port ( clk : in  STD_LOGIC;
32
           reset : in  STD_LOGIC;
33
                          tableReady : in STD_LOGIC;
34
                          computeDone : in STD_LOGIC;
35
                          featureDataStrobe : out STD_LOGIC;
36
                          acknowledge : in STD_LOGIC;
37
                          indexMax : in  STD_LOGIC_VECTOR (9 downto 0);
38
           eqData : in  STD_LOGIC_VECTOR (9 downto 0);
39
           eqAddress : out  STD_LOGIC_VECTOR (9 downto 0);
40
           compuCode : out  STD_LOGIC_VECTOR (9 downto 0);
41
                          cntObjects : out  STD_LOGIC_VECTOR (9 downto 0);
42
           mergeEnable : out  STD_LOGIC;
43
           compute : buffer  STD_LOGIC;
44
           tablePreset : out  STD_LOGIC);
45
end compuSequencer;
46
 
47
architecture Behavioral of compuSequencer is
48
 
49
        signal mergeAddressDelayed, calcAddressDelayed : std_logic_vector(9 downto 0);
50
        signal mergeAddress, calcAddress, calcCode, mergeCode : std_logic_vector(9 downto 0);
51
        signal runCalc, computeDoneDelay : std_logic;
52
 
53
        type calc_state_type is (idle, initSearch, objectSearch, waitOnCompute1, waitOnCompute2, waitOnCompute3, waitOnComm1, waitOnComm2, waitOnComm3); --state declaration
54
 
55
        signal calc_state : calc_state_type := idle;
56
 
57
begin
58
 
59
        eqAddress <= calcAddress when runCalc = '1' else mergeAddress;
60
        compuCode <= calcCode when runCalc = '1' else mergeCode;
61
 
62
        resolve: process(clk,reset)
63
                variable cnt : std_logic_vector(9 downto 0) := (others=>'0');
64
                variable destination : std_logic_vector(9 downto 0) := (others=>'0');
65
                variable cindex : std_logic_vector(10 downto 0) := (others=>'1');
66
                variable found : boolean := false;
67
 
68
                begin
69
                        if reset = '1' then
70
                                cindex := conv_std_logic_vector(1,11);
71
                                mergeAddress <= cindex(9 downto 0);
72
                                cnt := (others=>'0');
73
                                mergeCode <= (others=>'0');
74
                                mergeEnable <= '0';
75
                                found := false;
76
                                runCalc <= '0';
77
                        elsif clk'event and clk = '1' then
78
                                mergeCode <= (others=>'0');
79
                                mergeEnable <= '0';
80
                                if tableReady = '0' then
81
                                        cindex := conv_std_logic_vector(1,11);
82
                                        mergeAddress <= cindex(9 downto 0);
83
                                        cnt := (others=>'0');
84
                                        found := false;
85
                                        runCalc <= '0';
86
 
87
                                else
88
                                        if cindex < indexMax+1 then
89
                                                if mergeAddressDelayed /= eqData and cindex > 1 and not found then
90
                                                        cnt := cnt + 1;
91
                                                        --mergeDest <= eqData;
92
                                                        mergeCode <= mergeAddressDelayed;
93
                                                        destination := eqData;
94
                                                        --mergeEnable <= '1';
95
                                                        found := true;
96
                                                elsif found then
97
                                                        found := false;
98
                                                        cindex := cindex + 1;
99
                                                        mergeCode <= destination;
100
                                                        mergeEnable <= '1';
101
                                                else
102
                                                        cindex := cindex + 1;
103
                                                end if;
104
                                        elsif cindex = indexMax+1 then
105
                                                runCalc <= '1';
106
                                                cntObjects <= indexMax - cnt - 1;
107
                                                cindex := cindex + 1;
108
                                        end if;
109
                                mergeAddressDelayed <= mergeAddress;
110
                                mergeAddress <= cindex(9 downto 0);
111
                                end if;
112
                        end if;
113
 
114
                end process resolve;
115
 
116
 
117
calc: process(clk,reset)
118
                variable cindex : std_logic_vector(10 downto 0) := (others=>'1');
119
                begin
120
                        if reset = '1' then
121
                                cindex := conv_std_logic_vector(1,11);
122
                                calcAddress <= cindex(9 downto 0);
123
                                tablePreset <= '0';
124
                                compute <= '0';
125
                                calcCode <= (others=>'0');
126
 
127
                        elsif clk'event and clk = '1' then
128
 
129
                                case calc_state is
130
                                        when idle =>
131
                                                        tablePreset <= '0';
132
                                                        compute <= '0';
133
                                                        featureDataStrobe <= '0';
134
                                                        calcCode <= (others=>'0');
135
                                        when initSearch =>
136
                                                        cindex := conv_std_logic_vector(1,11);
137
                                                        calcAddress <= cindex(9 downto 0);
138
                                                        tablePreset <= '0';
139
                                                        compute <= '0';
140
                                                        featureDataStrobe <= '0';
141
                                                        calcCode <= (others=>'0');
142
                                                        if computeDone = '1' then
143
                                                                calc_state <= objectSearch;
144
                                                        end if;
145
                                        when objectSearch =>
146
                                                        compute <= '0';
147
                                                        if cindex < indexMax then
148
                                                                if calcAddressDelayed = eqData and cindex >= 1 then
149
                                                                        calcCode <= calcAddressDelayed;
150
                                                                        compute <= '1';
151
                                                                        calc_state <= waitOnCompute1;
152
                                                                end if;
153
                                                                cindex := cindex + 1;
154
                                                        else
155
                                                                tablePreset <= '1';
156
                                                                calc_state <= idle;
157
                                                        end if;
158
                                        when waitOnCompute1 =>
159
                                                        compute <= '0';
160
                                                        calc_state <= waitOnCompute2;
161
                                                        if calcAddressDelayed = eqData and eqData /=calcCode then--for two objects on consecutive codes
162
                                                           cindex:= cindex-1;
163
                                                        end if;
164
                                        when waitOnCompute2 =>
165
                                                        compute <= '0';
166
                                                        calc_state <= waitOnCompute3;
167
                                        when waitOnCompute3 =>
168
                                                        compute <= '0';
169
                                                        if computeDone = '1' then
170
                                                                featureDataStrobe <= '1';
171
                                                                calc_state <= waitOnComm1;
172
                                                        end if;
173
                                        when waitOnComm1 =>
174
                                                        compute <= '0';
175
                                                        featureDataStrobe <= '0';
176
                                                        calc_state <= waitOnComm2;
177
                                        when waitOnComm2 =>
178
                                                        compute <= '0';
179
                                                        featureDataStrobe <= '0';
180
                                                        calc_state <= waitOnComm3;
181
                                        when waitOnComm3 =>
182
                                                        compute <= '0';
183
                                                        featureDataStrobe <= '0';
184
                                                        if acknowledge = '1' then
185
                                                                calc_state <= objectSearch;
186
                                                        end if;
187
                                        end case;
188
 
189
                                if runCalc = '0' then
190
                                        calc_state <= initSearch;
191
                                end if;
192
 
193
                                calcAddressDelayed <= calcAddress;
194
                                calcAddress <= cindex(9 downto 0);
195
 
196
                        end if; -- Syncronolus statements
197
                end process calc;
198
 
199
--      calc: process(clk,reset) 
200
--              variable cindex : std_logic_vector(10 downto 0) := (others=>'1');
201
--              begin
202
--                      if reset = '1' then
203
--                              cindex := conv_std_logic_vector(1,11);
204
--                              calcAddress <= cindex(9 downto 0);
205
--                              tablePreset <= '0';
206
--                              compute <= '0';
207
--                              calcCode <= (others=>'0');
208
--                              
209
--                      elsif clk'event and clk = '1' then
210
--                              
211
--                              if runCalc = '0' then
212
--                                      cindex := conv_std_logic_vector(1,11);
213
--                                      tablePreset <= '0';
214
--                                      calcAddress <= cindex(9 downto 0);
215
--                                      compute <= '0';
216
--                                      calcCode <= (others=>'0');
217
--                              elsif computeDone = '1' and acknowledge = '1' then
218
--                                      compute <= '0';
219
--                                      if cindex < indexMax+1 then
220
--                                              if calcAddressDelayed = eqData and cindex > 1 then
221
--                                                      calcCode <= calcAddressDelayed;
222
--                                                      compute <= '1';
223
--                                              end if;
224
--                                              cindex := cindex + 1;
225
--                                      elsif cindex = indexMax+1 then
226
--                                              tablePreset <= '1';
227
--                                              cindex := cindex + 1;
228
--                                      else
229
--                                              tablePreset <= '0';
230
--                                      end if;
231
--                                      calcAddressDelayed <= calcAddress;
232
--                                      calcAddress <= cindex(9 downto 0);
233
--                              else
234
--                                      compute <='0';
235
--                              end if;
236
--                              
237
--                              if computeDone = '1'  and computeDoneDelay = '0' and acknowledge = '1' then
238
--                                      featureDataStrobe <= '1';
239
--                              else
240
--                                      featureDataStrobe <= '0';
241
--                              end if;
242
--                              
243
--                              computeDoneDelay <= computeDone;
244
--                      end if;
245
--              end process calc;
246
 
247
end Behavioral;
248
 

powered by: WebSVN 2.1.0

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