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 56

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 56 alirezamon
module header_flit_generator #(
33
    parameter NOC_ID=0,
34
    parameter DATA_w=9 // header flit can carry Optional data. The data will be placed after control data.  Fpay >= DATA_w + CTRL_BITS_w
35
)(
36 48 alirezamon
    flit_out,
37
    src_e_addr_in,
38
    dest_e_addr_in,
39
    destport_in,
40
    class_in,
41
    weight_in,
42
    vc_num_in,
43
    be_in,
44
    data_in
45 56 alirezamon
);
46 48 alirezamon
 
47 56 alirezamon
        `NOC_CONF
48 48 alirezamon
 
49 56 alirezamon
    localparam    HDR_FLAG  =   2'b10;
50 48 alirezamon
 
51
    localparam
52
        Dw = (DATA_w==0)? 1 : DATA_w,
53
        DATA_LSB= MSB_BE+1,               DATA_MSB= (DATA_LSB + DATA_w)
54 56 alirezamon
 
55 48 alirezamon
    output   [Fw-1  :   0] flit_out;
56
    input    [Cw-1  :   0] class_in;
57 54 alirezamon
    input    [DAw-1 :   0] dest_e_addr_in;
58 48 alirezamon
    input    [EAw-1 :   0] src_e_addr_in;
59
    input    [V-1   :   0] vc_num_in;
60
    input    [WEIGHTw-1 :   0] weight_in;
61
    input    [DSTPw-1   :   0] destport_in;
62
    input    [BEw-1 : 0] be_in;
63
    input    [Dw-1  :   0] data_in;
64
 
65
   // 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};
66
    assign flit_out [E_SRC_MSB : E_SRC_LSB] = src_e_addr_in;
67
    assign flit_out [E_DST_MSB : E_DST_LSB] = dest_e_addr_in;
68
    assign flit_out [DST_P_MSB : DST_P_LSB] = destport_in;
69
 
70
 
71
    generate
72
    if(C>1)begin :have_class
73
        assign flit_out [CLASS_MSB :CLASS_LSB] = class_in;
74
    end
75
 
76
    /* verilator lint_off WIDTH */
77
    if(SWA_ARBITER_TYPE != "RRA")begin  : wrra_b
78
    /* verilator lint_on WIDTH */
79
        assign flit_out [WEIGHT_MSB :WEIGHT_LSB] = weight_in;
80
    end
81
 
82
    if( BYTE_EN ) begin : be_1
83
        assign flit_out [BE_MSB : BE_LSB] = be_in;
84
    end
85
 
86
 
87
    if (DATA_w ==0) begin :no_data
88
        if(FPAYw>DATA_LSB) begin: dontcare
89
                 assign flit_out [FPAYw-1 : DATA_LSB] = {(FPAYw-DATA_LSB){1'bX}};
90
        end
91
    end else begin :have_data
92
                 assign flit_out [DATA_MSB : DATA_LSB] = data_in[DATA_MSB-DATA_LSB : 0]; // we have enough space for adding whole of the data
93
    end
94
    endgenerate
95
 
96
    assign flit_out [FPAYw+V-1    :   FPAYw] = vc_num_in;
97
    assign flit_out [Fw-1        :    Fw-2] = HDR_FLAG;
98
 
99
 
100
    //synthesis translate_off
101
    //synopsys  translate_off
102
    initial begin
103
        if((DATA_LSB + DATA_w)-1 > FPAYw)begin
104
            $display("%t: ERROR: The reqired header flit size is %d which is larger than %d payload size   ",$time,(DATA_LSB + DATA_w)-1,FPAYw);
105
            $finish;
106
        end
107
    end
108
    //synopsys  translate_on
109 56 alirezamon
    //synthesis translate_on
110 48 alirezamon
 
111
endmodule
112
 
113
 
114 56 alirezamon
module extract_header_flit_info # (
115
    parameter NOC_ID=0,
116 48 alirezamon
    parameter DATA_w = 0
117 56 alirezamon
) (
118 48 alirezamon
    //inputs
119
    flit_in,
120
    flit_in_wr,
121
    //outputs
122
    src_e_addr_o,
123
    dest_e_addr_o,
124
    destport_o,
125
    class_o,
126
    weight_o,
127
    data_o,
128
    tail_flg_o,
129
    hdr_flg_o,
130
    vc_num_o,
131
    hdr_flit_wr_o,
132 56 alirezamon
    be_o
133
);
134 48 alirezamon
 
135 56 alirezamon
        `NOC_CONF
136
 
137 48 alirezamon
    localparam
138
        W = WEIGHTw,
139 56 alirezamon
        Dw = (DATA_w==0)? 1 : DATA_w,
140
        DATA_LSB= MSB_BE+1,               DATA_MSB= (DATA_LSB + DATA_w)
