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/] [rtl/] [src_noc/] [header_flit.sv] - Blame information for rev 48

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

Line No. Rev Author Line
1 48 alirezamon
`timescale 1ns / 1ps
2
 
3
/**********************************************************************
4
**  File:  header_flit.sv
5
**  Date:2017-07-11
6
**
7
**  Copyright (C) 2014-2017  Alireza Monemi
8
**
9
**  This file is part of ProNoC
10
**
11
**  ProNoC ( stands for Prototype Network-on-chip)  is free software:
12
**  you can redistribute it and/or modify it under the terms of the GNU
13
**  Lesser General Public License as published by the Free Software Foundation,
14
**  either version 2 of the License, or (at your option) any later version.
15
**
16
**  ProNoC is distributed in the hope that it will be useful, but WITHOUT
17
**  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
18
**  or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General
19
**  Public License for more details.
20
**
21
**  You should have received a copy of the GNU Lesser General Public
22
**  License along with ProNoC. If not, see .
23
**
24
**
25
**  Description:
26
**  This file contains modules related to header flit
27
******************************************************************/
28
 
29
/***************
30
*   header_flit_generator
31
***************/
32
 
33
module header_flit_generator
34
import pronoc_pkg::*;
35
#(
36
    parameter DATA_w = 9 // header flit can carry Optional data. The data will be placed after control data.  Fpay >= DATA_w + CTRL_BITS_w
37
 
38
)(
39
 
40
    flit_out,
41
    src_e_addr_in,
42
    dest_e_addr_in,
43
    destport_in,
44
    class_in,
45
    weight_in,
46
    vc_num_in,
47
    be_in,
48
    data_in
49
);
50
 
51
 
52
    function integer log2;
53
      input integer number; begin
54
         log2=(number <=1) ? 1: 0;
55
         while(2**log2
56
            log2=log2+1;
57
         end
58
      end
59
    endfunction // log2
60
 
61
/* verilator lint_off WIDTH */
62
    localparam
63
        Cw   =  (C>1)? log2(C): 1,
64
        HDR_FLAG  =   2'b10,
65
        BEw = (BYTE_EN)? log2(Fpay/8) : 1;
66
/* verilator lint_on WIDTH */
67
 
68
 
69
 
70
 
71
 
72
    localparam
73
        Dw = (DATA_w==0)? 1 : DATA_w,
74
        DATA_LSB= MSB_BE+1,               DATA_MSB= (DATA_LSB + DATA_w)
75
 
76
 
77
 
78
 
79
    output   [Fw-1  :   0] flit_out;
80
    input    [Cw-1  :   0] class_in;
81
    input    [EAw-1 :   0] dest_e_addr_in;
82
    input    [EAw-1 :   0] src_e_addr_in;
83
    input    [V-1   :   0] vc_num_in;
84
    input    [WEIGHTw-1 :   0] weight_in;
85
    input    [DSTPw-1   :   0] destport_in;
86
    input    [BEw-1 : 0] be_in;
87
    input    [Dw-1  :   0] data_in;
88
 
89
   // assign flit_out [W+Cw+P_1+Xw+Yw+Xw+Yw-1 :0] = {weight_i,class_i,destport_i,x_dst_i,y_dst_i,x_src_i,y_src_i};
90
    assign flit_out [E_SRC_MSB : E_SRC_LSB] = src_e_addr_in;
91
    assign flit_out [E_DST_MSB : E_DST_LSB] = dest_e_addr_in;
92
    assign flit_out [DST_P_MSB : DST_P_LSB] = destport_in;
93
 
94
 
95
    generate
96
    if(C>1)begin :have_class
97
        assign flit_out [CLASS_MSB :CLASS_LSB] = class_in;
98
    end
99
 
100
    /* verilator lint_off WIDTH */
101
    if(SWA_ARBITER_TYPE != "RRA")begin  : wrra_b
102
    /* verilator lint_on WIDTH */
103
        assign flit_out [WEIGHT_MSB :WEIGHT_LSB] = weight_in;
104
    end
105
 
106
    if( BYTE_EN ) begin : be_1
107
        assign flit_out [BE_MSB : BE_LSB] = be_in;
108
    end
109
 
110
 
111
    if (DATA_w ==0) begin :no_data
112
        if(FPAYw>DATA_LSB) begin: dontcare
113
                 assign flit_out [FPAYw-1 : DATA_LSB] = {(FPAYw-DATA_LSB){1'bX}};
114
        end
115
    end else begin :have_data
116
                 assign flit_out [DATA_MSB : DATA_LSB] = data_in[DATA_MSB-DATA_LSB : 0]; // we have enough space for adding whole of the data
117
    end
118
    endgenerate
119
 
120
    assign flit_out [FPAYw+V-1    :   FPAYw] = vc_num_in;
121
    assign flit_out [Fw-1        :    Fw-2] = HDR_FLAG;
122
 
123
 
124
    //synthesis translate_off
125
    //synopsys  translate_off
126
    initial begin
127
        if((DATA_LSB + DATA_w)-1 > FPAYw)begin
128
            $display("%t: ERROR: The reqired header flit size is %d which is larger than %d payload size   ",$time,(DATA_LSB + DATA_w)-1,FPAYw);
129
            $finish;
130
        end
131
    end
132
    //synopsys  translate_on
133
    //synthesis translate_on
134
 
135
 
136
endmodule
137
 
138
 
139
 
140
module extract_header_flit_info
141
                import pronoc_pkg::*;
142
#(
143
    parameter DATA_w = 0
144
)(
145
    //inputs
146
    flit_in,
147
    flit_in_wr,
148
    //outputs
149
    src_e_addr_o,
150
    dest_e_addr_o,
151
    destport_o,
152
    class_o,
153
    weight_o,
154
    data_o,
155
    tail_flg_o,
156
    hdr_flg_o,
157
    vc_num_o,
158
    hdr_flit_wr_o,
159
    be_o
160
 
161
);
162
 
163
 
164
 
165
    function integer log2;
166
      input integer number; begin
167
         log2=(number <=1) ? 1: 0;
168
         while(2**log2
169
            log2=log2+1;
170
         end
171
      end
172
    endfunction // log2
173
 
174
    localparam
175
        Cw = (C>1)? log2(C): 1,
176
        W = WEIGHTw,
177
        BEw = (BYTE_EN)? log2(Fpay/8) : 1;
178
 
179
    localparam
180
        Dw = (DATA_w==0)? 1 : DATA_w;
181
 
182
     localparam
183
 
184
        DATA_LSB= MSB_BE+1,               DATA_MSB= (DATA_LSB + DATA_w)
185
 
186
 
187
 
188
    localparam OFFSETw = DATA_MSB - DATA_LSB +1;
189
 
190
 
191
    input [Fw-1 : 0] flit_in;
192
    input flit_in_wr;
193
 
194
    output [EAw-1 : 0] src_e_addr_o;
195
    output [EAw-1 : 0] dest_e_addr_o;
196
    output [DSTPw-1 : 0] destport_o;
197
    output [Cw-1 : 0] class_o;
198
    output [W-1  : 0] weight_o;
199
    output tail_flg_o;
200
    output hdr_flg_o;
201
    output [V-1 : 0] vc_num_o;
202
    output [V-1 : 0] hdr_flit_wr_o;
203
    output [BEw-1 : 0] be_o;
204
    output [Dw-1  :   0] data_o;
205
 
206
 
207
 
208
 
209
 
210
    wire [OFFSETw-1 : 0 ] offset;
211
 
212
    assign src_e_addr_o = flit_in [E_SRC_MSB : E_SRC_LSB];
213
    assign dest_e_addr_o = flit_in [E_DST_MSB : E_DST_LSB];
214
    assign destport_o = flit_in [DST_P_MSB : DST_P_LSB];
215
 
216
 
217
    generate
218
    if(C>1)begin :have_class
219
        assign class_o = flit_in [CLASS_MSB : CLASS_LSB];
220
    end else begin : no_class
221
     assign class_o = {Cw{1'b0}};
222
    end
223
 
224
    /* verilator lint_off WIDTH */
225
    if(SWA_ARBITER_TYPE != "RRA")begin  : wrra_b
226
    /* verilator lint_on WIDTH */
227
        assign weight_o =  flit_in [WEIGHT_MSB : WEIGHT_LSB];
228
    end else begin : rra_b
229
        assign weight_o = {WEIGHTw{1'bX}};
230
    end
231
 
232
    if( BYTE_EN ) begin : be_1
233
        assign be_o = flit_in [BE_MSB : BE_LSB];
234
    end else begin : be_0
235
        assign be_o = {BEw{1'bX}};
236
    end
237
 
238
 
239
    assign offset = flit_in [DATA_MSB : DATA_LSB];
240
 
241
 
242
    if(Dw > OFFSETw) begin : if1
243
        assign data_o={{(Dw-OFFSETw){1'b0}},offset};
244
    end else begin : if2
245
        assign data_o=offset[Dw-1 : 0];
246
    end
247
 
248
    endgenerate
249
 
250
   /* verilator lint_off WIDTH */
251
    assign hdr_flg_o  = (PCK_TYPE == "MULTI_FLIT") ? flit_in [Fw-1]  : 1'b1;
252
    assign tail_flg_o = (PCK_TYPE == "MULTI_FLIT") ? flit_in [Fw-2]  : 1'b1;
253
   /* verilator lint_on WIDTH */
254
 
255
 
256
    assign vc_num_o = flit_in [FPAYw+V-1 : FPAYw];
257
    assign hdr_flit_wr_o= (flit_in_wr & hdr_flg_o )? vc_num_o : {V{1'b0}};
258
 
259
endmodule
260
 
261
 
262
 
263
 
264
 
265
 
266
/***********************************
267
*  flit_update
268
*  update the header flit look ahead routing and output VC
269
**********************************/
270
 
271
module header_flit_update_lk_route_ovc
272
                import pronoc_pkg::*;
273
#(
274
    parameter P = 5
275
)(
276
    flit_in ,
277
    flit_out,
278
    vc_num_in,
279
    lk_dest_all_in,
280
    assigned_ovc_num,
281
    any_ivc_sw_request_granted,
282
    lk_dest_not_registered,
283
    sel,
284
    reset,
285
    clk
286
);
287
 
288
 
289
    localparam
290
        VDSTPw = V * DSTPw,
291
        VV = V * V;
292
 
293
 
294
     localparam
295
        E_SRC_LSB =0,                   E_SRC_MSB = E_SRC_LSB + EAw-1,
296
        E_DST_LSB = E_SRC_MSB +1,       E_DST_MSB = E_DST_LSB + EAw-1,
297
        DST_P_LSB = E_DST_MSB + 1,      DST_P_MSB = DST_P_LSB + DSTPw-1;
298
 
299
 
300
    input [Fw-1 : 0]  flit_in;
301
    output reg [Fw-1 : 0]  flit_out;
302
    input [V-1 : 0]  vc_num_in;
303
    input [VDSTPw-1 : 0]  lk_dest_all_in;
304
    input                           reset,clk;
305
    input [VV-1 : 0]  assigned_ovc_num;
306
    input [V-1 : 0]  sel;
307
    input                    any_ivc_sw_request_granted;
308
    input [DSTPw-1 : 0]  lk_dest_not_registered;
309
 
310
    wire hdr_flag;
311
    reg [V-1 : 0]  vc_num_delayed;
312
    wire [V-1 : 0]  ovc_num;
313
    wire [DSTPw-1 : 0]  lk_dest,dest_coded;
314
    wire [DSTPw-1 : 0]  lk_mux_out;
315
 
316
 
317
`ifdef SYNC_RESET_MODE
318
    always @ (posedge clk )begin
