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/] [topology_localparam.v] - Blame information for rev 48

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

Line No. Rev Author Line
1 48 alirezamon
/**************************************
2
* Module: localparameter
3
* Date:2019-04-08
4
* Author: alireza
5
*
6
* Description:
7
***************************************/
8
 `ifdef     INCLUDE_TOPOLOGY_LOCALPARAM
9
 
10
     //MESH, TORUS Topology p=5           
11
    localparam    LOCAL   =   0,
12
                  EAST    =   1,
13
                  NORTH   =   2,
14
                  WEST    =   3,
15
                  SOUTH   =   4;
16
 
17
 
18
 
19
    //LINE RING Topology p=3           
20
    localparam  FORWARD =  1,
21
                BACKWARD=  2;
22
 
23
 
24
 
25
     function automatic integer log2;
26
      input integer number; begin
27
         log2=(number <=1) ? 1: 0;
28
         while(2**log2<number) begin
29
            log2=log2+1;
30
         end
31
      end
32
    endfunction // log2 
33
 
34
     function automatic integer powi; // x^y
35
        input integer x,y;
36
        integer i;begin //compute x to the y
37
        powi=1;
38
        for (i = 0; i <y; i=i+1 ) begin
39
            powi=powi * x;
40
        end
41
        end
42
    endfunction // powi
43
 
44
 
45
    function automatic integer  sum_powi;//x^(y-1) + x^(y-2) + ...+ 1;
46
        input integer x,y;
47
        integer i;begin
48
        sum_powi = 0;
49
        for (i = 0; i < y; i=i+1)begin
50
            sum_powi = sum_powi + powi( x, i );
51
       end
52
    end
53
    endfunction // sum_powi
54
 
55
 
56
    // get the port num and return the port located at streight direction. If there is no strieght port return  router_port_num. 
57
    function automatic integer strieght_port;
58
        input integer router_port_num;  //router port num
59
        input integer current_port;
60
        begin
61
        /* verilator lint_off WIDTH */
62
        if(TOPOLOGY == "MESH" || TOPOLOGY == "FMESH" || TOPOLOGY == "TORUS") begin
63
        /* verilator lint_on WIDTH */
64
            strieght_port =
65
                (current_port== EAST)?  WEST:
66
                (current_port== WEST)?  EAST:
67
                (current_port== SOUTH)? NORTH:
68
                (current_port== NORTH)? SOUTH:
69
                                 router_port_num; //DISABLED;
70
        end
71
        /* verilator lint_off WIDTH */
72
        else if (TOPOLOGY ==  "RING" || TOPOLOGY ==  "LINE") begin
73
        /* verilator lint_on WIDTH */
74
            strieght_port =
75
                (current_port== FORWARD )? BACKWARD:
76
                (current_port== BACKWARD)? FORWARD:
77
                                           router_port_num; //DISABLED;
78
 
79
        end
80
        /* verilator lint_off WIDTH */
81
        else if (TOPOLOGY == "FATTREE" ) begin
82
        /* verilator lint_on WIDTH */
83
             if(router_port_num[0]==1'b0) begin //even port num
84
                 strieght_port =   (current_port < (router_port_num/2) )?
85
                    (router_port_num/2)+ current_port :
86
                    current_port - (router_port_num/2);
87
             end else begin
88
                 strieght_port =  (current_port == (router_port_num-1)/2) ?  router_port_num: //DISABLED;
89
                                  (current_port < ((router_port_num+1)/2))? ((router_port_num+1)/2)+ current_port :
90
                                                                            current_port - ((router_port_num+1)/2);
91
 
92
             end
93
        end else begin
94
            strieght_port = router_port_num; //DISABLED;
95
        end
96
        end
97
    endfunction
98
 
99
 
100
    function automatic integer port_buffer_size;
101
        input integer router_port_num;  //router port num
102
        begin
103
        port_buffer_size = B;
104
        /* verilator lint_off WIDTH */
105
        if(TOPOLOGY == "MESH" || TOPOLOGY == "FMESH" || TOPOLOGY == "TORUS" || TOPOLOGY ==  "RING" || TOPOLOGY ==  "LINE")begin
106
        /* verilator lint_on WIDTH */
107
           if (router_port_num == 0 || router_port_num > 4 ) port_buffer_size = LB;
108
        end
109
        end
110
    endfunction
111
 
112
 
113
/*******************
114
*   "RING"  "LINE"  "MESH" TORUS" "FMESH"
115
******************/
116
 
117
 
118
/* verilator lint_off WIDTH */
119
//route type
120
localparam
121
    NX = T1,
122
    NY = T2,
123
    NL = T3,
124
    NXw = log2(NX),
125
    NYw= log2(NY),
126
    NLw= log2(NL),
127
    PPSw_MESH_TORI =4, //port presel width for adaptive routing
128
 
129
    /* verilator lint_off WIDTH */
130
    ROUTE_TYPE_MESH_TORI = (ROUTE_NAME == "XY" || ROUTE_NAME == "TRANC_XY" )?    "DETERMINISTIC" :
131
                               (ROUTE_NAME == "DUATO" || ROUTE_NAME == "TRANC_DUATO" )?   "FULL_ADAPTIVE": "PAR_ADAPTIVE",
132
 
133
    R2R_CHANELS_MESH_TORI=  (TOPOLOGY=="RING" || TOPOLOGY=="LINE")? 2 : 4,
134
    R2E_CHANELS_MESH_TORI= NL,
135
    RAw_MESH_TORI = ( TOPOLOGY == "RING" || TOPOLOGY == "LINE")? NXw : NXw + NYw,
136
    EAw_MESH_TORI = (NL==1) ? RAw_MESH_TORI : RAw_MESH_TORI + NLw,
137
    NR_MESH_TORI = (TOPOLOGY=="RING" || TOPOLOGY=="LINE")? NX : NX*NY,
138
    NE_MESH_TORI = NR_MESH_TORI * NL,
139
    MAX_P_MESH_TORI = R2R_CHANELS_MESH_TORI + R2E_CHANELS_MESH_TORI,
140
    DSTPw_MESH_TORI =   R2R_CHANELS_MESH_TORI; // P-1
141
    /* verilator lint_on WIDTH */
142
 
143
/****************
144
 *  FMESH
145
 * *************/
146
 localparam
147
    NE_FMESH = NE_MESH_TORI + 2 * (NX+NY),
148
    NR_FMESH = NR_MESH_TORI,
149
    MAX_P_FMESH = 4 + NL,
150
    EAw_FMESH = RAw_MESH_TORI + log2(MAX_P_FMESH);
151
 
152
 
153
 
154
 
155
 
156
 
157
 
158
 /******************
159
  *     FATTREE
160
  * *****************/
161
localparam
162
    K=T1,
163
    L=T2,
164
    Lw=log2(L),
165
    Kw=log2(K),
166
    LKw=L*Kw,
167
    RAw_FATTREE =  LKw + Lw,
168
    EAw_FATTREE  = LKw,
169
    NE_FATTREE = powi( K,L ),
170
    NR_FATTREE = L * powi( K , L - 1 ),  // total number of routers  
171
    ROUTE_TYPE_FATTREE = "DETERMINISTIC",
172
    DSTPw_FATTREE = K+1,
173
    MAX_P_FATTREE = 2*K;
174
 
175
 
176
 
177
/**********************
178
 *      TREE
179
 * ********************/
180
localparam
181
    ROUTE_TYPE_TREE = "DETERMINISTIC",
182
    NE_TREE = powi( K,L ),  //total number of endpoints
183
    NR_TREE = sum_powi ( K,L ),  // total number of routers  
184
    RAw_TREE =  LKw + Lw,
185
    EAw_TREE  =  LKw,
186
    DSTPw_TREE = log2(K+1),
187
    MAX_P_TREE = K+1;
188
 
189
 
190
/*********************
191
 *  STAR
192
 * ******************/
193
  localparam
194
    ROUTE_TYPE_STAR = "DETERMINISTIC",
195
    NE_STAR = T1,  //total number of endpoints
196
    NR_STAR = 1,  // total number of routers  
197
    RAw_STAR = 1,
198
    EAw_STAR  =  log2(NE_STAR),
199
    DSTPw_STAR = EAw_STAR,
200
    MAX_P_STAR = NE_STAR;
201
 
202
 /************************
203
  *  CUSTOM - made by netmaker
204
  * **********************/
205
 localparam
206
    ROUTE_TYPE_CUSTOM = "DETERMINISTIC",
207
    NE_CUSTOM  = T1,  //total number of endpoints
208
    NR_CUSTOM  = T2,  // total number of routers  
209
    EAw_CUSTOM = log2(NE_CUSTOM),
210
    RAw_CUSTOM = log2(NR_CUSTOM),
211
    MAX_P_CUSTOM = T3,
212
    DSTPw_CUSTOM = log2(MAX_P_CUSTOM);
213
 
214
 
215
    /* verilator lint_off WIDTH */
216
    localparam
217
        PPSw = PPSw_MESH_TORI,
218
        // maximum number of port in a router in the topology
219
        MAX_P =
220
            (TOPOLOGY == "FATTREE")? MAX_P_FATTREE:
221
            (TOPOLOGY == "TREE")?  MAX_P_TREE:
222
            (TOPOLOGY == "RING" || TOPOLOGY == "LINE" || TOPOLOGY == "MESH" || TOPOLOGY == "TORUS")? MAX_P_MESH_TORI:
223
            (TOPOLOGY == "FMESH")? MAX_P_MESH_TORI:
224
            (TOPOLOGY == "STAR") ? MAX_P_STAR:
225
            MAX_P_CUSTOM,
226
 
227
        // destination port width in header flit           
228
        DSTPw =
229
         //   (CAST_TYPE!= "UNICAST")? MAX_P: // Each asserted bit indicats that the flit should be sent to that port
230
            (TOPOLOGY == "FATTREE")? DSTPw_FATTREE:
231
            (TOPOLOGY == "TREE")?  DSTPw_TREE:
232
            (TOPOLOGY == "RING" || TOPOLOGY == "LINE" || TOPOLOGY == "MESH" || TOPOLOGY == "TORUS")? DSTPw_MESH_TORI:
233
            (TOPOLOGY == "FMESH")? DSTPw_MESH_TORI:
234
            (TOPOLOGY == "STAR") ? DSTPw_STAR:
235
            DSTPw_CUSTOM,
236
        //router address width        
237
        RAw =
238
            (TOPOLOGY == "FATTREE")? RAw_FATTREE:
239
            (TOPOLOGY == "TREE")?  RAw_TREE:
240
            (TOPOLOGY == "RING" || TOPOLOGY == "LINE" || TOPOLOGY == "MESH" || TOPOLOGY == "TORUS")? RAw_MESH_TORI:
241
            (TOPOLOGY == "FMESH")? RAw_MESH_TORI:
242
            (TOPOLOGY == "STAR") ? RAw_STAR:
243
            RAw_CUSTOM,
244
        //endpoint address width
245
        EAw =
246
            (TOPOLOGY == "FATTREE")? EAw_FATTREE:
247
            (TOPOLOGY == "TREE")?  EAw_TREE:
248
            (TOPOLOGY == "RING" || TOPOLOGY == "LINE" || TOPOLOGY == "MESH" || TOPOLOGY == "TORUS")? EAw_MESH_TORI:
249
            (TOPOLOGY == "FMESH")? EAw_FMESH:
250
            (TOPOLOGY == "STAR") ? EAw_STAR:
251
            EAw_CUSTOM,
252
        // total number of endpoints         
253
        NE =
254
            (TOPOLOGY == "FATTREE")? NE_FATTREE:
255
            (TOPOLOGY == "TREE")?  NE_TREE:
256
            (TOPOLOGY == "RING" || TOPOLOGY == "LINE" || TOPOLOGY == "MESH" || TOPOLOGY == "TORUS")? NE_MESH_TORI:
257
            (TOPOLOGY == "FMESH")? NE_FMESH:
258
            (TOPOLOGY == "STAR")? NE_STAR:
259
            NE_CUSTOM,
260
        //total number of routers        
261
        NR =
262
            (TOPOLOGY == "FATTREE")? NR_FATTREE:
263
            (TOPOLOGY == "TREE")?  NR_TREE:
264
            (TOPOLOGY == "RING" || TOPOLOGY == "LINE" || TOPOLOGY == "MESH" || TOPOLOGY == "TORUS")? NR_MESH_TORI:
265
            (TOPOLOGY == "FMESH")? NR_FMESH:
266
            (TOPOLOGY == "STAR") ? NR_STAR:
267
            NR_CUSTOM,
268
        //routing algorithm type    
269
        ROUTE_TYPE =
270
            (TOPOLOGY == "FATTREE")? ROUTE_TYPE_FATTREE:
271
            (TOPOLOGY == "TREE")?  ROUTE_TYPE_TREE:
272
            (TOPOLOGY == "RING" || TOPOLOGY == "LINE" || TOPOLOGY == "MESH" || TOPOLOGY == "TORUS")? ROUTE_TYPE_MESH_TORI:
273
            (TOPOLOGY == "FMESH")? ROUTE_TYPE_MESH_TORI:
274
            (TOPOLOGY == "STAR") ? ROUTE_TYPE_STAR:
275
            ROUTE_TYPE_CUSTOM;
276
 
277
    /* verilator lint_on WIDTH */
278
 
279
 
280
 
281
 
282
 
283
 `endif
284
 
285
 

powered by: WebSVN 2.1.0

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