141
        OFFSETw = DATA_MSB - DATA_LSB +1;
142 48 alirezamon
 
143
 
144
    input [Fw-1 : 0] flit_in;
145
    input flit_in_wr;
146
 
147
    output [EAw-1 : 0] src_e_addr_o;
148 54 alirezamon
    output [DAw-1 : 0] dest_e_addr_o;
149 48 alirezamon
    output [DSTPw-1 : 0] destport_o;
150
    output [Cw-1 : 0] class_o;
151
    output [W-1  : 0] weight_o;
152
    output tail_flg_o;
153
    output hdr_flg_o;
154
    output [V-1 : 0] vc_num_o;
155
    output [V-1 : 0] hdr_flit_wr_o;
156
    output [BEw-1 : 0] be_o;
157
    output [Dw-1  :   0] data_o;
158
 
159
 
160
 
161
 
162
 
163
    wire [OFFSETw-1 : 0 ] offset;
164
 
165
    assign src_e_addr_o = flit_in [E_SRC_MSB : E_SRC_LSB];
166
    assign dest_e_addr_o = flit_in [E_DST_MSB : E_DST_LSB];
167
    assign destport_o = flit_in [DST_P_MSB : DST_P_LSB];
168
 
169
 
170
    generate
171
    if(C>1)begin :have_class
172
        assign class_o = flit_in [CLASS_MSB : CLASS_LSB];
173
    end else begin : no_class
