OpenCores
URL https://opencores.org/ocsvn/an-fpga-implementation-of-low-latency-noc-based-mpsoc/an-fpga-implementation-of-low-latency-noc-based-mpsoc/trunk

Subversion Repositories an-fpga-implementation-of-low-latency-noc-based-mpsoc

[/] [an-fpga-implementation-of-low-latency-noc-based-mpsoc/] [trunk/] [mpsoc/] [perl_gui/] [lib/] [ip/] [NoC/] [ni_master.IP] - Blame information for rev 48

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

Line No. Rev Author Line
1 34 alirezamon
#######################################################################
2
##      File: ni_master.IP
3
##
4 48 alirezamon
##      Copyright (C) 2014-2019  Alireza Monemi
5 34 alirezamon
##
6 48 alirezamon
##      This file is part of ProNoC 1.9.1
7 34 alirezamon
##
8
##      WARNING: THIS IS AN AUTO-GENERATED FILE. CHANGES TO IT
9 48 alirezamon
##      MAY CAUSE UNEXPECTED BEHAVIOR.
10 34 alirezamon
################################################################################
11
 
12 38 alirezamon
$ipgen = bless( {
13 48 alirezamon
                  'ports_order' => [
14
                                     'reset',
15
                                     'clk',
16
                                     'current_e_addr',
17
                                     'current_r_addr',
18
                                     'chan_out',
19
                                     'chan_in',
20
                                     's_dat_i',
21
                                     's_sel_i',
22
                                     's_addr_i',
23
                                     's_cti_i',
24
                                     's_stb_i',
25
                                     's_cyc_i',
26
                                     's_we_i',
27
                                     's_dat_o',
28
                                     's_ack_o',
29
                                     'm_send_sel_o',
30
                                     'm_send_addr_o',
31
                                     'm_send_cti_o',
32
                                     'm_send_stb_o',
33
                                     'm_send_cyc_o',
34
                                     'm_send_we_o',
35
                                     'm_send_dat_i',
36
                                     'm_send_ack_i',
37
                                     'm_receive_sel_o',
38
                                     'm_receive_dat_o',
39
                                     'm_receive_addr_o',
40
                                     'm_receive_cti_o',
41
                                     'm_receive_stb_o',
42
                                     'm_receive_cyc_o',
43
                                     'm_receive_we_o',
44
                                     'm_receive_ack_i',
45
                                     'irq'
46
                                   ],
47
                  'parameters' => {
48
                                    'CRC_EN' => {
49
                                                  'redefine_param' => 1,
50
                                                  'default' => '"NO"',
51
                                                  'global_param' => 'Localparam',
52
                                                  'info' => 'The parameter can be selected as "YES" or "NO".
53
If CRC is enabled, then two CRC32 generator modules will be added to the NI. One CRC generator for calculating CRC of sending packets and another for receiving packets.   The CRC32 value of each packet is send via tail flit and at destination NI, is will be compared with received packet generated CRC32. The matching results can be used for error-detection and can be read via NI slave interface. ',
54
                                                  'content' => '"YES","NO"',
55
                                                  'type' => 'Combo-box'
56
                                                },
57
                                    'SELw' => {
58
                                                'info' => 'Parameter',
59
                                                'content' => '',
60
                                                'global_param' => 'Localparam',
61
                                                'redefine_param' => 1,
62
                                                'default' => '4',
63
                                                'type' => 'Fixed'
64
                                              },
65
                                    'MAX_TRANSACTION_WIDTH' => {
66
                                                                 'type' => 'Spin-button',
67
                                                                 'global_param' => 'Localparam',
68
                                                                 'redefine_param' => 1,
69
                                                                 'default' => '13',
70
                                                                 'info' => 'maximum packet size width  in words.
71
The maximum data that can be sent via one packet will be 2 power of MAX_DMA_TRANSACTION_WIDTH in words.',
72
                                                                 'content' => '4,32,1'
73
                                                               },
74
                                    'EAw' => {
75
                                               'type' => 'Fixed',
76
                                               'default' => '16',
77
                                               'redefine_param' => 0,
78
                                               'global_param' => 'Parameter',
79
                                               'content' => '',
80
                                               'info' => undef
81
                                             },
82
                                    'S_Aw' => {
83
                                                'type' => 'Fixed',
84
                                                'content' => '',
85
                                                'info' => 'Parameter',
86
                                                'default' => '8',
87
                                                'redefine_param' => 1,
88
                                                'global_param' => 'Localparam'
89
                                              },
90
                                    'TAGw' => {
91
                                                'type' => 'Fixed',
92
                                                'global_param' => 'Localparam',
93
                                                'redefine_param' => 1,
94
                                                'default' => '3',
95
                                                'info' => 'Parameter',
96
                                                'content' => ''
97
                                              },
98
                                    'Dw' => {
99
                                              'info' => 'wishbone_bus data width in bits.',
100
                                              'content' => '32,256,8',
101
                                              'global_param' => 'Localparam',
102
                                              'default' => '32',
103
                                              'redefine_param' => 1,
104
                                              'type' => 'Spin-button'
105
                                            },
106
                                    'M_Aw' => {
107
                                                'type' => 'Fixed',
108
                                                'info' => 'Parameter',
109
                                                'content' => 'Dw',
110
                                                'redefine_param' => 1,
111
                                                'default' => '32',
112
                                                'global_param' => 'Localparam'
113
                                              },
114
                                    'MAX_BURST_SIZE' => {
115
                                                          'default' => '16',
116
                                                          'redefine_param' => 1,
117
                                                          'global_param' => 'Localparam',
118
                                                          'info' => 'Maximum burst size in words.
119
The NI releases the wishbone bus  each time one burst is completed or when the VC\'s internal FIFO becomes full.  The bus will be released for one clock cycle. Then in case, there are other active VCs, another active VC will get access to the bus using round robin arbiter.  This process will be continued until all of the desired data is transferred. ',
120
                                                          'content' => '2,4,8,16,32,64,128,256,512,1024,2048',
121
                                                          'type' => 'Combo-box'
122
                                                        },
123
                                    'RAw' => {
124
                                               'type' => 'Fixed',
125
                                               'redefine_param' => 0,
126
                                               'default' => '16',
127
                                               'global_param' => 'Parameter',
128
                                               'content' => '',
129
                                               'info' => undef
130
                                             },
131
                                    'HDATA_PRECAPw' => {
132
                                                         'type' => 'Spin-button',
133
                                                         'info' => ' The headr Data pre capture width. It Will be enabled when it is larger than zero. The header data can optionally carry a short width Data. This data can be pre-captured (completely/partially) by the NI before saving the packet in a memory buffer. This can give some hints to the software regarding the incoming packet such as its type, or source port so the software can store the packet in its appropriate buffer.',
134
                                                         'content' => '0,8,1',
135
                                                         'global_param' => 'Localparam',
136
                                                         'default' => '0',
137
                                                         'redefine_param' => 1
138
                                                       }
139
                                  },
140
                  'plugs' => {
141
                               'reset' => {
142
                                            'type' => 'num',
143
                                            'value' => 1,
144
                                            '0' => {
145
                                                     'name' => 'reset'
146
                                                   },
147
                                            'reset' => {}
148
                                          },
149
                               'wb_slave' => {
150
                                               'type' => 'num',
151
                                               '0' => {
152
                                                        'name' => 'wb_slave',
153
                                                        'addr' => '0xb800_0000  0xbfff_ffff             custom devices',
154
                                                        'width' => 10
155
                                                      },
156
                                               'wb_slave' => {},
157
                                               'value' => 1
158
                                             },
159
                               'wb_master' => {
160
                                                '1' => {
161
                                                         'name' => 'wb_receive'
162
                                                       },
163
                                                'wb_master' => {},
164
                                                'type' => 'num',
165
                                                '0' => {
166
                                                         'name' => 'wb_send'
167
                                                       },
168
                                                'value' => 2
169
                                              },
170
                               'interrupt_peripheral' => {
171
                                                           'value' => 1,
172
                                                           '0' => {
173
                                                                    'name' => 'interrupt'
174
                                                                  },
175
                                                           'type' => 'num',
176
                                                           'interrupt_peripheral' => {}
177
                                                         },
178
                               'clk' => {
179
                                          'clk' => {},
180
                                          'type' => 'num',
181
                                          '0' => {
182
                                                   'name' => 'clk'
183
                                                 },
184
                                          'value' => 1
185
                                        }
186
                             },
187 42 alirezamon
                  'ports' => {
188 48 alirezamon
                               'm_send_stb_o' => {
189
                                                   'intfc_port' => 'stb_o',
190
                                                   'range' => '',
191
                                                   'type' => 'output',
192 42 alirezamon
                                                   'intfc_name' => 'plug:wb_master[0]'
193
                                                 },
194 48 alirezamon
                               'm_send_cti_o' => {
195
                                                   'range' => 'TAGw-1          :   0',
196
                                                   'intfc_port' => 'cti_o',
197
                                                   'intfc_name' => 'plug:wb_master[0]',
198
                                                   'type' => 'output'
199
                                                 },
200
                               'chan_in' => {
201
                                              'range' => 'smartflit_chanel_t',
202
                                              'intfc_port' => 'chan_in',
203
                                              'type' => 'input',
204
                                              'intfc_name' => 'socket:ni[0]'
205
                                            },
206 43 alirezamon
                               'm_receive_sel_o' => {
207 42 alirezamon
                                                      'type' => 'output',
208 48 alirezamon
                                                      'intfc_name' => 'plug:wb_master[1]',
209 43 alirezamon
                                                      'range' => 'SELw-1          :   0',
210
                                                      'intfc_port' => 'sel_o'
211 42 alirezamon
                                                    },
212 48 alirezamon
                               'm_send_sel_o' => {
213
                                                   'intfc_port' => 'sel_o',
214
                                                   'range' => 'SELw-1          :   0',
215 43 alirezamon
                                                   'type' => 'output',
216 42 alirezamon
                                                   'intfc_name' => 'plug:wb_master[0]'
217
                                                 },
218 48 alirezamon
                               'current_e_addr' => {
219
                                                     'intfc_name' => 'socket:ni[0]',
220
                                                     'type' => 'input',
221
                                                     'intfc_port' => 'current_e_addr',
222
                                                     'range' => 'EAw-1   :   0'
223
                                                   },
224
                               'chan_out' => {
225
                                               'type' => 'output',
226
                                               'intfc_name' => 'socket:ni[0]',
227
                                               'intfc_port' => 'chan_out',
228
                                               'range' => 'smartflit_chanel_t'
229
                                             },
230
                               'm_send_we_o' => {
231
                                                  'intfc_name' => 'plug:wb_master[0]',
232
                                                  'type' => 'output',
233
                                                  'intfc_port' => 'we_o',
234
                                                  'range' => ''
235
                                                },
236 43 alirezamon
                               's_cyc_i' => {
237
                                              'intfc_name' => 'plug:wb_slave[0]',
238
                                              'type' => 'input',
239 48 alirezamon
                                              'range' => '',
240
                                              'intfc_port' => 'cyc_i'
241 43 alirezamon
                                            },
242 48 alirezamon
                               'irq' => {
243
                                          'intfc_name' => 'plug:interrupt_peripheral[0]',
244
                                          'type' => 'output',
245
                                          'range' => '',
246
                                          'intfc_port' => 'int_o'
247
                                        },
248 43 alirezamon
                               'm_receive_ack_i' => {
249 48 alirezamon
                                                      'intfc_port' => 'ack_i',
250
                                                      'range' => '',
251 43 alirezamon
                                                      'intfc_name' => 'plug:wb_master[1]',
252 48 alirezamon
                                                      'type' => 'input'
253 43 alirezamon
                                                    },
254 42 alirezamon
                               'reset' => {
255
                                            'range' => '',
256
                                            'intfc_port' => 'reset_i',
257 48 alirezamon
                                            'intfc_name' => 'plug:reset[0]',
258
                                            'type' => 'input'
259 42 alirezamon
                                          },
260 48 alirezamon
                               'clk' => {
261
                                          'intfc_name' => 'plug:clk[0]',
262
                                          'type' => 'input',
263
                                          'intfc_port' => 'clk_i',
264
                                          'range' => ''
265
                                        },
266
                               'm_receive_addr_o' => {
267
                                                       'intfc_name' => 'plug:wb_master[1]',
268
                                                       'type' => 'output',
269
                                                       'intfc_port' => 'adr_o',
270
                                                       'range' => 'M_Aw-1          :   0'
271
                                                     },
272
                               's_dat_o' => {
273
                                              'type' => 'output',
274 43 alirezamon
                                              'intfc_name' => 'plug:wb_slave[0]',
275
                                              'range' => 'Dw-1       :   0',
276 48 alirezamon
                                              'intfc_port' => 'dat_o'
277 43 alirezamon
                                            },
278 48 alirezamon
                               'm_receive_cyc_o' => {
279 43 alirezamon
                                                      'type' => 'output',
280 48 alirezamon
                                                      'intfc_name' => 'plug:wb_master[1]',
281
                                                      'range' => '',
282
                                                      'intfc_port' => 'cyc_o'
283 43 alirezamon
                                                    },
284 42 alirezamon
                               'm_receive_we_o' => {
285
                                                     'range' => '',
286 48 alirezamon
                                                     'intfc_port' => 'we_o',
287 43 alirezamon
                                                     'intfc_name' => 'plug:wb_master[1]',
288 48 alirezamon
                                                     'type' => 'output'
289 42 alirezamon
                                                   },
290 43 alirezamon
                               'm_receive_dat_o' => {
291
                                                      'type' => 'output',
292 48 alirezamon
                                                      'intfc_name' => 'plug:wb_master[1]',
293 43 alirezamon
                                                      'intfc_port' => 'dat_o',
294 48 alirezamon
                                                      'range' => 'Dw-1            :   0'
295 43 alirezamon
                                                    },
296 48 alirezamon
                               's_dat_i' => {
297
                                              'intfc_name' => 'plug:wb_slave[0]',
298 43 alirezamon
                                              'type' => 'input',
299 48 alirezamon
                                              'intfc_port' => 'dat_i',
300
                                              'range' => 'Dw-1       :   0'
301 43 alirezamon
                                            },
302 48 alirezamon
                               'm_send_addr_o' => {
303
                                                    'range' => 'M_Aw-1          :   0',
304
                                                    'intfc_port' => 'adr_o',
305
                                                    'intfc_name' => 'plug:wb_master[0]',
306
                                                    'type' => 'output'
307
                                                  },
308 43 alirezamon
                               's_we_i' => {
309 48 alirezamon
                                             'intfc_port' => 'we_i',
310
                                             'range' => '',
311 43 alirezamon
                                             'intfc_name' => 'plug:wb_slave[0]',
312 48 alirezamon
                                             'type' => 'input'
313 43 alirezamon
                                           },
314 48 alirezamon
                               's_addr_i' => {
315
                                               'range' => 'S_Aw-1     :   0',
316
                                               'intfc_port' => 'adr_i',
317
                                               'type' => 'input',
318
                                               'intfc_name' => 'plug:wb_slave[0]'
319
                                             },
320
                               's_ack_o' => {
321
                                              'type' => 'output',
322
                                              'intfc_name' => 'plug:wb_slave[0]',
323
                                              'range' => '',
324
                                              'intfc_port' => 'ack_o'
325
                                            },
326 42 alirezamon
                               'm_receive_stb_o' => {
327 48 alirezamon
                                                      'range' => '',
328 42 alirezamon
                                                      'intfc_port' => 'stb_o',
329 43 alirezamon
                                                      'intfc_name' => 'plug:wb_master[1]',
330
                                                      'type' => 'output'
331 42 alirezamon
                                                    },
332 48 alirezamon
                               's_sel_i' => {
333
                                              'range' => 'SELw-1     :   0',
334
                                              'intfc_port' => 'sel_i',
335
                                              'type' => 'input',
336
                                              'intfc_name' => 'plug:wb_slave[0]'
337
                                            },
338
                               's_cti_i' => {
339
                                              'intfc_name' => 'plug:wb_slave[0]',
340
                                              'type' => 'input',
341
                                              'intfc_port' => 'cti_i',
342
                                              'range' => 'TAGw-1     :   0'
343
                                            },
344
                               'm_send_dat_i' => {
345
                                                   'intfc_name' => 'plug:wb_master[0]',
346
                                                   'type' => 'input',
347
                                                   'range' => 'Dw-1           :  0',
348
                                                   'intfc_port' => 'dat_i'
349
                                                 },
350 42 alirezamon
                               'm_send_cyc_o' => {
351
                                                   'range' => '',
352 48 alirezamon
                                                   'intfc_port' => 'cyc_o',
353 43 alirezamon
                                                   'intfc_name' => 'plug:wb_master[0]',
354 48 alirezamon
                                                   'type' => 'output'
355 42 alirezamon
                                                 },
356 48 alirezamon
                               'm_receive_cti_o' => {
357
                                                      'intfc_name' => 'plug:wb_master[1]',
358
                                                      'type' => 'output',
359
                                                      'intfc_port' => 'cti_o',
360
                                                      'range' => 'TAGw-1          :   0'
361
                                                    },
362
                               'm_send_ack_i' => {
363
                                                   'type' => 'input',
364
                                                   'intfc_name' => 'plug:wb_master[0]',
365
                                                   'intfc_port' => 'ack_i',
366
                                                   'range' => ''
367
                                                 },
368
                               'current_r_addr' => {
369
                                                     'range' => 'RAw-1   :   0',
370
                                                     'intfc_port' => 'current_r_addr',
371
                                                     'type' => 'input',
372
                                                     'intfc_name' => 'socket:ni[0]'
373
                                                   },
374
                               's_stb_i' => {
375
                                              'range' => '',
376
                                              'intfc_port' => 'stb_i',
377
                                              'intfc_name' => 'plug:wb_slave[0]',
378
                                              'type' => 'input'
379
                                            }
380 38 alirezamon
                             },
381 48 alirezamon
                  'unused' => {
382
                                'plug:wb_slave[0]' => [
383
                                                        'tag_i',
384
                                                        'err_o',
385
                                                        'bte_i',
386
                                                        'rty_o'
387
                                                      ],
388
                                'plug:wb_master[0]' => [
389
                                                         'rty_i',
390
                                                         'dat_o',
391
                                                         'tag_o',
392
                                                         'err_i',
393
                                                         'bte_o'
394
                                                       ],
395
                                'plug:wb_master[1]' => [
396
                                                         'dat_i',
397
                                                         'rty_i',
398
                                                         'tag_o',
399
                                                         'err_i',
400
                                                         'bte_o'
401
                                                       ]
402
                              },
403 42 alirezamon
                  'parameters_order' => [
404
                                          'MAX_TRANSACTION_WIDTH',
405
                                          'MAX_BURST_SIZE',
406
                                          'Dw',
407
                                          'S_Aw',
408
                                          'M_Aw',
409
                                          'TAGw',
410
                                          'SELw',
411 43 alirezamon
                                          'CRC_EN',
412
                                          'RAw',
413 48 alirezamon
                                          'EAw',
414
                                          'HDATA_PRECAPw'
415 42 alirezamon
                                        ],
416 48 alirezamon
                  'module_name' => 'ni_master',
417
                  'description' => '',
418
                  'ip_name' => 'ni_master',
419
                  'hdl_files' => [
420
                                   '/mpsoc/rtl/src_peripheral/ni/ni_vc_dma.v',
421
                                   '/mpsoc/rtl/src_peripheral/ni/ni_vc_wb_slave_regs.v',
422
                                   '/mpsoc/rtl/src_peripheral/ni/ni_master.sv',
423
                                   '/mpsoc/rtl/src_peripheral/ni/ni_crc32.v',
424
                                   '/mpsoc/rtl/main_comp.v',
425
                                   '/mpsoc/rtl/arbiter.v',
426
                                   '/mpsoc/rtl/src_topolgy/',
427
                                   '/mpsoc/rtl/src_noc/'
428
                                 ],
429
                  'file_name' => 'mpsoc/rtl/src_peripheral/ni/ni_master.v',
430
                  'system_c' => '/*
431
        The NI initializing function.
432
        The burst_size must be  <= $MAX_BURST_SIZE
433
        send_int_en :1: enable the intrrupt when a packet is sent 0 : This intrrupt is disabled
434
        save_int_en : 1: enable the intrrupt when a recived packet is saved on internal buffer  0 : This intrrupt is disabled
435
        got_pck_int_en : 1: enable the intrrupt when a packet is recived in NI. 0 : This intrrupt is disabled
436
 
437
*/
438
void ${IP}_initial (unsigned int burst_size, unsigned char errors_int_en, unsigned char send_done_int_en, unsigned char save_done_int_en, unsigned char got_pck_int_en) {
439
        ${IP}_BURST_SIZE_REG  =  burst_size;
440
        int i;
441
        for (i=0; i<${IP}_NUM_VCs;i++){
442
                if(send_done_int_en)    ${IP}_send_done_int_en(i);  else  ${IP}_send_done_int_disable(i);
443
                if(save_done_int_en)    ${IP}_save_done_int_en(i);  else  ${IP}_save_done_int_disable(i);
444
                if(got_pck_int_en)      ${IP}_got_pckt_int_en(i);   else  ${IP}_got_pckt_int_disable(i);
445
                if(errors_int_en)       ${IP}_error_int_en(i);      else  ${IP}_error_int_disable(i);
446
 
447
        }
448
}
449
 
450
/*
451
        The NI message sent function:
452
        v: virtual chanel number which this packet should be sent to
453
        class_num: message class number. Diffrent message classes can be sent via isolated network resources to avoid protocol deadlock
454
        data_start_addr : The address pointer to the start location of the packet to be sent in the memory
455
        data_size: the message data size in words
456
        dest_phy_addr: the destination endpoint physical address. check phy_adr.h file for knowing each endpoint physical address
457
 
458
*/
459
 
460
void ${IP}_transfer (unsigned int init_weight, unsigned int v, unsigned int class_num, unsigned char  hdr_data, unsigned int data_start_addr,  unsigned int data_size, unsigned int dest_phy_addr){
461
        while (${IP}_send_is_busy(v)); // wait until VC is busy sending previous packet
462
        ${IP}_SEND_HDR_DATA_REG(v) = hdr_data;
463
        ${IP}_SEND_DATA_SIZE_REG(v)  = data_size;
464
        ${IP}_SEND_ADDR_POINTER_REG(v)  = data_start_addr;
465
        ${IP}_SEND_DEST_REG(v)   = dest_phy_addr | (class_num<<16) | (init_weight<<24);
466
 
467
}
468
 
469
/*
470
        The NI message receiver function:
471
        v: virtual chanel number of the received packet
472
        data_start_addr : The address pointer to the start location of the memory where the newly arrived packet must be stored by NI in.
473
        max_buffer_size : The allocated receive-memory buffer size in words.
474
*/
475
 
476
void ${IP}_receive (unsigned int v, unsigned int data_start_addr,  unsigned int max_buffer_size, unsigned int start_index){
477
         while (${IP}_receive_is_busy(v)); // wait until VC is busy saving previous packet
478
        ${IP}_RECEIVE_ADDR_POINTER_REG(v)  = data_start_addr;
479
        ${IP}_RECEIVE_SATRT_INDEX_REG(v) =   start_index ;
480
        ${IP}_RECEIVE_MAX_BUFF_SIZ_REG(v) = max_buffer_size;
481
        ${IP}_RECEIVE_CTRL_REG(v)   = 1;
482
}',
483 43 alirezamon
                  'system_h' => '#include 
484 48 alirezamon
#ifdef MULTI_CORE
485
        #include "../phy_addr.h"
486
#endif
487
 
488
/*          NI wb registers addresses
489
 
490
 VC specefic registers
491
       address bits
492
 [4+Vw:4]      [3:0]
493
                1  :   CTRL_FLAGS: {invalid_send_req_err, burst_size_err_isr, send_data_size_err_isr, crc_miss_match_isr, rcive_buff_ovrflw_err_isr,got_packet_isr,
494
                                    packet_is_saved_isr, packet_is_sent_isr,got_any_errorint_en,got_packet_int_en, packet_is_saved_int_en, packet_is_sent_int_en,
495
                                    receive_is_busy, send_is_busy};
496
                2  :   SEND_DEST_WB_ADDR           The destination router address
497
                3  :   SEND_POINTER_WB_ADDR,       The address of data to be sent in byte
498
 Virtual        4  :   SEND_DATA_SIZE_WB_ADDR,     The size of data to be sent in byte
499
 chanel        5  :   SEND_HDR_DATA_WB_ADDR       The heder data address
500
 number
501
                8  :   RECEIVE_SRC_WB_ADDR         The source router (the router which is sent this packet).
502
                9  :   RECEIVE_POINTER_WB_ADDR     The address pointer of reciever memory in byte
503
                10 :   RECEIVE_DATA_SIZE_WB_ADDR   The size of recieved data in byte
504
                11 :   RECEIVE_MAX_BUFF_SIZ        The reciver allocated buffer size in words. If the packet size is bigger than the buffer size the rest of ot will be discarred
505
                12 :   RECEIVE_SATRT_INDEX_WB_ADDR The recived data is wrriten on RECEIVE_POINTER_WB_ADDR + RECEIVE_SATRT_INDEX_WB_ADDR.
506
                                                       If the write address reach to the end of buffer pointer, it starts at the RECEIVE_POINTER_WB_ADDR.
507
                13 :   RECEIVE_CTRL_WB_ADDR        The NI reciever control register
508
                14 :   RECEIVE_PRECAP_DATA_ADDR    The address to the header filit data which can be precaptured befor buffering the actual data.
509 43 alirezamon
 
510 48 alirezamon
 Shared registers for all VCs
511
    address bits
512
      [5:0]
513
       0:    STATUS1_WB_ADDR     // status1:  {send_vc_enable_binary, receive_vc_enable_binary, receive_vc_is_busy, send_vc_is_busy};
514
       16:   BURST_SIZE_WB_ADDR  // The busrt size in words
515
       32: reserved
516
 
517 34 alirezamon
*/
518 48 alirezamon
 
519
 
520
 
521 43 alirezamon
#define COREID  ${CORE_ID}
522
#define CORE_PHY_ADDR   PHY_ADDR_ENDP_${CORE_ID}
523 48 alirezamon
#define ${IP}_NUM_VCs   ${V}
524
#define ${IP}_HDATA_PRECAPw     ${HDATA_PRECAPw}
525
#define ${IP}_BYTE_EN     ${BYTE_EN}
526 34 alirezamon
 
527 48 alirezamon
//general registers
528
#define ${IP}_STATUS1_REG                 (*((volatile unsigned int *) ($BASE)))   //0
529
#define ${IP}_BURST_SIZE_REG              (*((volatile unsigned int *) ($BASE+64))) //16
530 34 alirezamon
 
531 48 alirezamon
//VC contro registerl
532
#define ${IP}_CTRL_FLAGS_REG(v)           (*((volatile unsigned int *) ($BASE+4+(v<<6)))) //1
533 34 alirezamon
 
534 48 alirezamon
//Send VC registers
535
#define ${IP}_SEND_DEST_REG(v)            (*((volatile unsigned int *) ($BASE+8+(v<<6)))) //2
536
#define ${IP}_SEND_ADDR_POINTER_REG(v)    (*((volatile unsigned int *) ($BASE+12+(v<<6))))  //3
537
#define ${IP}_SEND_DATA_SIZE_REG(v)       (*((volatile unsigned int *) ($BASE+16+(v<<6))))  //4
538
#define ${IP}_SEND_HDR_DATA_REG(v)        (*((volatile unsigned int *) ($BASE+20+(v<<6)))) //5
539 34 alirezamon
 
540 48 alirezamon
//Receives VC registers
541
#define ${IP}_RECEIVE_SRC_REG(v)          (*((volatile unsigned int *) ($BASE+32+(v<<6))))  //8
542
#define ${IP}_RECEIVE_ADDR_POINTER_REG(v) (*((volatile unsigned int *) ($BASE+36+(v<<6)))) //9
543
#define ${IP}_RECEIVE_DATA_SIZE_REG(v)    (*((volatile unsigned int *) ($BASE+40+(v<<6)))) //10
544
#define ${IP}_RECEIVE_MAX_BUFF_SIZ_REG(v) (*((volatile unsigned int *) ($BASE+44+(v<<6)))) //11
545
#define ${IP}_RECEIVE_SATRT_INDEX_REG(v)  (*((volatile unsigned int *) ($BASE+48+(v<<6)))) //12
546
#define ${IP}_RECEIVE_CTRL_REG(v)         (*((volatile unsigned int *) ($BASE+52+(v<<6)))) //13
547
#define ${IP}_RECEIVE_PRECAP_DATA_REG(v)  (*((volatile unsigned int *) ($BASE+56+(v<<6)))) //14
548 34 alirezamon
 
549 48 alirezamon
//STATUS FLGs
550
#define  ANY_SENT_DONE_ISR_FLG    (1<<0)
551
#define  ANY_SAVE_DONE_ISR_FLG    (1<<1)
552
#define  ANY_GOT_PCK_ISR_FLG      (1<<2)
553
#define  ANY_ERR_ISR_FLG           (1<<3)
554 34 alirezamon
 
555 48 alirezamon
#define ${IP}_any_sent_done_isr_is_asserted()      (( ${IP}_STATUS1_REG & ANY_SENT_DONE_ISR_FLG )!=0)
556
#define ${IP}_any_save_done_isr_is_asserted()      (( ${IP}_STATUS1_REG & ANY_SAVE_DONE_ISR_FLG )!=0)
557
#define ${IP}_any_got_pck_isr_is_asserted()        (( ${IP}_STATUS1_REG & ANY_GOT_PCK_ISR_FLG)!=0)
558
#define ${IP}_any_err_isr_is_asserted()            (( ${IP}_STATUS1_REG & ANY_ERR_ISR_FLG)!=0)
559 34 alirezamon
 
560
 
561
 
562 48 alirezamon
//CTRL FLGs:
563
#define SEND_IS_BUSY_FLG         (1<<0)
564
#define RCV_IS_BUSY_FLG          (1<<1)
565 34 alirezamon
 
566 48 alirezamon
#define SEND_DONE_INT_EN_FLG     (1<<2)
567
#define SAVE_DONE_INT_EN_FLG     (1<<3)
568
#define GOT_PCK_INT_EN_FLG       (1<<4)
569
#define ANY_ERR_INT_EN_FLG       (1<<5)
570 34 alirezamon
 
571 48 alirezamon
#define SEND_DONE_ISR_FLG        (1<<6)
572
#define SAVE_DONE_ISR_FLG        (1<<7)
573
#define GOT_PCK_ISR_FLG          (1<<8)
574 34 alirezamon
 
575 48 alirezamon
#define BUFF_OVFLOW_ERR_ISR_FLG  (1<<9)   // This error happens when the receiver allocated buffer size is smaller than the received packet size
576
#define CRC_MISS_MATCH_ISR_FLG   (1<<10)  // This error happens when the received packet CRC miss match
577
#define SEND_DSIZE_ERR_ISR_FLG   (1<<11)  // This error happens when the send data size is not set
578
#define BURST_SIZE_ERR_ISR_FLG   (1<<12)  // This error happens when the burst size is not set
579
#define INVALID_SEND_REQ_ISR_FLG (1<<13)  // This error happens when a new send request is received while the DMA is still busy sending previous packet
580 34 alirezamon
 
581 48 alirezamon
#define ALL_INT_EN       (SEND_DONE_INT_EN_FLG | SAVE_DONE_INT_EN_FLG | GOT_PCK_INT_EN_FLG | ANY_ERR_INT_EN_FLG)
582 42 alirezamon
 
583
 
584 48 alirezamon
#define ${IP}_send_is_busy(v)             ((${IP}_CTRL_FLAGS_REG(v) & SEND_IS_BUSY_FLG)!=0)
585
#define ${IP}_send_is_free(v)             ((${IP}_CTRL_FLAGS_REG(v) & SEND_IS_BUSY_FLG)==0)
586 42 alirezamon
 
587 48 alirezamon
#define ${IP}_receive_is_busy(v)          ((${IP}_CTRL_FLAGS_REG(v) & RCV_IS_BUSY_FLG)!=0)
588
#define ${IP}_receive_is_free(v)          ((${IP}_CTRL_FLAGS_REG(v) & RCV_IS_BUSY_FLG)==0)
589 42 alirezamon
 
590
 
591
 
592 48 alirezamon
 
593
 
594
#define ${IP}_send_done_int_en(v)         (${IP}_CTRL_FLAGS_REG(v) |=  SEND_DONE_INT_EN_FLG)
595
#define ${IP}_send_done_int_disable(v)    (${IP}_CTRL_FLAGS_REG(v) &= ~SEND_DONE_INT_EN_FLG)
596
#define ${IP}_save_done_int_en(v)         (${IP}_CTRL_FLAGS_REG(v) |=  SAVE_DONE_INT_EN_FLG)
597
#define ${IP}_save_done_int_disable(v)    (${IP}_CTRL_FLAGS_REG(v) &= ~SAVE_DONE_INT_EN_FLG)
598
#define ${IP}_got_pckt_int_en(v)          (${IP}_CTRL_FLAGS_REG(v) |=  GOT_PCK_INT_EN_FLG)
599
#define ${IP}_got_pckt_int_disable(v)     (${IP}_CTRL_FLAGS_REG(v) &= ~GOT_PCK_INT_EN_FLG)
600
#define ${IP}_error_int_en(v)             (${IP}_CTRL_FLAGS_REG(v) |=  ANY_ERR_INT_EN_FLG)
601
#define ${IP}_error_int_disable(v)        (${IP}_CTRL_FLAGS_REG(v) &= ~ANY_ERR_INT_EN_FLG)
602
 
603
 
604
 
605
#define ${IP}_packet_is_sent(v)           ((${IP}_CTRL_FLAGS_REG(v) & SEND_DONE_ISR_FLG)!=0)
606
#define ${IP}_packet_is_saved(v)          ((${IP}_CTRL_FLAGS_REG(v) & SAVE_DONE_ISR_FLG )!=0)
607
#define ${IP}_got_packet(v)               ((${IP}_CTRL_FLAGS_REG(v) & GOT_PCK_ISR_FLG)!=0)
608
 
609
#define ${IP}_got_buff_ovf(v)             ((${IP}_CTRL_FLAGS_REG(v) & BUFF_OVFLOW_ERR_ISR_FLG)!=0)
610
#define ${IP}_got_crc_mismatch(v)         ((${IP}_CTRL_FLAGS_REG(v) & CRC_MISS_MATCH_ISR_FLG)!=0)
611
#define ${IP}_got_send_dsize_err(v)       ((${IP}_CTRL_FLAGS_REG(v) & SEND_DSIZE_ERR_ISR_FLG)!=0)
612
#define ${IP}_got_burst_size_err(v)       ((${IP}_CTRL_FLAGS_REG(v) & BURST_SIZE_ERR_ISR_FLG)!=0)
613
#define ${IP}_got_invalid_send_req(v)     ((${IP}_CTRL_FLAGS_REG(v) & INVALID_SEND_REQ_ISR_FLG)!=0)
614
 
615
 
616
 
617
//intrrupts ack functions
618
#define ${IP}_ack_send_done_isr(v)         (${IP}_CTRL_FLAGS_REG(v) &= (ALL_INT_EN | SEND_DONE_ISR_FLG))
619
#define ${IP}_ack_save_done_isr(v)         (${IP}_CTRL_FLAGS_REG(v) &= (ALL_INT_EN | SAVE_DONE_ISR_FLG))
620
#define ${IP}_ack_got_pck_isr(v)           (${IP}_CTRL_FLAGS_REG(v) &= (ALL_INT_EN | GOT_PCK_ISR_FLG))
621
 
622
#define ${IP}_ack_buff_ovf_isr(v)          (${IP}_CTRL_FLAGS_REG(v) &= (ALL_INT_EN | BUFF_OVFLOW_ERR_ISR_FLG))
623
#define ${IP}_ack_crc_mismatch_isr(v)      (${IP}_CTRL_FLAGS_REG(v) &= (ALL_INT_EN | CRC_MISS_MATCH_ISR_FLG))
624
#define ${IP}_ack_send_dsize_err_isr(v)    (${IP}_CTRL_FLAGS_REG(v) &= (ALL_INT_EN | SEND_DSIZE_ERR_ISR_FLG))
625
#define ${IP}_ack_burst_size_err_isr(v)    (${IP}_CTRL_FLAGS_REG(v) &= (ALL_INT_EN | BURST_SIZE_ERR_ISR_FLG))
626
#define ${IP}_ack_invalid_send_req_isr(v)  (${IP}_CTRL_FLAGS_REG(v) &= (ALL_INT_EN | INVALID_SEND_REQ_ISR_FLG))
627
 
628
 
629
#define ${IP}_ack_all_isr(v)  (${IP}_CTRL_FLAGS_REG(v) = ${IP}_CTRL_FLAGS_REG(v))
630
 
631
 
632 42 alirezamon
struct SRC_INFOS{
633
        unsigned char r; // reserved
634
        unsigned char c;  // message  class
635 43 alirezamon
        int16_t addr; // phy_addr
636 42 alirezamon
} ;
637
 
638 48 alirezamon
static inline struct SRC_INFOS get_src_info(unsigned char v){
639
        struct SRC_INFOS  src_info =*(struct SRC_INFOS *) (&${IP}_RECEIVE_SRC_REG(v));
640 42 alirezamon
        return  src_info;
641
}
642
 
643
/*
644
        The NI initializing function.
645
        The burst_size must be  <= $MAX_BURST_SIZE
646
        send_int_en :1: enable the intrrupt when a packet is sent 0 : This intrrupt is disabled
647
        save_int_en : 1: enable the intrrupt when a recived packet is saved on internal buffer  0 : This intrrupt is disabled
648
        got_pck_int_en : 1: enable the intrrupt when a packet is recived in NI. 0 : This intrrupt is disabled
649
 
650
*/
651 48 alirezamon
void ${IP}_initial (unsigned int burst_size, unsigned char errors_int_en, unsigned char send_done_int_en, unsigned char save_done_int_en, unsigned char got_pck_int_en) ;
652 34 alirezamon
 
653 42 alirezamon
/*
654
        The NI message sent function:
655 48 alirezamon
        v: virtual chanel number which this packet should be sent to
656 42 alirezamon
        class_num: message class number. Diffrent message classes can be sent via isolated network resources to avoid protocol deadlock
657
        data_start_addr : The address pointer to the start location of the packet to be sent in the memory
658
        data_size: the message data size in words
659 43 alirezamon
        dest_phy_addr: the destination endpoint physical address. check phy_adr.h file for knowing each endpoint physical address
660 34 alirezamon
 
661 42 alirezamon
*/
662
 
663 48 alirezamon
void ${IP}_transfer (unsigned int init_weight, unsigned int v, unsigned int class_num, unsigned char  hdr_data, unsigned int data_start_addr,  unsigned int data_size, unsigned int dest_phy_addr);
664 34 alirezamon
 
665 42 alirezamon
/*
666
        The NI message receiver function:
667 48 alirezamon
        v: virtual chanel number of the received packet
668 42 alirezamon
        data_start_addr : The address pointer to the start location of the memory where the newly arrived packet must be stored by NI in.
669
        max_buffer_size : The allocated receive-memory buffer size in words.
670
*/
671
 
672 48 alirezamon
void ${IP}_receive (unsigned int v, unsigned int data_start_addr,  unsigned int max_buffer_size, unsigned int start_index);',
673
                  'gui_status' => {
674
                                    'status' => 'ideal',
675
                                    'timeout' => 0
676 43 alirezamon
                                  },
677 48 alirezamon
                  'system_v' => '`define INCLUDE_TOPOLOGY_LOCALPARAM
678
    `include "topology_localparam.v"',
679
                  'modules' => {
680
                                 'ni_master' => {},
681
                                 'ovc_status' => {},
682
                                 'vc_wb_slave_registers' => {},
683
                                 'ni_vc_dma' => {},
684
                                 'header_flit_generator' => {}
685
                               },
686
                  'version' => 84,
687
                  'description_pdf' => '/mpsoc/rtl/src_peripheral/ni/NI.pdf',
688
                  'category' => 'NoC',
689 43 alirezamon
                  'sockets' => {
690
                                 'ni' => {
691
                                           '0' => {
692
                                                    'name' => 'ni'
693
                                                  },
694 48 alirezamon
                                           'ni' => {},
695
                                           'value' => 1,
696
                                           'connection_num' => 'single connection',
697 43 alirezamon
                                           'type' => 'num'
698
                                         }
699 48 alirezamon
                               }
700 38 alirezamon
                }, 'ip_gen' );

powered by: WebSVN 2.1.0

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