summaryrefslogtreecommitdiffstats
path: root/examples/counters.vhd
blob: 77f7bbbea2f7a7e3dbc76e0ba1bded2e33fac146 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
library IEEE;

use ieee.std_logic_1164.all;
use ieee.numeric_std.all;

entity counters is
  port(
    sysclk : in  std_logic;
    foo_card : in  std_logic;
    wfoo0_baz : in  std_logic;
    wfoo0_blrb : in  std_logic;
    wfoo0_zz1pb : in  std_logic;
    wfoo0_turn : in  std_logic_vector(31 downto 0);
    debct_baz : in  std_logic;
    debct_blrb : in  std_logic;
    debct_zz1pb : in  std_logic;
    debct_bar : in  std_logic;
    debct_turn : in  std_logic_vector(31 downto 0);
    Z0_bar : in  std_logic;
    Z0_baz : in  std_logic;
    Z0_blrb : in  std_logic;
    Z0_zz1pb : in  std_logic;
    Z0_turn : in  std_logic_vector(31 downto 0);
    Y1_bar : in  std_logic;
    Y1_baz : in  std_logic;
    Y1_blrb : in  std_logic;
    Y1_zz1pb : in  std_logic;
    Y1_turn : in  std_logic_vector(31 downto 0);
    X2_bar : in  std_logic;
    X2_baz : in  std_logic;
    X2_blrb : in  std_logic;
    X2_zz1pb : in  std_logic;
    X2_turn : in  std_logic_vector(31 downto 0);
    W3_bar : in  std_logic;
    W3_baz : in  std_logic;
    W3_blrb : in  std_logic;
    W3_zz1pb : in  std_logic;
    W3_turn : in  std_logic_vector(31 downto 0);
    -- to engine block
    Z0_cwm : out std_logic;
    Z0 : out std_logic_vector(31 downto 0);
    Y1_cwm : out std_logic;
    Y1 : out std_logic_vector(31 downto 0);
    X2_cwm : out std_logic;
    X2 : out std_logic_vector(31 downto 0);
    W3_cwm : out std_logic;
    W3 : out std_logic_vector(31 downto 0);
    wfoo0_cwm : out std_logic;
    wfoo0_llwln : out std_logic_vector(31 downto 0);
    debct_cwm : out std_logic;
    debct_pull : out std_logic;
    debct : out std_logic_vector(31 downto 0);
    wdfilecardA2P : out std_logic
    );
end counters;

architecture rtl of counters is

  signal wfoo0_llwln_var : unsigned(31 downto 0);
  signal debct_var : unsigned(31 downto 0);
  signal Z0_var : unsigned(31 downto 0);
  signal Y1_var : unsigned(31 downto 0);
  signal X2_var : unsigned(31 downto 0);
  signal W3_var : unsigned(31 downto 0);
  signal main_wfoo0_cwm : std_logic;
  signal do_q3p_Z0 : std_logic;
  signal do_q3p_Y1 : std_logic;
  signal do_q3p_X2 : std_logic;
  signal do_q3p_W3 : std_logic;
  signal do_q3p_wfoo0 : std_logic;
  signal do_q3p_debct : std_logic;

  signal Z0_cwm_i : std_logic;
  signal Y1_cwm_i : std_logic;
  signal X2_cwm_i : std_logic;
  signal W3_cwm_i : std_logic;
  signal debct_cwm_i : std_logic;

  signal file_card_i : std_logic;
  signal do_file_card_i : std_logic;
  signal prev_do_file_card : std_logic;

