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/] [fattree_noc_top.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
// synthesis translate_off
2
`timescale 1ns / 1ps
3
// synthesis translate_on
4
 
5
/**************************************
6
* Module: fattree
7
* Date:2019-01-01
8
* Author: alireza
9
*
10
*
11
Description:
12
 
13
    FatTree
14
 
15
      Each level of the hierarchical indirect Network has
16
      k^(l-1) Routers. The Routers are organized such that
17
      each node has k descendents, and each parent is
18
      replicated k  times.
19
      most routers has 2K ports, excep the top level has only K
20
 
21
***************************************/
22
 
23
 
24
module  fattree_noc_top
25
                import pronoc_pkg::*;
26
        (
27
 
28
                reset,
29
                clk,
30
                chan_in_all,
31
                chan_out_all
32
        );
33
 
34
 
35
        input   clk,reset;
36
        //local ports
37
        input   smartflit_chanel_t chan_in_all  [NE-1 : 0];
38
        output  smartflit_chanel_t chan_out_all [NE-1 : 0];
39
 
40
 
41
        //all routers port
42
        smartflit_chanel_t    router_chan_in   [NR-1 :0][MAX_P-1 : 0];
43
        smartflit_chanel_t    router_chan_out  [NR-1 :0][MAX_P-1 : 0];
44
 
45
 
46
 
47
                localparam
48
                        PV = V * MAX_P,
49
                        PFw = MAX_P * Fw,
50
                        NRL= NE/K, //number of router in  each layer
51
                        NEFw = NE * Fw,
52
                        NEV = NE * V,
53
                        CONG_ALw = CONGw * MAX_P,
54
                        PLKw = MAX_P * LKw,
55
                        PLw = MAX_P * Lw,
56
                        PRAw = MAX_P * RAw; // {layer , Pos} width
57
 
58
  function integer addrencode;
59
        input integer pos,k,n,kw;
60
        integer pow,i,tmp;begin
61
        addrencode=0;
62
        pow=1;
63
        for (i = 0; i 
64
            tmp=(pos/pow);
65
            tmp=tmp%k;
66
            tmp=tmp<
67
            addrencode=addrencode | tmp;
68
            pow=pow * k;
69
        end
70
        end
71
    endfunction
72
 
73
    wire [LKw-1 : 0] current_pos_addr [NR-1 :0];
74
    wire [Lw-1  : 0] current_layer_addr [NR-1 :0];
75
    wire [RAw-1 : 0] current_r_addr [NR-1 : 0];
76
 
77
//add roots
78
 
79
genvar pos,level,port;
80
 
81
 
82
 
83
generate
84
for( pos=0; pos
85
 
86
          router_top # (
87
               .P(K)
88
      )
89
      the_router
90
      (
91
                .current_r_addr  (current_r_addr [pos]),
92
                .chan_in         (router_chan_in [pos][K-1 : 0]),
93
                .chan_out        (router_chan_out[pos][K-1 : 0]),
94
                .clk             (clk            ),
95
                .reset           (reset          )
96
      );
97
 
98
 
99
end
100
 
101
//add leaves
102
 
103
for( level=1; level
104
   for( pos=0; pos
105
 
106
        router_top # (
107
                        .P(2*K)
108
                )
109
                the_router
110
                (
111
                        .current_r_addr  (current_r_addr [NRL*level+pos]),
112
                        .chan_in         (router_chan_in [NRL*level+pos]),
113
                        .chan_out        (router_chan_out[NRL*level+pos]),
114
                        .clk             (clk            ),
115
                        .reset           (reset          )
116
                );
117
 
118
    end
119
end
120
 
121
 
122
//connect all down input chanels
123
localparam NPOS = powi( K, L-1);
124
localparam CHAN_PER_DIRECTION = (K * powi( L , L-1 )); //up or down
125
localparam CHAN_PER_LEVEL = 2*(K * powi( K , L-1 )); //up+down
126
 
127
for (level = 0; level
128
/* verilator lint_off WIDTH */
129
    localparam [Lw-1 : 0] LEAVE_L = L-1-level;
130
/* verilator lint_on WIDTH */
131
    //input chanel are numbered interleavely, the interleaev depends on level
132
    localparam ROUTERS_PER_NEIGHBORHOOD = powi(K,L-1-(level));
133
    localparam ROUTERS_PER_BRANCH = powi(K,L-1-(level+1));
134
    localparam LEVEL_OFFSET = ROUTERS_PER_NEIGHBORHOOD*K;
135
    for ( pos = 0; pos < NPOS; pos=pos+1 ) begin : pos_c
136
        localparam ADRRENCODED=addrencode(pos,K,L,Kw);
137
        localparam NEIGHBORHOOD = (pos/ROUTERS_PER_NEIGHBORHOOD);
138
        localparam NEIGHBORHOOD_POS = pos % ROUTERS_PER_NEIGHBORHOOD;
139
        for ( port = 0; port < K; port=port+1 ) begin : port_c
140
            localparam LINK =
141
                ((level+1)*CHAN_PER_LEVEL - CHAN_PER_DIRECTION)  //which levellevel
142
                +NEIGHBORHOOD* LEVEL_OFFSET   //region in level
143
                +port*ROUTERS_PER_BRANCH*K //sub region in region
144
                +(NEIGHBORHOOD_POS)%ROUTERS_PER_BRANCH*K //router in subregion
145
                +(NEIGHBORHOOD_POS)/ROUTERS_PER_BRANCH; //port on router
146
 
147
 
148
            localparam L2= (LINK+CHAN_PER_DIRECTION)/CHAN_PER_LEVEL;
149
            localparam POS2 = ((LINK+CHAN_PER_DIRECTION) % CHAN_PER_LEVEL)/K;
150
            localparam PORT2= (((LINK+CHAN_PER_DIRECTION) % CHAN_PER_LEVEL)  %K)+K;
151
            localparam ID1 =NRL*level+pos;
152
            localparam ID2 =NRL*L2 + POS2;
153
            localparam POS_ADR_CODE2= addrencode(POS2,K,L,Kw);
154
            localparam POS_ADR_CODE1= addrencode(pos,K,L,Kw);
155
 
156
 
157
           // $dotfile=$dotfile.node_connection('R',$id1,undef,$port,'R',$connect_id,undef,$connect_port);
158
                assign  router_chan_in [ID1][port ] = router_chan_out [ID2][PORT2];
159
                        assign  router_chan_in [ID2][PORT2] = router_chan_out [ID1][port ];
160
 
161
            assign current_layer_addr [ID1] = LEAVE_L;
162
            assign current_pos_addr [ID1] = ADRRENCODED[LKw-1 :0];
163
            assign current_r_addr [ID1] = {current_layer_addr [ID1],current_pos_addr[ID1]};
164
 
165
                        if(level==L-2)begin
166
                                 assign current_layer_addr [ID2] ={Lw{1'b0}};
167
                 assign current_pos_addr [ID2] = POS_ADR_CODE2[LKw-1 :0];
168
                 assign current_r_addr [ID2] = {current_layer_addr [ID2],current_pos_addr[ID2]};
169
                        end
170
 
171
 
172
         end
173
    end
174
end
175
 
176
 
177
 
178
 for ( pos = 0; pos <  NE; pos=pos+1 ) begin : endpoints
179
    localparam RID= NRL*(L-1)+(pos/K);
180
    localparam RPORT = pos%K;
181
 
182
     //$dotfile=$dotfile.node_connection('T',$i,undef,undef,'R',$r,undef,$i%($k));
183
 
184
            assign router_chan_in [RID][RPORT] =    chan_in_all [pos];
185
            assign chan_out_all [pos] = router_chan_out [RID][RPORT];
186
 
187
 
188
 end
189
 endgenerate
190
 
191
 
192
endmodule
193
 
194
 
195
 
196
 

powered by: WebSVN 2.1.0

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