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 54

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

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

powered by: WebSVN 2.1.0

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