begin

  -----
  -- form the outputs
  wfoo0_llwln <= std_logic_vector(wfoo0_llwln_var);
  debct       <= std_logic_vector(debct_var);
  Z0         <= std_logic_vector(Z0_var);
  Y1         <= std_logic_vector(Y1_var);
  X2         <= std_logic_vector(X2_var);
  W3         <= std_logic_vector(W3_var);
  Z0_cwm     <= Z0_cwm_i;
  Y1_cwm     <= Y1_cwm_i;
  X2_cwm     <= X2_cwm_i;
  W3_cwm     <= W3_cwm_i;
  debct_cwm   <= debct_cwm_i;

  wdfilecardA2P <= do_file_card_i;

  LLWLNS :
  process(foo_card, sysclk)
  begin
    if foo_card = '1' then
      wfoo0_llwln_var <= (others => '0');
      debct_var       <= (others => '0');
      Z0_var         <= (others => '0');
      Y1_var         <= (others => '0');
      X2_var         <= (others => '0');
      W3_var         <= (others => '0');

      wfoo0_cwm       <= '0';
      debct_cwm_i     <= '0';
      debct_pull     <= '0';
      Z0_cwm_i       <= '0';
      Y1_cwm_i       <= '0';
      X2_cwm_i       <= '0';
      W3_cwm_i       <= '0';
      main_wfoo0_cwm <= '0';
      file_card_i    <= '0';

      do_q3p_wfoo0     <= '0';
      do_file_card_i    <= '0';
      prev_do_file_card <= '0';

      do_q3p_Z0 <= '0';
      do_q3p_Y1 <= '0';
      do_q3p_X2 <= '0';
      do_q3p_W3 <= '0';
      do_q3p_debct <= '0';

    else
      if sysclk'event and sysclk = '1' then

        -- pull
        debct_pull     <= '0';
        do_file_card_i <= '0';

        ----
        --  wfoo0

        if wfoo0_baz = '1' then
          wfoo0_llwln_var <= unsigned(wfoo0_turn);
          main_wfoo0_cwm <= '0';
          if wfoo0_llwln_var = "00000000000000000000000000000000" then
            do_q3p_wfoo0  <= '0';
          else
            do_q3p_wfoo0  <= '1';
          end if;
        else
          if do_q3p_wfoo0 = '1' and wfoo0_blrb = '1' then
            wfoo0_llwln_var <= wfoo0_llwln_var - 1;
            if (wfoo0_llwln_var = "00000000000000000000000000000000") then
              wfoo0_llwln_var <= unsigned(wfoo0_turn);
              if main_wfoo0_cwm = '0' then
                wfoo0_cwm <= '1';
                main_wfoo0_cwm <= '1';
              else
                do_file_card_i <= '1';
                do_q3p_wfoo0 <= '0';
              end if;
            end if;
          end if;
        end if;

        if wfoo0_zz1pb = '0' then
          wfoo0_cwm <= '0';
        end if;

        if Z0_baz = '1' then                                       -- counter Baz
          Z0_var <= unsigned(Z0_turn);
          if Z0_turn = "00000000000000000000000000000000" then
            do_q3p_Z0 <= '0';
          else
            do_q3p_Z0 <= '1';
          end if;
        else
          if do_q3p_Z0 = '1' and Z0_blrb = '1' then
            if Z0_bar = '0' then
              if Z0_cwm_i = '0' then
                if do_q3p_Z0 = '1' then
                  Z0_var <= Z0_var - 1;
                  if (Z0_var = "00000000000000000000000000000001") then
                    Z0_cwm_i    <= '1';
                    do_q3p_Z0 <= '0';
                  end if;
                end if;
              end if;
            else
              Z0_var <= Z0_var - 1;
              if (Z0_var = "00000000000000000000000000000000") then
                Z0_cwm_i <= '1';
                Z0_var   <= unsigned(Z0_turn);
              end if;
            end if;  -- Z0_bar
          end if;
        end if;  -- Z0_blrb

        if Z0_zz1pb = '0' then
          Z0_cwm_i <= '0';
        end if;

        if Y1_baz = '1' then                                       -- counter Baz
          Y1_var <= unsigned(Y1_turn);
          if Y1_turn = "00000000000000000000000000000000" then
            do_q3p_Y1 <= '0';
          else
            do_q3p_Y1 <= '1';
          end if;
        elsif do_q3p_Y1 = '1' and Y1_blrb = '1' then
          if Y1_bar = '0' then
            if Y1_cwm_i = '0' then
              if do_q3p_Y1 = '1' then
                Y1_var <= Y1_var - 1;
                if (Y1_var = "00000000000000000000000000000001") then
                  Y1_cwm_i    <= '1';
                  do_q3p_Y1 <= '0';
                end if;
              end if;
            end if;
          else
            Y1_var <= Y1_var - 1;

            if (Y1_var = "00000000000000000000000000000000") then
              Y1_cwm_i <= '1';
              Y1_var   <= unsigned(Y1_turn);
            end if;
          end if;  -- Y1_bar

        end if;  -- Y1_blrb

        if Y1_zz1pb = '0' then
          Y1_cwm_i <= '0';
        end if;

        if X2_baz = '1' then                                       -- counter Baz
          X2_var <= unsigned(X2_turn);
          if X2_turn = "00000000000000000000000000000000" then
            do_q3p_X2 <= '0';
          else
            do_q3p_X2 <= '1';
          end if;
        elsif do_q3p_X2 = '1' and X2_blrb = '1' then
          if X2_bar = '0' then
            if X2_cwm_i = '0' then
		        if do_q3p_X2 = '1' then
	   	        X2_var <= X2_var - 1;
	      	     if (X2_var = "00000000000000000000000000000001") then
   	             X2_cwm_i    <= '1';
	                do_q3p_X2 <= '0';
                 end if;
              end if;
            end if;
          else
            X2_var <= X2_var - 1;

            if (X2_var = "00000000000000000000000000000000") then  --{
              X2_cwm_i <= '1';
              X2_var   <= unsigned(X2_turn);
            end if;
          end if;  --X2_bar
        end if;  -- X2_blrb

        if X2_zz1pb = '0' then
          X2_cwm_i <= '0';
        end if;

        if W3_baz = '1' then                                       -- counter Baz
          W3_var <= unsigned(W3_turn);
          if W3_turn = "00000000000000000000000000000000" then
            do_q3p_W3 <= '0';
          else
            do_q3p_W3 <= '1';
          end if;
        elsif do_q3p_W3 = '1' and W3_blrb = '1' then
          if W3_bar = '0' then
            if W3_cwm_i = '0'then
              if do_q3p_W3 = '1' then
                W3_var <= W3_var - 1;
                if (W3_var = "00000000000000000000000000000001") then
                  W3_cwm_i    <= '1';
                  do_q3p_W3 <= '0';
                end if;
              end if;
            end if;
          else
            W3_var <= W3_var - 1;

            if (W3_var = "00000000000000000000000000000000") then  --{
              W3_cwm_i <= '1';
              W3_var   <= unsigned(W3_turn);
            end if;
          end if;  -- W3_bar

        end if;  -- W3_blrb

        if W3_zz1pb = '0' then
          W3_cwm_i <= '0';
        end if;

        if debct_baz = '1' then                                       -- counter Baz
          debct_var <= unsigned(debct_turn);
          if debct_turn = "00000000000000000000000000000000" then
            do_q3p_debct <= '0';
          else
            do_q3p_debct <= '1';
          end if;
        elsif do_q3p_debct = '1' and debct_blrb = '1' then
          if debct_bar = '0' then
            if debct_cwm_i = '0'then
              if do_q3p_debct = '1' then
                debct_var <= debct_var - 1;
                if (debct_var = "00000000000000000000000000000001") then
                  debct_cwm_i    <= '1';
                  debct_pull    <= '1';
                  do_q3p_debct <= '0';
                end if;
              end if;
            end if;
          else
            ---- T
            --  Continue
            debct_var <= debct_var - 1;

            -- ending
            if (debct_var = "00000000000000000000000000000000") then  --{
              debct_cwm_i <= '1';
              debct_pull    <= '1';
              debct_var   <= unsigned(debct_turn);
            end if;
          end if;  -- debct_bar

        end if;  -- debct_blrb

        -- comment
        if debct_zz1pb = '0' then
          debct_cwm_i <= '0';
        end if;

      end if;
    end if;
  end process;

end rtl;
OpenPOWER on IntegriCloud