174
     assign class_o = {Cw{1'b0}};
175
    end
176
 
177
    /* verilator lint_off WIDTH */
178
    if(SWA_ARBITER_TYPE != "RRA")begin  : wrra_b
179
    /* verilator lint_on WIDTH */
180
        assign weight_o =  flit_in [WEIGHT_MSB : WEIGHT_LSB];
181
    end else begin : rra_b
182
        assign weight_o = {WEIGHTw{1'bX}};
183
    end
184
 
185
    if( BYTE_EN ) begin : be_1
186
        assign be_o = flit_in [BE_MSB : BE_LSB];
187
    end else begin : be_0
188
        assign be_o = {BEw{1'bX}};
189
    end
190
 
191
 
192
    assign offset = flit_in [DATA_MSB : DATA_LSB];
193
 
194
 
195
    if(Dw > OFFSETw) begin : if1
196
        assign data_o={{(Dw-OFFSETw){1'b0}},offset};
197
    end else begin : if2
198
        assign data_o=offset[Dw-1 : 0];
199
    end
200
 
201
    endgenerate
202
 
203
   /* verilator lint_off WIDTH */
204
    assign hdr_flg_o  = (PCK_TYPE == "MULTI_FLIT") ? flit_in [Fw-1]  : 1'b1;
205
    assign tail_flg_o = (PCK_TYPE == "MULTI_FLIT") ? flit_in [Fw-2]  : 1'b1;
206
   /* verilator lint_on WIDTH */
207
 
208
 
209
    assign vc_num_o = flit_in [FPAYw+V-1 : FPAYw];
210
    assign hdr_flit_wr_o= (flit_in_wr & hdr_flg_o )? vc_num_o : {V{1'b0}};
211
 
212
endmodule
213
 
214
 
215
 
216
 
217
 
218
 
219
/***********************************
220
*  flit_update
221
*  update the header flit look ahead routing and output VC
222
**********************************/
223
 
224 56 alirezamon
module header_flit_update_lk_route_ovc #(
225
    parameter NOC_ID=0,
226
    parameter P = 5
227
)
228
(
229 48 alirezamon
    flit_in ,
230
    flit_out,
231
    vc_num_in,
232
    lk_dest_all_in,
233
    assigned_ovc_num,
234
    any_ivc_sw_request_granted,
235
    lk_dest_not_registered,
236
    sel,
237
    reset,
238
    clk
239
);
240
 
241 56 alirezamon
        `NOC_CONF
242
 
243 48 alirezamon
    localparam
244
        VDSTPw = V * DSTPw,
245 56 alirezamon
        VV = V * V;
246 48 alirezamon
 
247
    input [Fw-1 : 0]  flit_in;
248
    output reg [Fw-1 : 0]  flit_out;
249
    input [V-1 : 0]  vc_num_in;
250
    input [VDSTPw-1 : 0]  lk_dest_all_in;
251
    input                           reset,clk;
252
    input [VV-1 : 0]  assigned_ovc_num;
253
    input [V-1 : 0]  sel;
254
    input                    any_ivc_sw_request_granted;
255
    input [DSTPw-1 : 0]  lk_dest_not_registered;
256
 
257
    wire hdr_flag;
258 54 alirezamon
    logic [V-1 : 0]  vc_num_delayed;
259 48 alirezamon
    wire [V-1 : 0]  ovc_num;
260
    wire [DSTPw-1 : 0]  lk_dest,dest_coded;
261
    wire [DSTPw-1 : 0]  lk_mux_out;
262
 
263 56 alirezamon
    pronoc_register #(.W(V)) reg1 (.in(vc_num_in), .out(vc_num_delayed), .reset(reset), .clk(clk));
264 54 alirezamon
 
265 48 alirezamon
    /* verilator lint_off WIDTH */
266
    assign hdr_flag = ( PCK_TYPE == "MULTI_FLIT")? flit_in[Fw-1]: 1'b1;
267
    /* verilator lint_on WIDTH */
268
 
269
    onehot_mux_1D #(
270
        .W(DSTPw),
271
        .N(V)
272
    )
273
    lkdest_mux
274
    (
275
        .in(lk_dest_all_in),
276
        .out(lk_mux_out),
277
        .sel(vc_num_delayed)
278
    );
279
 
280
    generate
281
    /* verilator lint_off WIDTH */
282
    if( SSA_EN == "YES" ) begin : predict // bypass the lk fifo when no ivc is granted
283
    /* verilator lint_on WIDTH */
284 54 alirezamon
        logic ivc_any_delayed;
285 48 alirezamon
 
286 54 alirezamon
        pronoc_register #(.W(1)) reg2 (.in(any_ivc_sw_request_granted ), .out(ivc_any_delayed), .reset(reset), .clk(clk));
287
 
288 48 alirezamon
        assign lk_dest = (ivc_any_delayed == 1'b0)? lk_dest_not_registered : lk_mux_out;
289
 
290
    end else begin : no_predict
291
        assign lk_dest =lk_mux_out;
292
    end
293
    endgenerate
294
 
295
   onehot_mux_1D #(
296
        .W(V),
297
        .N(V)
298
    )
299
    ovc_num_mux
300
    (
301
        .in(assigned_ovc_num),
302
        .out(ovc_num),
303
        .sel(vc_num_delayed)
304
    );
305
 
306
    generate
307
    /* verilator lint_off WIDTH */
308
    if((TOPOLOGY == "MESH" || TOPOLOGY == "FMESH" || TOPOLOGY == "TORUS"  || TOPOLOGY ==  "RING") && ROUTE_TYPE != "DETERMINISTIC" )begin :coded
309
    /* verilator lint_on WIDTH */
310
        mesh_torus_adaptive_lk_dest_encoder #(
311
            .V(V),
312
            .P(P),
313
            .DSTPw(DSTPw),
314
            .Fw(Fw),
315
            .DST_P_MSB(DST_P_MSB),
316
            .DST_P_LSB(DST_P_LSB)
317
        )
318
        dest_encoder
319
        (
320
            .sel(sel),
321
            .dest_coded_out(dest_coded),
322
            .vc_num_delayed(vc_num_delayed),
323
            .lk_dest(lk_dest),
324
            .flit_in(flit_in)
325
        );
326
 
327
 
328
    end else begin : dtrmn1
329
        assign dest_coded = lk_dest;
330
        /*
331
         mesh_torus_dtrmn_dest_encoder #(
332
            .P(P),
333
            .DSTPw(DSTPw),
334
            .Fw(Fw),
335
            .DST_P_MSB(DST_P_MSB),
336
            .DST_P_LSB(DST_P_LSB)
337
        )
338
         dest_encoder
339
        (
340
                .dest_coded_out(dest_coded),
341
                .lk_dest(lk_dest),
342
                .flit_in(flit_in)
343
         );
344
         */
345
    end
346
 
347
    always @(*)begin
348
         flit_out = {flit_in[Fw-1 : Fw-2],ovc_num,flit_in[FPAYw-1 :0]};
349
         if(hdr_flag) flit_out[DST_P_MSB : DST_P_LSB]= dest_coded;
350
    end
351
 
352
 
353
    endgenerate
354
 
355
 
356
 
357
 
358
endmodule
359
 
360
/******************
361
 *  hdr_flit_weight_update
362
 * ****************/
363
 
364 56 alirezamon
module hdr_flit_weight_update #(
365
    parameter NOC_ID = 0
366
) (
367 48 alirezamon
    new_weight,
368
    flit_in,
369
    flit_out
370
);
371
 
372 56 alirezamon
        `NOC_CONF
373
 
374 48 alirezamon
    input [WEIGHTw-1 : 0] new_weight;
375
    input [Fw-1 : 0] flit_in;
376
    output [Fw-1 : 0] flit_out;
377
 
378 56 alirezamon
    assign flit_out =  {flit_in[Fw-1 : WEIGHT_LSB+WEIGHTw ] ,new_weight, flit_in[WEIGHT_LSB-1 : 0] };
379 48 alirezamon
 
380
endmodule
381
 

powered by: WebSVN 2.1.0

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