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 56

Details | Compare with Previous | View Log

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

powered by: WebSVN 2.1.0

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