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

Subversion Repositories nocem

[/] [nocem/] [trunk/] [bridge/] [noc2proc_bridge2.vhd] - Blame information for rev 8

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 5 schelleg
 
2
-----------------------------------------------------------------------------
3
-- NoCem -- Network on Chip Emulation Tool for System on Chip Research 
4
-- and Implementations
5
-- 
6
-- Copyright (C) 2006  Graham Schelle, Dirk Grunwald
7
-- 
8
-- This program is free software; you can redistribute it and/or
9
-- modify it under the terms of the GNU General Public License
10
-- as published by the Free Software Foundation; either version 2
11
-- of the License, or (at your option) any later version.
12
-- 
13
-- This program is distributed in the hope that it will be useful,
14
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
15
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
-- GNU General Public License for more details.
17
-- 
18
-- You should have received a copy of the GNU General Public License
19
-- along with this program; if not, write to the Free Software
20
-- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  
21
-- 02110-1301, USA.
22
-- 
23
-- The authors can be contacted by email: <schelleg,grunwald>@cs.colorado.edu 
24
-- 
25
-- or by mail: Campus Box 430, Department of Computer Science,
26
-- University of Colorado at Boulder, Boulder, Colorado 80309
27
-------------------------------------------------------------------------------- 
28
 
29
 
30
-- 
31 2 schelleg
-- Filename: noc2proc_bridge2.vhd
32 5 schelleg
-- 
33 2 schelleg
-- Description: the bridge for proc2noc communication
34 5 schelleg
-- 
35 2 schelleg
 
36 5 schelleg
 
37
 
38 2 schelleg
library IEEE;
39
use IEEE.STD_LOGIC_1164.ALL;
40
use IEEE.STD_LOGIC_ARITH.ALL;
41
use IEEE.STD_LOGIC_UNSIGNED.ALL;
42
use IEEE.STD_LOGIC_textio.all;
43
 
44
 
45
use work.pkg_nocem.all;
46 3 schelleg
--use work.pkg_snocem.all;
47 2 schelleg
 
48
library std;
49
use std.textio.all;
50
 
51
 
52
entity noc2proc_bridge2 is
53
  generic
54
  (
55
 
56
    -- DO NOT EDIT BELOW THIS LINE ---------------------
57
    -- Bus protocol parameters, do not add to or delete
58
    C_AWIDTH                       : integer              := 32;
59
    C_DWIDTH                       : integer              := 64;
60
    C_NUM_CS                       : integer              := 1;
61
    C_NUM_CE                       : integer              := 2;
62
    C_IP_INTR_NUM                  : integer              := 1
63
    -- DO NOT EDIT ABOVE THIS LINE ---------------------
64
  );
65
  port
66
  (
67
    -- ADD USER PORTS BELOW THIS LINE ------------------
68
 
69
 
70
                noc_arb_req         : out  std_logic;
71
                noc_arb_cntrl_out       : out  arb_cntrl_word;
72
 
73
                noc_arb_grant       : in  std_logic;
74
                noc_arb_cntrl_in        : in  arb_cntrl_word;
75
 
76
                noc_datain        : in   std_logic_vector(NOCEM_DW-1 downto 0);
77
                noc_datain_valid  : in   std_logic;
78
                noc_datain_recvd  : out  std_logic;
79
 
80
                noc_dataout       : out std_logic_vector(NOCEM_DW-1 downto 0);
81
                noc_dataout_valid : out std_logic;
82
                noc_dataout_recvd : in  std_logic;
83
 
84
                noc_pkt_cntrl_in        : in   pkt_cntrl_word;
85
                noc_pkt_cntrl_in_valid  : in   std_logic;
86
                noc_pkt_cntrl_in_recvd  : out  std_logic;
87
 
88
                noc_pkt_cntrl_out       : out pkt_cntrl_word;
89
                noc_pkt_cntrl_out_valid : out std_logic;
90
                noc_pkt_cntrl_out_recvd : in  std_logic;
91
 
92
 
93
 
94
 
95
 
96
    -- ADD USER PORTS ABOVE THIS LINE ------------------
97
 
98
    -- DO NOT EDIT BELOW THIS LINE ---------------------
99
    -- Bus protocol ports, do not add to or delete
100
    Bus2IP_Clk                     : in  std_logic;
101
    Bus2IP_Reset                   : in  std_logic;
102
    IP2Bus_IntrEvent               : out std_logic_vector(0 to C_IP_INTR_NUM-1);
103
    Bus2IP_Addr                    : in  std_logic_vector(0 to C_AWIDTH-1);
104
    Bus2IP_Data                    : in  std_logic_vector(0 to C_DWIDTH-1);
105
    Bus2IP_BE                      : in  std_logic_vector(0 to C_DWIDTH/8-1);
106
    Bus2IP_Burst                   : in  std_logic;
107
    Bus2IP_CS                      : in  std_logic_vector(0 to C_NUM_CS-1);
108
    Bus2IP_CE                      : in  std_logic_vector(0 to C_NUM_CE-1);
109
    Bus2IP_RdCE                    : in  std_logic_vector(0 to C_NUM_CE-1);
110
    Bus2IP_WrCE                    : in  std_logic_vector(0 to C_NUM_CE-1);
111
    Bus2IP_RdReq                   : in  std_logic;
112
    Bus2IP_WrReq                   : in  std_logic;
113
    IP2Bus_Data                    : out std_logic_vector(0 to C_DWIDTH-1);
114
    IP2Bus_Retry                   : out std_logic;
115
    IP2Bus_Error                   : out std_logic;
116
    IP2Bus_ToutSup                 : out std_logic;
117
    IP2Bus_RdAck                   : out std_logic;
118
    IP2Bus_WrAck                   : out std_logic
119
    -- DO NOT EDIT ABOVE THIS LINE ---------------------
120
  );
121
end noc2proc_bridge2;
122
 
123
architecture Behavioral of noc2proc_bridge2 is
124
 
125
        COMPONENT packetbuffer2
126
        generic(
127
                 METADATA_WIDTH : integer;
128
                 METADATA_LENGTH : integer
129
        );
130
        Port (
131
                din   : IN std_logic_VECTOR(31 downto 0);
132
                rd_en : IN std_logic;
133
                wr_en : IN std_logic;
134
                dout  : OUT std_logic_VECTOR(31 downto 0);
135
                empty : OUT std_logic;
136
                full  : OUT std_logic;
137
                pkt_metadata_din                : in std_logic_vector(METADATA_WIDTH-1 downto 0);
138
                pkt_metadata_re         : IN std_logic;
139
                pkt_metadata_we         : IN std_logic;
140
                pkt_metadata_dout       : out std_logic_vector(METADATA_WIDTH-1 downto 0);
141
                clk : in std_logic;
142
      rst : in std_logic);
143
        END COMPONENT;
144
 
145
 
146
 
147
        ------------------ GLOBAL SIGNALS     ----------------------------------
148
        signal clk,rst : std_logic;
149
        signal  arb_sending_word,arb_receiving_word   :   arb_cntrl_word;
150
        signal allones_vcwidth : std_logic_vector(NOCEM_NUM_VC-1 downto 0);
151
 
152
 
153
   ------------------ PB 2 NoC Signals   ----------------------------------
154
        signal pb2noc_word1,pb2noc_word2,pb2noc_word3,pb2noc_word4 : std_logic_vector(31 downto 0);
155
        signal outgoing_next_free_vc  : std_logic_vector(NOCEM_NUM_VC-1 downto 0);
156
        signal outgoing_vc_state : std_logic_Vector(NOCEM_NUM_VC-1 downto 0);   -- 0: free, 1: allocated --
157
        signal pb2noc_vc_alloc : std_logic;
158
        signal outgoing_free_this_vc     : std_logic_vector(NOCEM_NUM_VC-1 downto 0);
159
        signal vc_mux_wr_reg     : std_logic_vector(NOCEM_VC_ID_WIDTH-1 downto 0);
160
        signal pb2noc_byte_counter : std_logic_vector(7 downto 0);
161
        signal pb2noc_pkt_dest_addr : std_logic_vector(NOCEM_AW-1 downto 0);
162
        signal pb2noc_pkt_len : std_logic_vector(7 downto 0);
163
 
164
        signal pb2noc_amI_os : std_logic;
165
 
166
        type pb2noc_st is (init_st,getting_vc_st,sending_word1_st,sending_word2_st,sending_word3_st,sending_word4_st) ;
167
        signal pb2noc_state,pb2noc_nextState : pb2noc_st;
168
 
169
   ------------------ PB 2 Processor Signals   ----------------------------
170
        signal pb2proc_interrupt : std_logic_vector(0 to C_IP_INTR_NUM-1);
171
        signal pb2proc_byte_counter : std_logic_vector(7 downto 0);
172
        signal pb2proc_dest_addr_i : std_logic_vector(NOCEM_AW-1 downto 0);
173
        signal pb2proc_pkt_len_i : std_logic_vector(7 downto 0);
174
        signal pb2proc_len_addr_aggr : std_logic_vector(0 to C_DWIDTH-1);
175
 
176
 
177
 
178
        type pb2proc_st is (IDLE_ST, SENDING_META_ST,SENDING_ST) ;
179
        signal pb2proc_state,pb2proc_nextState : pb2proc_st;
180
 
181
 
182
   ------------------ NoC 2 PB Signals   ----------------------------------