319
`else
320
    always @ (posedge clk or posedge reset)begin
321
`endif
322
        if(reset) begin
323
            vc_num_delayed                  <= {V{1'b0}};
324
            //assigned_ovc_num_delayed  <=  {VV{1'b0}};
325
        end else begin
326
            vc_num_delayed<= vc_num_in;
327
            //assigned_ovc_num_delayed  <=assigned_ovc_num;
328
        end
329
    end
330
    /* verilator lint_off WIDTH */
331
    assign hdr_flag = ( PCK_TYPE == "MULTI_FLIT")? flit_in[Fw-1]: 1'b1;
332
    /* verilator lint_on WIDTH */
333
 
334
    onehot_mux_1D #(
335
        .W(DSTPw),
336
        .N(V)
337
    )
338
    lkdest_mux
339
    (
340
        .in(lk_dest_all_in),
341
        .out(lk_mux_out),
342
        .sel(vc_num_delayed)
343
    );
344
 
345
    generate
346
    /* verilator lint_off WIDTH */
347
    if( SSA_EN == "YES" ) begin : predict // bypass the lk fifo when no ivc is granted
348
    /* verilator lint_on WIDTH */
349
        reg ivc_any_delayed;
350
 
351
`ifdef SYNC_RESET_MODE
352
        always @ (posedge clk )begin
353
`else
354
        always @ (posedge clk or posedge reset)begin
355
`endif
356
            if(reset) begin
357
                ivc_any_delayed <= 1'b0;
358
            end else begin
359
                ivc_any_delayed <= any_ivc_sw_request_granted;
360
            end
361
        end
362
 
363
        assign lk_dest = (ivc_any_delayed == 1'b0)? lk_dest_not_registered : lk_mux_out;
364
 
365
    end else begin : no_predict
366
        assign lk_dest =lk_mux_out;
367
    end
368
    endgenerate
369
 
370
   onehot_mux_1D #(
371
        .W(V),
372
        .N(V)
373
    )
374
    ovc_num_mux
375
    (
376
        .in(assigned_ovc_num),
377
        .out(ovc_num),
378
        .sel(vc_num_delayed)
379
    );
380
 
381
    generate
382
    /* verilator lint_off WIDTH */
383
    if((TOPOLOGY == "MESH" || TOPOLOGY == "FMESH" || TOPOLOGY == "TORUS"  || TOPOLOGY ==  "RING") && ROUTE_TYPE != "DETERMINISTIC" )begin :coded
384
    /* verilator lint_on WIDTH */
385
        mesh_torus_adaptive_lk_dest_encoder #(
386
            .V(V),
387
            .P(P),
388
            .DSTPw(DSTPw),
389
            .Fw(Fw),
390
            .DST_P_MSB(DST_P_MSB),
391
            .DST_P_LSB(DST_P_LSB)
392
        )
393
        dest_encoder
394
        (
395
            .sel(sel),
396
            .dest_coded_out(dest_coded),
397
            .vc_num_delayed(vc_num_delayed),
398
            .lk_dest(lk_dest),
399
            .flit_in(flit_in)
400
        );
401
 
402
 
403
    end else begin : dtrmn1
404
        assign dest_coded = lk_dest;
405
        /*
406
         mesh_torus_dtrmn_dest_encoder #(
407
            .P(P),
408
            .DSTPw(DSTPw),
409
            .Fw(Fw),
410
            .DST_P_MSB(DST_P_MSB),
411
            .DST_P_LSB(DST_P_LSB)
412
        )
413
         dest_encoder
414
        (
415
                .dest_coded_out(dest_coded),
416
                .lk_dest(lk_dest),
417
                .flit_in(flit_in)
418
         );
419
         */
420
    end
421
 
422
    always @(*)begin
423
         flit_out = {flit_in[Fw-1 : Fw-2],ovc_num,flit_in[FPAYw-1 :0]};
424
         if(hdr_flag) flit_out[DST_P_MSB : DST_P_LSB]= dest_coded;
425
    end
426
 
427
 
428
    endgenerate
429
 
430
 
431
 
432
 
433
endmodule
434
 
435
/******************
436
 *  hdr_flit_weight_update
437
 * ****************/
438
 
439
module hdr_flit_weight_update
440
                import pronoc_pkg::*;
441
(
442
    new_weight,
443
    flit_in,
444
    flit_out
445
);
446
 
447
    function integer log2;
448
      input integer number; begin
449
         log2=(number <=1) ? 1: 0;
450
         while(2**log2
451
            log2=log2+1;
452
         end
453
      end
454
    endfunction // log2
455
 
456
 
457
     localparam
458
 
459
        Cw = (C>1)? log2(C): 1;
460
 
461
 
462
    input [WEIGHTw-1 : 0] new_weight;
463
    input [Fw-1 : 0] flit_in;
464
    output [Fw-1 : 0] flit_out;
465
 
466
 
467
 
468
  assign flit_out =  {flit_in[Fw-1 : WEIGHT_LSB+WEIGHTw ] ,new_weight, flit_in[WEIGHT_LSB-1 : 0] };
469
 
470
 
471
endmodule
472
 

powered by: WebSVN 2.1.0

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