183
        signal  noc2pb_next_vc_with_pkt,noc2pb_finished_pkt,noc2pb_eop_wr_sig,noc2pb_pkt_rdy     : std_logic_vector(NOCEM_NUM_VC-1 downto 0);
184
        signal  noc2pb_recv_idle : std_logic;
185
        signal  noc2pb_din_pad : std_logic_vector(31 downto 0);
186
        signal  noc2pb_din_reg : std_logic_vector(31 downto 0);
187
   signal  noc2pb_byte_counter : std_logic_vector(7 downto 0);
188
        signal  noc2pb_we_delay, noc2pb_mwe_delay : std_logic;
189
        signal  noc2pb_we_b1,noc2pb_we_b2,noc2pb_we_b3,noc2pb_we_b4 : std_logic;
190
        signal  noc2pb_din_rotated : std_logic_vector(31 downto 0);
191
 
192
 
193
        type noc2pb_st is (init_st,recving_word1_st,recving_word2_st,recving_word3_st,recving_word4_st) ;
194
        signal noc2pb_state,noc2pb_nextState : noc2pb_st;
195
 
196
 
197
 
198
 
199
 
200
   ------------------ Processor 2 PB Signals   ----------------------------
201
        signal proc2pb_dest_addr_i : std_logic_vector(NOCEM_AW-1 downto 0);
202
        signal proc2pb_pkt_len_i : std_logic_vector(7 downto 0);
203
        signal proc2pb_byte_counter : std_logic_vector(7 downto 0);
204
 
205
        type proc2pb_st is (IDLE_ST, SENDING_ST) ;
206
        signal proc2pb_state,proc2pb_nextState : proc2pb_st;
207
 
208
 
209
        ------------------ PKT BUFFER SIGNALS ----------------------------------
210
        constant METADATA_WIDTH  : integer := NOCEM_AW+8 ;
211
        constant METADATA_LENGTH : integer := 16 ;
212
 
213
 
214
        signal din_n2p,dout_n2p : std_logic_vector(31 downto 0);
215
        signal re_n2p,we_n2p,empty_n2p,full_n2p,mre_n2p,mwe_n2p : std_logic;
216
        signal mdin_n2p,mdout_n2p : std_logic_vector(METADATA_WIDTH-1 downto 0);
217
 
218
 
219
        signal din_p2n,dout_p2n : std_logic_vector(31 downto 0);
220
        signal re_p2n,we_p2n,empty_p2n,full_p2n,mre_p2n,mwe_p2n : std_logic;
221
        signal mdin_p2n,mdout_p2n : std_logic_vector(METADATA_WIDTH-1 downto 0);
222
   -------------------------------------------------------------------------
223
 
224
 
225
 
226
 
227
        ------------------------ DEBUG SIGNALLING
228
        signal debug_p2n_addr1,debug_p2n_addr2 : std_logic_vector (0 to 11);
229
        signal debug_p2n_boolean_test1,debug_p2n_boolean_test2,debug_p2n_boolean_test3 : std_logic;
230
        signal tl_debug : std_logic_vector(4 downto 0);
231
 
232
 
233
begin
234
 
235
---------------------------------------------------------------------
236
--------------------- GLOBAL RENAMING, ETC --------------------------
237
---------------------------------------------------------------------
238
 
239
clk <= Bus2IP_Clk;
240
rst <= Bus2IP_Reset;
241
noc_arb_cntrl_out <= arb_sending_word or arb_receiving_word;
242
 
243
IP2Bus_Error       <= '0';
244
IP2Bus_Retry       <= '0';
245
IP2Bus_ToutSup     <= '0';
246
 
247
 
248
 
249
 
250
 
251
---------------------------------------------------------------------
252
------------ PROCESSSOR TO PKT BUFFER PROCESSES ---------------------
253
---------------------------------------------------------------------
254
 
255
 
256
----------------------------------------------------------------------------
257
--      Processor to noc packet flow
258
 
259
-- the Processor wants to write a packet to the NoC.  It must first write and address
260
-- into the noc_addr_reg and packet length and then begin writing the packet.  
261
-- This is accomplished by using the following register locations:
262
--      
263
--                      C_BASE_ADDR + 0x000: NOC_ADDR_REG,NOC_PACKET_LENGTH
264
--                      C_BASE_ADDR + 0x004: IP2NOC_PACKET_DATA
265
--                                      ...
266
--                                      ...
267
-- the PPC will write to successive locations (in burst mode) so once a write starts
268
-- this process will just accept the successive writes and hand it off to the NoC
269
----------------------------------------------------------------------------
270
 
271
 
272
 
273
proc2pb_clkd : process (clk,rst)
274
 
275
variable L : line;
276
 
277
begin
278
        if rst='1' then
279
                proc2pb_dest_addr_i     <= (others => '0');
280
                proc2pb_pkt_len_i               <= (others => '0');
281
                proc2pb_byte_counter  <= (others => '0');
282
                proc2pb_state                   <= IDLE_ST;
283
 
284
        elsif clk='1' and clk'event then
285
                proc2pb_state <= proc2pb_nextState;
286
                case proc2pb_state is
287
                        when IDLE_ST =>
288
 
289
 
290
                                -----------------------------------------------------------
291
                                --              THIS IS FOR TASKLIST EXERCISER WORK                                     --
292
                                -----------------------------------------------------------
293
                                --224   0E0     11100000        SIMULATION ONLY                 an entire tasklist has begun being allocated
294
                                --228   0E4     11100100        SIMULATION ONLY                 an entire tasklist has finished -- all CE's are deallocated
295
                                --232   0E8     11101000        SIMULATION ONLY                 an allocation attempt has been successful
296
                                --236   0EC     11101100        SIMULATION ONLY                 an allocation attempt has NOT been successful
297
                                --240   0F0     11110000        SIMULATION ONLY                 a deallocation occurred
298
 
299
                                if      Bus2IP_Addr(C_AWIDTH-12 to C_AWIDTH-1) = X"0E0" and
300
                                        Bus2IP_WrReq = '1' and
301
                                        Bus2IP_CS /= 0 and
302
                                        Bus2IP_CE /= 0   then
303
 
304 3 schelleg
--                                                      write(L, string'("OS checkpoint: ")); 
305
--                                                      write(L,time'image(NOW));                                               
306
--                                                      write(L, string'(" tasklist started: "));                                                               
307
--                                                      write(L, string'(" with OS Data: "));   
308
--                                                      hwrite(L, Bus2IP_data);                                                 
309
--                                                      writeline(OUTPUT, L);                           
310 2 schelleg
 
311
--                                                      tl_debug(4) <= '1';
312
--
313
--                                                      IP2Bus_WrAck            <= '1';
314
--                                                      proc2pb_nextState <= IDLE_ST;   
315
                                end if;
316
 
317
 
318
                                if      Bus2IP_Addr(C_AWIDTH-12 to C_AWIDTH-1) = X"0E4" and
319
                                        Bus2IP_WrReq = '1' and
320
                                        Bus2IP_CS /= 0 and
321
                                        Bus2IP_CE /= 0   then
322
 
323 3 schelleg
--                                                      write(L, string'("OS checkpoint: ")); 
324
--                                                      write(L,time'image(NOW));                                               
325
--                                                      write(L, string'(" tasklist ended: "));                                                         
326
--                                                      write(L, string'(" with OS Data: "));   
327
--                                                      hwrite(L, Bus2IP_data);                                                 
328
--                                                      writeline(OUTPUT, L);                           
329 2 schelleg
 
330
--                                                      tl_debug(3) <= '1';
331
--              
332
--                                                      IP2Bus_WrAck            <= '1';
333
--                                                      proc2pb_nextState <= IDLE_ST;   
334
                                end if;
335
 
336
                                if      Bus2IP_Addr(C_AWIDTH-12 to C_AWIDTH-1) = X"0E8" and
337
                                        Bus2IP_WrReq = '1' and
338
                                        Bus2IP_CS /= 0 and
339
                                        Bus2IP_CE /= 0   then
340
 
341 3 schelleg
--                                                      write(L, string'("OS checkpoint: ")); 
342
--                                                      write(L,time'image(NOW));                                               
343
--                                                      write(L, string'(" task allocated SUCCESS: "));                                                         
344
--                                                      write(L, string'(" with OS Data: "));   
345
--                                                      hwrite(L, Bus2IP_data);                                                 
346
--                                                      writeline(OUTPUT, L);                           
347 2 schelleg
 
348
--                                                      tl_debug(2) <= '1';
349
--
350
--                                                      IP2Bus_WrAck            <= '1';
351
--                                                      proc2pb_nextState <= IDLE_ST;   
352
                                end if;
353
 
354
 
355
                                if      Bus2IP_Addr(C_AWIDTH-12 to C_AWIDTH-1) = X"0EC" and
356
                                        Bus2IP_WrReq = '1' and
357
                                        Bus2IP_CS /= 0 and
358
                                        Bus2IP_CE /= 0   then
359
 
360 3 schelleg
--                                                      write(L, string'("OS checkpoint: ")); 
361
--                                                      write(L,time'image(NOW));                                               
362
--                                                      write(L, string'(" task alloacted FAILURE: "));                                                         
363
--                                                      write(L, string'(" with OS Data: "));   
364
--                                                      hwrite(L, Bus2IP_data);                                                 
365
--                                                      writeline(OUTPUT, L);                           
366 2 schelleg
 
367
--                                                      tl_debug(1) <= '1';
368
--
369
--                                                      IP2Bus_WrAck            <= '1';
370
--                                                      proc2pb_nextState <= IDLE_ST;   
371
--                                                      
372
                                end if;
373
 
374
                                if      Bus2IP_Addr(C_AWIDTH-12 to C_AWIDTH-1) = X"0F0" and
375
                                        Bus2IP_WrReq = '1' and
376
                                        Bus2IP_CS /= 0 and
377
                                        Bus2IP_CE /= 0   then
378
 
379 3 schelleg
--                                                      write(L, string'("OS checkpoint: ")); 
380
--                                                      write(L,time'image(NOW));                                               
381
--                                                      write(L, string'(" CE Deallocated: "));                                                         
382
--                                                      write(L, string'(" with OS Data: "));   
383
--                                                      hwrite(L, Bus2IP_data);                                                 
384
----                                                    writeline(OUTPUT, L);
385
--
386
--                                                      write(L, string'(" ")); 
387
--                                                      writeline(OUTPUT, L);                                                   
388 2 schelleg
 
389
--                                                      tl_debug(0) <= '1';
390
--
391
--                                                      IP2Bus_WrAck            <= '1';
392
--                                                      proc2pb_nextState <= IDLE_ST;   
393
--                                                      
394
                                end if;
395
 
396
 
397
                                if      Bus2IP_Addr(C_AWIDTH-12 to C_AWIDTH-1) = X"0F4" and
398
                                        Bus2IP_WrReq = '1' and
399
                                        Bus2IP_CS /= 0 and
400
                                        Bus2IP_CE /= 0   then
401
 
402 3 schelleg
--                                                      write(L, string'("OS checkpoint: ")); 
403
--                                                      write(L,time'image(NOW));                                               
404
--                                                      write(L, string'(" BAD SYSCALL PACKET: "));                                                             
405
--                                                      write(L, string'(" with OS Data: "));   
406
--                                                      hwrite(L, Bus2IP_data);                                                 
407
--                                                      writeline(OUTPUT, L);                           
408 2 schelleg
 
409
--                                                      --tl_debug(0) <= '1';
410
--
411
--                                                      IP2Bus_WrAck            <= '1';
412
--                                                      proc2pb_nextState <= IDLE_ST;   
413
--                                                      
414
                                end if;
415
 
416
 
417
 
418
                                if      Bus2IP_Addr(C_AWIDTH-12 to C_AWIDTH-1) = X"0D8" and
419
                                        Bus2IP_WrReq = '1' and
420
                                        Bus2IP_CS /= 0 and
421
                                        Bus2IP_CE /= 0   then
422
 
423 3 schelleg
--                                                      write(L, string'("OS checkpoint: ")); 
424
--                                                      write(L,time'image(NOW));                                               
425
--                                                      write(L, string'(" STATISTICS COLLECTED: "));                                                           
426
--                                                      write(L, string'(" with runtime: "));   
427
--                                                      hwrite(L, Bus2IP_data);                                                 
428
--                                                      writeline(OUTPUT, L);                           
429 2 schelleg
 
430
--                                                      --tl_debug(0) <= '1';
431
--
432
--                                                      IP2Bus_WrAck            <= '1';
433
--                                                      proc2pb_nextState <= IDLE_ST;   
434
--                                                      
435
                                end if;
436
 
437
 
438
                                if      Bus2IP_Addr(C_AWIDTH-12 to C_AWIDTH-1) = X"0DC" and
439
                                        Bus2IP_WrReq = '1' and
440
                                        Bus2IP_CS /= 0 and
441
                                        Bus2IP_CE /= 0   then
442
 
443 3 schelleg
--                                                      write(L, string'("OS checkpoint: ")); 
444
--                                                      write(L,time'image(NOW));                                               
445
--                                                      write(L, string'(" STATISTICS COLLECTED: "));                                                           
446
--                                                      write(L, string'(" with packets sent: "));      
447
--                                                      hwrite(L, Bus2IP_data);                                                 
448
--                                                      writeline(OUTPUT, L);                           
449 2 schelleg
 
450
--                                                      --tl_debug(0) <= '1';
451
--
452
--                                                      IP2Bus_WrAck            <= '1';
453
--                                                      proc2pb_nextState <= IDLE_ST;   
454
--                                                      
455
                                end if;
456
 
457
 
458
                                -----------------------------------------------------------
459
                                --              END TASKLIST EXERCISER WORK                                                     --
460
                                -----------------------------------------------------------
461
 
462
 
463
 
464
 
465
 
466
 
467
 
468
 
469
 
470
 
471
 
472
                                if Bus2IP_Addr(C_AWIDTH-12 to C_AWIDTH-1) = X"000" and
473
                                        Bus2IP_WrReq = '1' and
474
                                        Bus2IP_CS /= 0 and
475
                                        Bus2IP_CE /= 0   then
476
 
477
                                                proc2pb_dest_addr_i <= Bus2IP_Data(32-NOCEM_AW to 31);
478
                                                proc2pb_pkt_len_i <= Bus2IP_Data(16 to 23);
479
                                else
480
                                                proc2pb_dest_addr_i   <= (others => '0');
481
                                                proc2pb_pkt_len_i     <= (others => '0');
482
                                                proc2pb_byte_counter  <= (others => '0');
483
                                end if;
484
 
485
                        when SENDING_ST =>
486
 
487
 
488
                                -- to send data, must have data coming from PLB and also ready on Noc side
489
                                if full_p2n = '0' and
490
                                        Bus2IP_Addr(C_AWIDTH-12 to C_AWIDTH-1) >= X"004" and
491
                                        Bus2IP_Addr(C_AWIDTH-12 to C_AWIDTH-1) < X"080" and
492
                                        Bus2IP_WrReq = '1' and
493
                                        Bus2IP_CS /= 0 and
494
                                        Bus2IP_CE /= 0   then
495
                                                -- may have to decode BE signal coming in
496
                                                proc2pb_byte_counter <= proc2pb_byte_counter+4;
497
                                else
498
                                        null;
499
                                end if;
500
 
501
                        when others =>
502
                                null;
503
                 end case;
504
 
505
        end if;
506
 
507
 
508
end process;
509
 
510
 
511
 
512
proc2pb_uclkd : process (full_p2n,proc2pb_dest_addr_i,Bus2IP_Data, Bus2IP_BE,proc2pb_state, Bus2IP_Addr, Bus2IP_WrReq, Bus2IP_CS, Bus2IP_CE, proc2pb_byte_counter, proc2pb_pkt_len_i)
513
 
514
 
515
begin
516
 
517
 
518
        proc2pb_nextState       <= IDLE_ST;
519
--      proc2pb_packet          <= (others => '0');
520
        --proc2pb_packet_we     <= '0';
521
 
522
        IP2Bus_WrAck            <= '0';
523
 
524
        din_p2n  <= (others => '0');
525
        mdin_p2n <= (others => '0');
526
        we_p2n <= '0';
527
        mwe_p2n <= '0';
528
 
529
        tl_debug <= (others => '0');
530
 
531
        case proc2pb_state      is
532
                        when IDLE_ST =>
533
 
534
 
535
                                -----------------------------------------------------------
536
                                --              THIS IS FOR TASKLIST EXERCISER WORK                                     --
537
                                -----------------------------------------------------------
538
                                --224   0E0     11100000        SIMULATION ONLY                 an entire tasklist has begun being allocated
539
                                --228   0E4     11100100        SIMULATION ONLY                 an entire tasklist has finished -- all CE's are deallocated
540
                                --232   0E8     11101000        SIMULATION ONLY                 an allocation attempt has been successful
541
                                --236   0EC     11101100        SIMULATION ONLY                 an allocation attempt has NOT been successful
542
                                --240   0F0     11110000        SIMULATION ONLY                 a deallocation occurred
543
 
544
                                if      Bus2IP_Addr(C_AWIDTH-12 to C_AWIDTH-1) = X"0E0" and
545
                                        Bus2IP_WrReq = '1' and
546
                                        Bus2IP_CS /= 0 and
547
                                        Bus2IP_CE /= 0   then
548
 
549
--                                                      write(L, string'("OS checkpoint: ")); 
550
--                                                      write(L,time'image(NOW));                                               
551
--                                                      write(L, string'(" tasklist started: "));                                                               
552
--                                                      write(L, string'(" with OS Data: "));   
553
--                                                      hwrite(L, Bus2IP_data);                                                 
554
--                                                      writeline(OUTPUT, L);                           
555
--                                              
556
                                                        tl_debug(4) <= '1';
557
 
558
                                                        IP2Bus_WrAck            <= '1';
559
                                                        proc2pb_nextState <= IDLE_ST;
560
                                end if;
561
 
562
 
563
                                if      Bus2IP_Addr(C_AWIDTH-12 to C_AWIDTH-1) = X"0E4" and
564
                                        Bus2IP_WrReq = '1' and
565
                                        Bus2IP_CS /= 0 and
566
                                        Bus2IP_CE /= 0   then
567
 
568
--                                                      write(L, string'("OS checkpoint: ")); 
569
--                                                      write(L,time'image(NOW));                                               
570
--                                                      write(L, string'(" tasklist ended: "));                                                         
571
--                                                      write(L, string'(" with OS Data: "));   
572
--                                                      hwrite(L, Bus2IP_data);                                                 
573
--                                                      writeline(OUTPUT, L);                           
574
--              
575
                                                        tl_debug(3) <= '1';
576
 
577
                                                        IP2Bus_WrAck            <= '1';
578
                                                        proc2pb_nextState <= IDLE_ST;
579
                                end if;
580
 
581
                                if      Bus2IP_Addr(C_AWIDTH-12 to C_AWIDTH-1) = X"0E8" and
582
                                        Bus2IP_WrReq = '1' and
583
                                        Bus2IP_CS /= 0 and
584
                                        Bus2IP_CE /= 0   then
585
 
586
--                                                      write(L, string'("OS checkpoint: ")); 
587
--                                                      write(L,time'image(NOW));                                               
588
--                                                      write(L, string'(" task allocated SUCCESS: "));                                                         
589
--                                                      write(L, string'(" with OS Data: "));   
590
--                                                      hwrite(L, Bus2IP_data);                                                 
591
--                                                      writeline(OUTPUT, L);                           
592
--
593
                                                        tl_debug(2) <= '1';
594
 
595
                                                        IP2Bus_WrAck            <= '1';
596
                                                        proc2pb_nextState <= IDLE_ST;
597
                                end if;
598
 
599
 
600
                                if      Bus2IP_Addr(C_AWIDTH-12 to C_AWIDTH-1) = X"0EC" and
601
                                        Bus2IP_WrReq = '1' and
602
                                        Bus2IP_CS /= 0 and
603
                                        Bus2IP_CE /= 0   then
604
 
605
--                                                      write(L, string'("OS checkpoint: ")); 
606
--                                                      write(L,time'image(NOW));                                               
607
--                                                      write(L, string'(" task alloacted FAILURE: "));                                                         
608
--                                                      write(L, string'(" with OS Data: "));   
609
--                                                      hwrite(L, Bus2IP_data);                                                 
610
--                                                      writeline(OUTPUT, L);                           
611
--
612
                                                        tl_debug(1) <= '1';
613
 
614
                                                        IP2Bus_WrAck            <= '1';
615
                                                        proc2pb_nextState <= IDLE_ST;
616
 
617
                                end if;
618
 
619
                                if      Bus2IP_Addr(C_AWIDTH-12 to C_AWIDTH-1) = X"0F0" and
620
                                        Bus2IP_WrReq = '1' and
621
                                        Bus2IP_CS /= 0 and
622
                                        Bus2IP_CE /= 0   then
623
 
624
--                                                      write(L, string'("OS checkpoint: ")); 
625
--                                                      write(L,time'image(NOW));                                               
626
--                                                      write(L, string'(" CE Deallocated: "));                                                         
627
--                                                      write(L, string'(" with OS Data: "));   
628
--                                                      hhwrite(L, Bus2IP_data);                                                        
629
--                                                      writeline(OUTPUT, L);                           
630
--
631
                                                        tl_debug(0) <= '1';
632
 
633
                                                        IP2Bus_WrAck            <= '1';
634
                                                        proc2pb_nextState <= IDLE_ST;
635
 
636
                                end if;
637
 
638
 
639
                                if      Bus2IP_Addr(C_AWIDTH-12 to C_AWIDTH-1) = X"0F4" and
640
                                        Bus2IP_WrReq = '1' and
641
                                        Bus2IP_CS /= 0 and
642
                                        Bus2IP_CE /= 0   then
643
 
644
--                                                      write(L, string'("OS checkpoint: ")); 
645
--                                                      write(L,time'image(NOW));                                               
646
--                                                      write(L, string'(" BAD SYSCALL PACKET: "));                                                             
647
--                                                      write(L, string'(" with OS Data: "));   
648
--                                                      hwrite(L, Bus2IP_data);                                                 
649
--                                                      writeline(OUTPUT, L);                           
650
 
651
                                                        --tl_debug(0) <= '1';
652
 
653
                                                        IP2Bus_WrAck            <= '1';
654
                                                        proc2pb_nextState <= IDLE_ST;
655
 
656
                                end if;
657
 
658
 
659
                                -----------------------------------------------------------
660
                                --              END TASKLIST EXERCISER WORK                                                     --
661
                                -----------------------------------------------------------
662
 
663
 
664
 
665
 
666
                                if Bus2IP_Addr(C_AWIDTH-12 to C_AWIDTH-1) = X"000" and
667
                                        Bus2IP_WrReq = '1' and
668
                                        Bus2IP_CS /= 0 and
669
                                        Bus2IP_CE /= 0   then
670
 
671
                                                IP2Bus_WrAck <= '1';
672
                                                proc2pb_nextState <= SENDING_ST;
673
 
674
                                else
675
                                        proc2pb_nextState <= IDLE_ST;
676
                                end if;
677
 
678
                        when SENDING_ST =>
679
 
680
                                if full_p2n = '0' and
681
                                        Bus2IP_Addr(C_AWIDTH-12 to C_AWIDTH-1) >= X"004" and
682
                                        Bus2IP_Addr(C_AWIDTH-12 to C_AWIDTH-1) < X"080" and
683
                                        Bus2IP_WrReq = '1' and
684
                                        Bus2IP_CS /= 0 and
685
                                        Bus2IP_CE /= 0   then
686
 
687
                                                din_p2n         <= Bus2IP_data(0 to 31);
688
                                                we_p2n          <= '1';
689
                                                IP2Bus_WrAck <= '1';
690
                                end if;
691
 
692
 
693
 
694
                                mdin_p2n(NOCEM_AW-1 downto 0)                    <= proc2pb_dest_addr_i;
695
                                mdin_p2n(NOCEM_AW+7 downto NOCEM_AW)    <= proc2pb_pkt_len_i;
696
                                -- when am done sending packet
697
                                if proc2pb_byte_counter >= proc2pb_pkt_len_i then
698
                                        proc2pb_nextState <= IDLE_ST;
699
                                        mwe_p2n <= '1';
700
                                else
701
                                        proc2pb_nextState <= SENDING_ST;
702
                                end if;
703
                        when others =>
704
                                null;
705
        end case;
706
 
707
end process;
708
 
709
 
710
 
711
 
712
 
713
 
714
 
715
 
716
 
717
---------------------------------------------------------------------
718
------------  PKT BUFFER TO PROCESSOR PROCESSES     -----------------
719
---------------------------------------------------------------------
720
 
721
 
722
----------------------------------------------------------------------------
723
-- PKT BUFFER to Processor packet flow
724
--
725
-- the noc has pb2proc_interrupted the processor and now is being requested to send a packet
726
-- up to the Processor for handling.  This is accomplished by the processor reading from
727
-- the memory locations that are specifically used for this.
728
--              
729
--                              C_BASE_ADDR + 0x080: NOC_ADDR_REG,NOC_PACKET_LENGTH
730
--                              C_BASE_ADDR + 0x084: NOC2IP_PACKET_DATA
731
--                                      ...
732
--                                      ...
733
-- The PPC will read the addr and length values and then do reads of the packet.  The
734
-- packet will eventually be consumed directly or buffered elsewhere.  The Processor cannot
735
-- will not attempt to read the packet twice from this bridge as it is not supported ;)
736
--  
737
----------------------------------------------------------------------------
738
 
739
 
740
----------------------------------------------------------------------------
741
--  when a packet arrives, pb2proc_interrupt the processor and let the processor 
742
--  do normal plb reads to get the packet into a packetbuffer for processing
743
--
744
--  need to make sure the packet is read and copied somewhere, as this block
745
--  is not going to handle holding the packet and manage random access to contents
746
----------------------------------------------------------------------------
747
 
748
 
749
 
750
 
751
pb2proc_clkd : process (clk,rst)
752
begin
753
 
754
        if rst='1' then
755
 
756
                pb2proc_byte_counter  <= (others => '0');
757
                pb2proc_state                   <= IDLE_ST;
758
 
759
        elsif clk='1' and clk'event then
760
                pb2proc_state <= pb2proc_nextState;
761
                case pb2proc_state is
762
                        when IDLE_ST =>
763
                                pb2proc_byte_counter  <= (others => '0');
764
                        when SENDING_META_ST =>
765
                                pb2proc_byte_counter  <= (others => '0');
766
                        when SENDING_ST =>
767
 
768
                                -- increment this counter as 4B get read each time
769
                                if Bus2IP_Addr(C_AWIDTH-12 to C_AWIDTH-1) >= X"084" and
770
                                        Bus2IP_Addr(C_AWIDTH-12 to C_AWIDTH-1) < X"100" and
771
                                        Bus2IP_RdReq = '1' and
772
                                        Bus2IP_CS /= 0 and
773
                                        Bus2IP_CE /= 0   then
774
 
775
                                                pb2proc_byte_counter <= pb2proc_byte_counter+4;
776
                                end if;
777
                        when others =>   null;
778
                end case;
779
        end if;
780
 
781
 
782
end process;
783
 
784
 
785
 
786
 
787
 
788
 
789
 
790
 
791
pb2proc_uclkd : process (mdout_n2p,pb2proc_interrupt, pb2proc_state, empty_n2p, Bus2IP_Addr, Bus2IP_RdReq, Bus2IP_CS, Bus2IP_CE, dout_n2p, pb2proc_byte_counter)
792
begin
793
 
794
        -- currently, straight translation from NoC inputs (addr,len)
795
   pb2proc_dest_addr_i  <= mdout_n2p(NOCEM_AW-1 downto 0);
796
        pb2proc_pkt_len_i       <= mdout_n2p(NOCEM_AW+7 downto NOCEM_AW);
797
 
798
 
799
        -- aggregate the length and addr into one 64b word for the PLB to read
800
        pb2proc_len_addr_aggr                                                                           <= (others => '0');
801
        pb2proc_len_addr_aggr(16 to 23)                                         <= pb2proc_pkt_len_i;
802
        --pb2proc_len_addr_aggr(47 downto 40)                                   <= pb2proc_pkt_len_i;
803
        --pb2proc_len_addr_aggr(NOCEM_AW+7 downto 8)    <= pb2proc_dest_addr_i;
804
 
805
 
806
        -- zero out outgoing signals
807
        IP2Bus_RdAck                    <= '0';
808
        IP2Bus_Data                     <= (others => '0');
809
        IP2Bus_IntrEvent <= pb2proc_interrupt;
810
 
811
        re_n2p  <= '0';
812
        mre_n2p <= '0';
813
        pb2proc_interrupt <= (others => '0');
814
 
815
 
816
        case pb2proc_state      is
817
                when IDLE_ST =>
818
 
819
                        --------------------------------------
820
                        ------POLLING BASED DESIGN------------
821
                        --------------------------------------
822
                        pb2proc_nextState <= SENDING_META_ST;
823
 
824
                        --------------------------------------
825
                        ------INTERRUPT BASED DESIGN----------
826
                        --------------------------------------
827
--                      if empty_n2p = '0' then
828
--                pb2proc_interrupt <= (others => '1');
829
--                               pb2proc_nextState <= SENDING_META_ST;
830
--            else
831
--                               pb2proc_nextState <= IDLE_ST;
832
--                pb2proc_interrupt <= (others => '0');
833
--            end if; 
834
--
835
 
836
 
837
 
838
 
839
 
840
 
841
 
842
 
843
 
844
                when SENDING_META_ST =>
845
 
846
                        -- the processor has been pb2proc_interrupted and now is requesting len,addr register 
847
                        if      Bus2IP_Addr(C_AWIDTH-12 to C_AWIDTH-1) = X"080" and
848
                                Bus2IP_RdReq = '1' and
849
                                Bus2IP_CS /= 0 and
850
                                Bus2IP_CE /= 0   then
851
 
852
 
853
                                        --------------------------------------
854
                                        ------INTERRUPT BASED DESIGN----------
855
                                        --------------------------------------
856
--                                      IP2Bus_RdAck            <= '1';
857
--                                      IP2Bus_Data             <=  pb2proc_len_addr_aggr;
858
--                                      pb2proc_nextState       <= SENDING_ST;
859
--
860
                                        --------------------------------------
861
                                        ------POLLING BASED DESIGN------------
862
                                        --------------------------------------
863
                                        if empty_n2p = '0' then
864
                                                IP2Bus_RdAck            <= '1';
865
                                                IP2Bus_Data             <=  pb2proc_len_addr_aggr;
866
                                                pb2proc_nextState       <= SENDING_ST;
867
                                        else
868
                                                IP2Bus_RdAck            <= '1';
869
                                                IP2Bus_Data             <= (others => '0');
870
                                                pb2proc_nextState       <= SENDING_META_ST;
871
                                        end if;
872
                        else
873
                                pb2proc_nextState <= SENDING_META_ST;
874
                         end if;
875
 
876
 
877
                        -----------------------------------------------------------
878
                        --              THIS IS SOME DEBUG CODE TO CHECK NOCEM                                  --
879
                        -----------------------------------------------------------
880
                        if      Bus2IP_Addr(C_AWIDTH-12 to C_AWIDTH-1) = X"088" and
881
                                Bus2IP_RdReq = '1' and
882
                                Bus2IP_CS /= 0 and
883
                                Bus2IP_CE /= 0   then
884
 
885
                                                IP2Bus_RdAck            <= '1';
886
                                                IP2Bus_Data             <= X"DEADBEEF";
887
                                                pb2proc_nextState       <= SENDING_META_ST;
888
 
889
                        end if;
890
 
891
 
892
 
893
                        -----------------------------------------------------------
894
                        --              THIS IS SOME DEBUG CODE TO CHECK NOCEM                                  --
895
                        -----------------------------------------------------------
896
                        if      Bus2IP_Addr(C_AWIDTH-12 to C_AWIDTH-1) = X"088" and
897
                                Bus2IP_RdReq = '1' and
898
                                Bus2IP_CS /= 0 and
899
                                Bus2IP_CE /= 0   then
900
 
901
                                                IP2Bus_RdAck            <= '1';
902
                                                IP2Bus_Data             <= X"DEADBEEF";
903
                                                pb2proc_nextState       <= SENDING_META_ST;
904
 
905
                        end if;
906
 
907
 
908
 
909
 
910
 
911
 
912
 
913
 
914
 
915
 
916
                when SENDING_ST =>
917
 
918
                        -- the processor should be now requesting the packet 
919
                        if Bus2IP_Addr(C_AWIDTH-12 to C_AWIDTH-1) >= X"084" and
920
                                Bus2IP_Addr(C_AWIDTH-12 to C_AWIDTH-1) < X"100" and
921
                                Bus2IP_RdReq = '1' and
922
                                Bus2IP_CS /= 0 and
923
                                Bus2IP_CE /= 0   then
924
                                        IP2Bus_RdAck    <= '1';
925
                                        IP2Bus_Data(0 to 31)     <=  dout_n2p;
926
                                        re_n2p <= '1';
927
 
928
                        end if;
929
 
930
                        -- data is read in 4B words, so possible to go over packet length
931
                        -- will be handled in software
932
                        if pb2proc_byte_counter >= pb2proc_pkt_len_i then
933
                                pb2proc_nextState <= IDLE_ST;
934
                                --re_n2p <= '1';
935
                                mre_n2p <= '1';
936
                        else
937
                                pb2proc_nextState <= SENDING_ST;
938
                        end if;
939
 
940
 
941
                when others =>
942
                        null;
943
        end case;
944
 
945
end process;
946
 
947
 
948
 
949
 
950
 
951
---------------------------------------------------------------------
952
------------ NOCEM TO PKT BUFFER PROCESSES      ---------------------
953
---------------------------------------------------------------------
954
 
955
 
956
--      type noc2pb_st is (init_st,recving_word1_st,recving_word2_st,recving_word3_st,recving_word4_st) ;
957
--      signal noc2pb_state,noc2pb_nextState : noc2pb_st;
958
 
959
 
960
noc2pb_clkd : process (clk,rst)
961
begin
962
 
963
 
964
        if rst='1' then
965
                noc2pb_pkt_rdy <= (others => '0');
966
                noc2pb_next_vc_with_pkt <= (others => '0');
967
                noc2pb_recv_idle <= '1';
968
                noc2pb_state <= init_st;
969
                noc2pb_byte_counter <=  (others => '0');
970
                noc2pb_mwe_delay <= '0';
971
                noc2pb_we_delay  <= '0';
972
                noc2pb_din_reg <= (others => '0');
973
        elsif clk'event and clk='1' then
974
 
975
                -- doing some width conversion we's here.
976
                if noc2pb_we_b1='1' then
977
                        noc2pb_din_reg(7 downto 0) <= noc2pb_din_rotated(7 downto 0);
978
                end if;
979
                if noc2pb_we_b2='1' then
980
                        noc2pb_din_reg(15 downto 8) <= noc2pb_din_rotated(15 downto 8);
981
 
982
                end if;
983
                if noc2pb_we_b3='1' then
984
                        noc2pb_din_reg(23 downto 16) <= noc2pb_din_rotated(23 downto 16);
985
 
986
                end if;
987
                if noc2pb_we_b4='1' then
988
                        noc2pb_din_reg(31 downto 24) <= noc2pb_din_rotated(31 downto 24);
989
                        noc2pb_we_delay <= '1';
990
                end if;
991
 
992
                -- need to force a we to the pkt buffer when the EOP is seen from NoC
993
                if (noc2pb_we_b1='1' or noc2pb_we_b2='1' or noc2pb_we_b3='1' or noc2pb_we_b4='1') and noc_pkt_cntrl_in(NOCEM_PKTCNTRL_EOP_IX) = '1' then
994
 
995
                        noc2pb_mwe_delay <= '1';
996
                        noc2pb_we_delay  <= '1';
997
                elsif noc2pb_we_b4='1' then
998
                        noc2pb_we_delay  <= '1';
999
                        noc2pb_mwe_delay <= '0';
1000
                else
1001
                        noc2pb_mwe_delay <= '0';
1002
                        noc2pb_we_delay  <= '0';
1003
 
1004
                end if;
1005
 
1006
 
1007
 
1008
 
1009
 
1010
                noc2pb_state <= noc2pb_nextState;
1011
                case noc2pb_state is
1012
                        when init_st =>
1013
                                noc2pb_byte_counter <= (others => '0');
1014
                                noc2pb_din_reg <= (others => '0');
1015
                        when recving_word1_st =>
1016
                                noc2pb_byte_counter <= noc2pb_byte_counter + NOCEM_DW/8;
1017
                        when recving_word2_st =>
1018
                                noc2pb_byte_counter <= noc2pb_byte_counter + NOCEM_DW/8;
1019
                        when recving_word3_st =>
1020
                                noc2pb_byte_counter <= noc2pb_byte_counter + NOCEM_DW/8;
1021
                        when recving_word4_st =>
1022
                                noc2pb_byte_counter <= noc2pb_byte_counter + NOCEM_DW/8;
1023
                        when others => null;
1024
                end case;
1025
 
1026
 
1027
 
1028
                -------------------------------------------------------------------------------------
1029
                ---------------------------- FINDING NEXT VC WITH A PACKET --------------------------
1030
                -------------------------------------------------------------------------------------
1031
                l1: for I in NOCEM_NUM_VC-1 downto 0 loop
1032
 
1033
                        -- is the pkt rdy for reading?
1034
                        if noc2pb_eop_wr_sig(I) = '1' then
1035
                                noc2pb_pkt_rdy(I) <= '1';
1036
                        elsif noc2pb_finished_pkt(I) = '1' then
1037
                                noc2pb_pkt_rdy(I) <= '0';
1038
                        end if;
1039
 
1040
                        -- what is the next pkt to read from VCs?
1041
                        if noc2pb_pkt_rdy(I) = '1' and noc2pb_recv_idle = '1' then
1042
                                noc2pb_next_vc_with_pkt <= CONV_STD_LOGIC_VECTOR(2**I,NOCEM_NUM_VC);
1043
                                noc2pb_recv_idle <= '0';
1044
                        elsif noc2pb_finished_pkt /= 0 then
1045
                                noc2pb_recv_idle <= '1';
1046
                        end if;
1047
 
1048
                end loop;
1049
 
1050
                -- if no packets OR just finished a packet's handling, show that no packet is ready
1051
                if noc2pb_pkt_rdy = 0 or noc2pb_finished_pkt /= 0 then
1052
                        noc2pb_next_vc_with_pkt <= (others => '0');
1053
                end if;
1054
                -------------------------------------------------------------------------------------
1055
 
1056
        end if;
1057
 
1058
 
1059
end process;
1060
 
1061
noc2pb_uclkd : process (noc2pb_din_pad,noc2pb_next_vc_with_pkt,noc_arb_cntrl_in, noc_pkt_cntrl_in,noc2pb_mwe_delay, noc2pb_we_delay, noc2pb_din_reg, noc2pb_byte_counter, noc_datain, noc2pb_state, full_n2p)
1062
begin
1063
 
1064
 
1065
 
1066
        mwe_n2p <= noc2pb_mwe_delay;
1067
        we_n2p <= noc2pb_we_delay;
1068
 
1069
        -- a quick network to processor byte endian change
1070
        din_n2p(7 downto 0)   <= noc2pb_din_reg(31 downto 24);
1071
        din_n2p(15 downto 8)  <= noc2pb_din_reg(23 downto 16);
1072
        din_n2p(23 downto 16) <= noc2pb_din_reg(15 downto 8);
1073
        din_n2p(31 downto 24) <= noc2pb_din_reg(7 downto 0);
1074
 
1075
        mdin_n2p <= noc2pb_byte_counter & CONV_STD_LOGIC_VECTOR(0,NOCEM_AW);
1076
 
1077
        noc_datain_recvd <= '0';
1078
        noc_pkt_cntrl_in_recvd <= '0';
1079
        noc2pb_finished_pkt <= (others => '0');
1080
        arb_receiving_word <= (others => '0');
1081
        noc2pb_eop_wr_sig <= noc_arb_cntrl_in(NOCEM_ARB_CNTRL_VC_EOP_WR_HIX downto NOCEM_ARB_CNTRL_VC_EOP_WR_LIX);
1082
 
1083
        -- setting up the padded register for width conversion
1084
        noc2pb_din_pad <= (others => '0');
1085
        noc2pb_din_pad(NOCEM_DW-1 downto 0) <= noc_datain;
1086
        noc2pb_din_rotated <= (others => '0');
1087
 
1088
        noc2pb_we_b1 <= '0';
1089
        noc2pb_we_b2 <= '0';
1090
        noc2pb_we_b3 <= '0';
1091
        noc2pb_we_b4 <= '0';
1092
 
1093
 
1094
 
1095
 
1096
                case noc2pb_state is
1097
                        when init_st =>
1098
                                if noc2pb_next_vc_with_pkt /= 0 and full_n2p = '0' then
1099
                                        noc2pb_nextState <= recving_word1_st;
1100
                                else
1101
                                        noc2pb_nextState <= init_st;
1102
                                end if;
1103
 
1104
                        when recving_word1_st =>
1105
 
1106
 
1107
 
1108
                                arb_receiving_word(NOCEM_ARB_CNTRL_VC_MUX_RD_HIX downto NOCEM_ARB_CNTRL_VC_MUX_RD_LIX) <= noc2pb_next_vc_with_pkt;
1109
                                noc_datain_recvd <= '1';
1110
                                noc_pkt_cntrl_in_recvd <= '1';
1111
                                if noc_pkt_cntrl_in(NOCEM_PKTCNTRL_EOP_IX)      = '1' then
1112
                                        noc2pb_finished_pkt <= noc2pb_next_vc_with_pkt;
1113
                                end if;
1114
 
1115
 
1116
 
1117
                                -- setup the width conversion correctly....
1118
                                noc2pb_din_rotated(NOCEM_DW-1 downto 0) <= noc2pb_din_pad(NOCEM_DW-1 downto 0);
1119
                                if NOCEM_DW = 32 then
1120
                                        noc2pb_we_b1 <= '1';
1121
                                        noc2pb_we_b2 <= '1';
1122
                                        noc2pb_we_b3 <= '1';
1123
                                        noc2pb_we_b4 <= '1';
1124
 
1125
                                        if noc_pkt_cntrl_in(NOCEM_PKTCNTRL_EOP_IX) = '1' then
1126
                                                noc2pb_nextState <= init_st;
1127
                                        else
1128
                                                noc2pb_nextState <= recving_word1_st;
1129
                                        end if;
1130
                                elsif NOCEM_DW = 16 then
1131
                                        noc2pb_we_b1 <= '1';
1132
                                        noc2pb_we_b2 <= '1';
1133
 
1134
                                        if noc_pkt_cntrl_in(NOCEM_PKTCNTRL_EOP_IX) = '1' then
1135
                                                noc2pb_nextState <= init_st;
1136
                                        else
1137
                                                noc2pb_nextState <= recving_word2_st;
1138
                                        end if;
1139
 
1140
                                elsif NOCEM_DW = 8 then
1141
                                        noc2pb_we_b1 <= '1';
1142
 
1143
                                        if noc_pkt_cntrl_in(NOCEM_PKTCNTRL_EOP_IX) = '1' then
1144
                                                noc2pb_nextState <= init_st;
1145
                                        else
1146
                                                noc2pb_nextState <= recving_word2_st;
1147
                                        end if;
1148
 
1149
 
1150
                                end if;
1151
 
1152
 
1153
                        when recving_word2_st =>
1154
 
1155
                                arb_receiving_word(NOCEM_ARB_CNTRL_VC_MUX_RD_HIX downto NOCEM_ARB_CNTRL_VC_MUX_RD_LIX) <= noc2pb_next_vc_with_pkt;
1156
                                noc_datain_recvd <= '1';
1157
                                noc_pkt_cntrl_in_recvd <= '1';
1158
                                if noc_pkt_cntrl_in(NOCEM_PKTCNTRL_EOP_IX)      = '1' then
1159
                                        noc2pb_finished_pkt <= noc2pb_next_vc_with_pkt;
1160
                                end if;
1161
 
1162
 
1163
 
1164
 
1165
 
1166
                                -- setup the width conversion correctly....
1167
                                if NOCEM_DW = 16 then
1168
                                        noc2pb_din_rotated(31 downto 16) <= noc2pb_din_pad(15 downto 0);
1169
                                        noc2pb_we_b3 <= '1';
1170
                                        noc2pb_we_b4 <= '1';
1171
 
1172
                                        if noc_pkt_cntrl_in(NOCEM_PKTCNTRL_EOP_IX) = '1' then
1173
                                                noc2pb_nextState <= init_st;
1174
                                        else
1175
                                                noc2pb_nextState <= recving_word1_st;
1176
                                        end if;
1177
 
1178
                                elsif NOCEM_DW = 8 then
1179
                                        noc2pb_din_rotated(15 downto 8) <= noc2pb_din_pad(7 downto 0);
1180
                                        noc2pb_we_b2 <= '1';
1181
 
1182
                                        if noc_pkt_cntrl_in(NOCEM_PKTCNTRL_EOP_IX) = '1' then
1183
                                                noc2pb_nextState <= init_st;
1184
                                        else
1185
                                                noc2pb_nextState <= recving_word3_st;
1186
                                        end if;
1187
 
1188
                                end if;
1189
 
1190
 
1191
 
1192
                        when recving_word3_st =>
1193
 
1194
 
1195
                                        arb_receiving_word(NOCEM_ARB_CNTRL_VC_MUX_RD_HIX downto NOCEM_ARB_CNTRL_VC_MUX_RD_LIX) <= noc2pb_next_vc_with_pkt;
1196
                                        noc_datain_recvd <= '1';
1197
                                        noc_pkt_cntrl_in_recvd <= '1';
1198
                                        if noc_pkt_cntrl_in(NOCEM_PKTCNTRL_EOP_IX)      = '1' then
1199
                                                noc2pb_finished_pkt <= noc2pb_next_vc_with_pkt;
1200
                                        end if;
1201
 
1202
                                        -- setup the width conversion correctly....
1203
                                        noc2pb_din_rotated(23 downto 16) <= noc2pb_din_pad(7 downto 0);
1204
                                        noc2pb_we_b3 <= '1';
1205
 
1206
                                        if noc_pkt_cntrl_in(NOCEM_PKTCNTRL_EOP_IX) = '1' then
1207
                                                noc2pb_nextState <= init_st;
1208
                                        else
1209
                                                noc2pb_nextState <= recving_word4_st;
1210
                                        end if;
1211
 
1212
                        when recving_word4_st =>
1213
 
1214
                                        arb_receiving_word(NOCEM_ARB_CNTRL_VC_MUX_RD_HIX downto NOCEM_ARB_CNTRL_VC_MUX_RD_LIX) <= noc2pb_next_vc_with_pkt;
1215
                                        noc_datain_recvd <= '1';
1216
                                        noc_pkt_cntrl_in_recvd <= '1';
1217
                                        if noc_pkt_cntrl_in(NOCEM_PKTCNTRL_EOP_IX)      = '1' then
1218
                                                noc2pb_finished_pkt <= noc2pb_next_vc_with_pkt;
1219
                                        end if;
1220
 
1221
                                        -- setup the width conversion correctly....
1222
                                        noc2pb_din_rotated(31 downto 24) <= noc2pb_din_pad(7 downto 0);
1223
                                        noc2pb_we_b4 <= '1';
1224
 
1225
                                        if noc_pkt_cntrl_in(NOCEM_PKTCNTRL_EOP_IX) = '1' then
1226
                                                noc2pb_nextState <= init_st;
1227
                                        else
1228
                                                noc2pb_nextState <= recving_word1_st;
1229
                                        end if;
1230
 
1231
                        when others => null;
1232
                end case;
1233
 
1234
 
1235
 
1236
 
1237
 
1238
 
1239
 
1240
 
1241
 
1242
end process;
1243
 
1244
 
1245
---------------------------------------------------------------------
1246
------------  PKT BUFFER TO NOCEM PROCESSES     ---------------------
1247
---------------------------------------------------------------------
1248
 
1249
 
1250
g_dw32: if NOCEM_DW = 32 generate
1251
 
1252
        pb2noc_word1 <= dout_p2n;
1253
        pb2noc_word2 <= (others => '0');
1254
        pb2noc_word3 <= (others => '0');
1255
        pb2noc_word4 <= (others => '0');
1256
 
1257
end generate;
1258
 
1259
g_dw16: if NOCEM_DW = 16 generate
1260
 
1261
        pb2noc_word1(31 downto 16) <= (others => '0');
1262
        pb2noc_word2(31 downto 16) <= (others => '0');
1263
        pb2noc_word1(15 downto 0) <= dout_p2n(31 downto 16);
1264
        pb2noc_word2(15 downto 0) <= dout_p2n(15 downto 0);
1265
        pb2noc_word3(15 downto 0) <= (others => '0');
1266
        pb2noc_word4(15 downto 0) <= (others => '0');
1267
 
1268
end generate;
1269
 
1270
g_dw8: if NOCEM_DW = 8 generate
1271
 
1272
        pb2noc_word1(31 downto 8) <= (others => '0');
1273
        pb2noc_word2(31 downto 8) <= (others => '0');
1274
        pb2noc_word3(31 downto 8) <= (others => '0');
1275
        pb2noc_word4(31 downto 8) <= (others => '0');
1276
 
1277
        pb2noc_word1(7 downto 0) <= dout_p2n(31 downto 24);
1278
        pb2noc_word2(7 downto 0) <= dout_p2n(23 downto 16);
1279
        pb2noc_word3(7 downto 0) <= dout_p2n(15 downto 8);
1280
        pb2noc_word4(7 downto 0) <= dout_p2n(7 downto 0);
1281
 
1282
end generate;
1283
 
1284
 
1285
 
1286
 
1287
gen_outgoing_vc_status_clkd : process (clk,rst)
1288
begin
1289
 
1290
 
1291
        if rst='1' then
1292
                outgoing_vc_state <= (others => '0');
1293
                outgoing_free_this_vc <= (others => '0');
1294
                outgoing_next_free_vc <= (others => '0');
1295
        elsif clk'event and clk='1' then
1296
 
1297
 
1298
                l2: for I in NOCEM_NUM_VC-1 downto 0 loop
1299
                        if outgoing_vc_state(I) = '0' then
1300
                                outgoing_next_free_vc <= CONV_STD_LOGIC_VECTOR(2**I,NOCEM_NUM_VC);
1301
                        end if;
1302
                end loop;
1303
 
1304
                if outgoing_vc_state = allones_vcwidth then
1305
                        outgoing_next_free_vc <= (others => '0');
1306
                end if;
1307
 
1308
 
1309
            outgoing_free_this_vc <= noc_arb_cntrl_in(NOCEM_ARB_CNTRL_VC_EOP_RD_HIX downto NOCEM_ARB_CNTRL_VC_EOP_RD_LIX);
1310
 
1311
                 -- 0: free, 1: allocated --
1312
                 l1: for I in NOCEM_NUM_VC-1 downto 0 loop
1313
                        if outgoing_vc_state(I) = '0' and outgoing_next_free_vc(I) = '1' and pb2noc_vc_alloc = '1' then -- free going to allocated
1314
                                outgoing_vc_state(I) <= '1';
1315
                        elsif outgoing_vc_state(I) = '1' and outgoing_free_this_vc(I) = '1' then -- allocated going to free
1316
                                outgoing_vc_state(I) <= '0';
1317
                        end if;
1318
                 end loop;
1319
 
1320
        end if;
1321
end process;
1322
 
1323
 
1324
 
1325
-- see a packet is ready in pkt_buffer
1326
-- then attempt to get a VC
1327
-- then send the packet correctly
1328
--      breaking up the 4B buffer word into appropriate chunks
1329
pb2noc_clkd : process (clk,rst)
1330
begin
1331
        if rst = '1' then
1332
                 pb2noc_state <= init_st;
1333
                 pb2noc_byte_counter <= CONV_STD_LOGIC_VECTOR(NOCEM_DW/8,8);
1334
                 vc_mux_wr_reg <= (others => '0');
1335
        elsif clk'event and clk='1' then
1336
                pb2noc_state <= pb2noc_nextState;
1337
        case pb2noc_state is
1338
        when init_st =>
1339
                           pb2noc_byte_counter <= CONV_STD_LOGIC_VECTOR(NOCEM_DW/8,8);
1340
                        when getting_vc_st =>
1341
                                vc_mux_wr_reg <= outgoing_next_free_vc;
1342
                        when sending_word1_st =>
1343
                                pb2noc_byte_counter <= pb2noc_byte_counter + NOCEM_DW/8;
1344
                        when sending_word2_st =>
1345
                                pb2noc_byte_counter <= pb2noc_byte_counter + NOCEM_DW/8;
1346
                        when sending_word3_st =>
1347
                                pb2noc_byte_counter <= pb2noc_byte_counter + NOCEM_DW/8;
1348
                        when sending_word4_st =>
1349
                                pb2noc_byte_counter <= pb2noc_byte_counter + NOCEM_DW/8;
1350
                        when others => null;
1351
                end case;
1352
        end if;
1353
 
1354
end process;
1355
 
1356
pb2noc_uclkd : process (empty_p2n,pb2noc_state,mdout_p2n, outgoing_next_free_vc, pb2noc_word1, vc_mux_wr_reg, pb2noc_byte_counter, pb2noc_word2, pb2noc_word3, pb2noc_word4)
1357
begin
1358
 
1359
                pb2noc_amI_os <= '1';
1360
 
1361
                noc_pkt_cntrl_out <= (others => '0');
1362
                noc_pkt_cntrl_out(NOCEM_PKTCNTRL_OS_PKT_IX) <= pb2noc_amI_os;
1363
 
1364
 
1365
                noc_dataout_valid                       <= '0';
1366
                noc_dataout              <= (others => '0');
1367
                noc_pkt_cntrl_out_valid  <= '0';
1368
                noc_arb_req        <= '0';
1369
 
1370
                allones_vcwidth <= (others => '1');
1371
                arb_sending_word <= (others => '0');
1372
                pb2noc_pkt_dest_addr <= mdout_p2n(NOCEM_AW-1 downto 0);
1373
                pb2noc_pkt_len                  <= mdout_p2n(NOCEM_AW+7 downto NOCEM_AW);
1374
           pb2noc_vc_alloc <= '0';
1375
                re_p2n <= '0';
1376
                mre_p2n <= '0';
1377
 
1378
        case pb2noc_state is
1379
        when init_st =>
1380
                                if empty_p2n='0' then
1381
                                        pb2noc_nextstate <= getting_vc_st;
1382
                                else
1383
                                        pb2noc_nextstate <= init_st;
1384
                                end if;
1385
 
1386
 
1387
                        when getting_vc_st =>
1388
                                if outgoing_next_free_vc /= 0 then
1389
                                        pb2noc_vc_alloc <= '1';
1390
                                        pb2noc_nextState <= sending_word1_st;
1391
                                else
1392
                                        pb2noc_nextState <= getting_vc_st;
1393
                                end if;
1394
 
1395
                        when sending_word1_st =>
1396
                                noc_dataout <= pb2noc_word1(NOCEM_DW-1 downto 0);
1397
                                noc_dataout_valid <= '1';
1398
 
1399
                                noc_pkt_cntrl_out(NOCEM_PKTCNTRL_DEST_ADDR_HIX downto NOCEM_PKTCNTRL_DEST_ADDR_LIX) <= pb2noc_pkt_dest_addr;
1400
                                noc_pkt_cntrl_out_valid <= '1';
1401
 
1402
                                noc_arb_req <= '1';
1403
                                arb_sending_word(NOCEM_ARB_CNTRL_VC_MUX_WR_HIX downto NOCEM_ARB_CNTRL_VC_MUX_WR_LIX) <= vc_mux_wr_reg;
1404
 
1405
                                -- do correct SOP/EOP signalling                                
1406
                           if pb2noc_byte_counter = CONV_STD_LOGIC_VECTOR(NOCEM_DW/8,8) then
1407
                                        noc_pkt_cntrl_out(NOCEM_PKTCNTRL_SOP_IX)        <= '1';
1408
                                end if;
1409
                                if pb2noc_byte_counter >= pb2noc_pkt_len then
1410
                                        noc_pkt_cntrl_out(NOCEM_PKTCNTRL_EOP_IX)        <= '1';
1411
                                end if;
1412
 
1413
 
1414
                                -- state change logic (depends on noc datawidth)
1415
                                if pb2noc_byte_counter = pb2noc_pkt_len then
1416
                                        re_p2n <= '1';
1417
                                        mre_p2n <= '1';
1418
                                        pb2noc_nextState <= init_st;
1419
                                elsif NOCEM_DW = 32 then
1420
                                        pb2noc_nextState <= sending_word1_st;
1421
                                        re_p2n <= '1';
1422
                                else
1423
                                        pb2noc_nextState <= sending_word2_st;
1424
                                end if;
1425
 
1426
 
1427
 
1428
                        when sending_word2_st =>
1429
                                noc_dataout <= pb2noc_word2(NOCEM_DW-1 downto 0);
1430
                                noc_dataout_valid <= '1';
1431
 
1432
 
1433
                                noc_pkt_cntrl_out(NOCEM_PKTCNTRL_DEST_ADDR_HIX downto NOCEM_PKTCNTRL_DEST_ADDR_LIX) <= pb2noc_pkt_dest_addr;
1434
                                noc_pkt_cntrl_out_valid <= '1';
1435
 
1436
                                noc_arb_req <= '1';
1437
                                arb_sending_word(NOCEM_ARB_CNTRL_VC_MUX_WR_HIX downto NOCEM_ARB_CNTRL_VC_MUX_WR_LIX) <= vc_mux_wr_reg;
1438
 
1439
                                -- do correct SOP/EOP signalling                                
1440
--                         if pb2noc_byte_counter = 0 then
1441
--                                      noc_pkt_cntrl_out(NOCEM_PKTCNTRL_SOP_IX)        <= '1'; 
1442
--                              end if;
1443
                                if pb2noc_byte_counter >= pb2noc_pkt_len then
1444
                                        noc_pkt_cntrl_out(NOCEM_PKTCNTRL_EOP_IX)        <= '1';
1445
                                end if;
1446
 
1447
 
1448
                                -- state change logic (depends on noc datawidth)
1449
                                if pb2noc_byte_counter = pb2noc_pkt_len then
1450
                                        re_p2n <= '1';
1451
                                        mre_p2n <= '1';
1452
                                        pb2noc_nextState <= init_st;
1453
                                elsif NOCEM_DW = 16 then
1454
                                        pb2noc_nextState <= sending_word1_st;
1455
                                        re_p2n <= '1';
1456
                                else
1457
                                        pb2noc_nextState <= sending_word3_st;
1458
                                end if;
1459
 
1460
 
1461
 
1462
 
1463
 
1464
                        when sending_word3_st =>
1465
                                noc_dataout <= pb2noc_word3(NOCEM_DW-1 downto 0);
1466
                                noc_dataout_valid <= '1';
1467
 
1468
                                noc_pkt_cntrl_out(NOCEM_PKTCNTRL_DEST_ADDR_HIX downto NOCEM_PKTCNTRL_DEST_ADDR_LIX) <= pb2noc_pkt_dest_addr;
1469
                                noc_pkt_cntrl_out_valid <= '1';
1470
 
1471
                                noc_arb_req <= '1';
1472
                                arb_sending_word(NOCEM_ARB_CNTRL_VC_MUX_WR_HIX downto NOCEM_ARB_CNTRL_VC_MUX_WR_LIX) <= vc_mux_wr_reg;
1473
 
1474
                                -- do correct SOP/EOP signalling                                
1475
--                         if pb2noc_byte_counter = 0 then
1476
--                                      noc_pkt_cntrl_out(NOCEM_PKTCNTRL_SOP_IX)        <= '1'; 
1477
--                              end if;
1478
                                if pb2noc_byte_counter >= pb2noc_pkt_len then
1479
                                        noc_pkt_cntrl_out(NOCEM_PKTCNTRL_EOP_IX)        <= '1';
1480
                                end if;
1481
 
1482
 
1483
                                -- state change logic (depends on noc datawidth)
1484
                                if pb2noc_byte_counter = pb2noc_pkt_len then
1485
                                        re_p2n <= '1';
1486
                                        mre_p2n <= '1';
1487
                                        pb2noc_nextState <= init_st;
1488
                                else
1489
                                        pb2noc_nextState <= sending_word4_st;
1490
                                end if;
1491
 
1492
 
1493
                        when sending_word4_st =>
1494
                                noc_dataout <= pb2noc_word4(NOCEM_DW-1 downto 0);
1495
                                noc_dataout_valid <= '1';
1496
 
1497
 
1498
                                noc_pkt_cntrl_out(NOCEM_PKTCNTRL_DEST_ADDR_HIX downto NOCEM_PKTCNTRL_DEST_ADDR_LIX) <= pb2noc_pkt_dest_addr;
1499
                                noc_pkt_cntrl_out_valid <= '1';
1500
 
1501
                                noc_arb_req <= '1';
1502
                                arb_sending_word(NOCEM_ARB_CNTRL_VC_MUX_WR_HIX downto NOCEM_ARB_CNTRL_VC_MUX_WR_LIX) <= vc_mux_wr_reg;
1503
 
1504
                                -- do correct SOP/EOP signalling                                
1505
--                         if pb2noc_byte_counter = 0 then
1506
--                                      noc_pkt_cntrl_out(NOCEM_PKTCNTRL_SOP_IX)        <= '1'; 
1507
--                              end if;
1508
                                if pb2noc_byte_counter >= pb2noc_pkt_len then
1509
                                        noc_pkt_cntrl_out(NOCEM_PKTCNTRL_EOP_IX)        <= '1';
1510
                                end if;
1511
 
1512
 
1513
                                -- state change logic (depends on noc datawidth)
1514
                                if pb2noc_byte_counter = pb2noc_pkt_len then
1515
                                        re_p2n <= '1';
1516
                                        mre_p2n <= '1';
1517
                                        pb2noc_nextState <= init_st;
1518
                                else
1519
                                        re_p2n <= '1';
1520
                                        pb2noc_nextState <= sending_word1_st;
1521
                                end if;
1522
 
1523
 
1524
                        when others => null;
1525
                end case;
1526
 
1527
end process;
1528
 
1529
 
1530
 
1531
 
1532
 
1533
 
1534
--------------------------------------------------------------------------
1535
--------------------------------------------------------------------------
1536
--------------------------------------------------------------------------
1537
 
1538
 
1539
 
1540
 
1541
 
1542
--------------------------------------------------------------------------------
1543
------------          THE PACKET BUFFER INSTANTIATIONS           ---------------
1544
--------------------------------------------------------------------------------
1545
 
1546
 
1547
---------------------------------------------------------
1548
--metadata(NOCEM_AW-1 downto 0)        : dest_addr              ---                             
1549
--metadata(NOCEM_AW+7 downto NOCEM_AW) : pkt_len                ---
1550
---------------------------------------------------------
1551
 
1552
 
1553
        pb_noc2proc : packetbuffer2
1554
 
1555
   generic map
1556
   (
1557
         METADATA_WIDTH => METADATA_WIDTH,
1558
         METADATA_LENGTH => METADATA_LENGTH
1559
   )
1560
   PORT MAP(
1561
                din => din_n2p,
1562
                rd_en => re_n2p,
1563
                wr_en => we_n2p,
1564
                dout => dout_n2p,
1565
                empty => empty_n2p,
1566
                full => full_n2p,
1567
                pkt_metadata_din => mdin_n2p,
1568
                pkt_metadata_re => mre_n2p,
1569
                pkt_metadata_we => mwe_n2p,
1570
                pkt_metadata_dout => mdout_n2p,
1571
                clk => clk,
1572
                rst => rst
1573
        );
1574
 
1575
 
1576
   pb_proc2noc: packetbuffer2
1577
   generic map
1578
   (
1579
         METADATA_WIDTH => METADATA_WIDTH,
1580
         METADATA_LENGTH =>  METADATA_LENGTH
1581
   )
1582
   PORT MAP(
1583
                din => din_p2n,
1584
                rd_en => re_p2n,
1585
                wr_en => we_p2n,
1586
                dout => dout_p2n,
1587
                empty => empty_p2n,
1588
                full => full_p2n,
1589
                pkt_metadata_din => mdin_p2n,
1590
                pkt_metadata_re => mre_p2n,
1591
                pkt_metadata_we => mwe_p2n,
1592
                pkt_metadata_dout => mdout_p2n,
1593
                clk => clk,
1594
                rst => rst
1595
        );
1596
 
1597
 
1598
 
1599
 
1600
 
1601
 
1602
end Behavioral;

powered by: WebSVN 2.1.0

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