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/] [tree_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
`timescale 1ns / 1ps
2
 
3
/**************************************
4
 * Module: tree
5
 * Date:2019-01-01
6
 * Author: alireza
7
 *
8
 *
9
Description:
10
 
11
    Tree
12
 
13
 ***************************************/
14
 
15
 
16
module  tree_noc_top
17
                import pronoc_pkg::*;
18
        (
19
                reset,
20
                clk,
21
                chan_in_all,
22
                chan_out_all
23
        );
24
 
25
 
26
        input   clk,reset;
27
        //local ports
28
        input   smartflit_chanel_t chan_in_all  [NE-1 : 0];
29
        output  smartflit_chanel_t chan_out_all [NE-1 : 0];
30
 
31
        //all routers port
32
        smartflit_chanel_t    router_chan_in   [NR-1 :0][MAX_P-1 : 0];
33
        smartflit_chanel_t    router_chan_out  [NR-1 :0][MAX_P-1 : 0];
34
 
35
 
36
 
37
        function integer addrencode;
38
                input integer pos,k,n,kw;
39
                integer pow,i,tmp;begin
40
                        addrencode=0;
41
                        pow=1;
42
                        for (i = 0; i 
43
                                tmp=(pos/pow);
44
                                tmp=tmp%k;
45
                                tmp=tmp<
46
                                addrencode=addrencode | tmp;
47
                                pow=pow * k;
48
                        end
49
                end
50
        endfunction
51
 
52
        localparam
53
                PV = V * MAX_P,
54
                PFw = MAX_P * Fw,
55
                NEFw = NE * Fw,
56
                NEV = NE * V,
57
                CONG_ALw = CONGw * MAX_P,
58
                PLKw = MAX_P * LKw,
59
                PLw = MAX_P * Lw,
60
                PRAw = MAX_P * RAw; // {layer , Pos} width
61
 
62
 
63
 
64
 
65
 
66
 
67
        wire [LKw-1 : 0] current_pos_addr [NR-1 :0];
68
        wire [Lw-1  : 0] current_layer_addr [NR-1 :0];
69
        wire [RAw-1 : 0] current_r_addr [NR-1 : 0];
70
 
71
 
72
 
73
 
74
        //add root
75
 
76
        localparam [Lw-1 : 0] ROOT_L = L-1;
77
        localparam ROOT_ID = 0;
78
 
79
        assign current_layer_addr [ROOT_ID] = ROOT_L;
80
        assign current_pos_addr [ROOT_ID] = {LKw{1'b0}};
81
        assign current_r_addr[ROOT_ID] = {current_layer_addr [ROOT_ID],current_pos_addr[ROOT_ID]};
82
 
83
 
84
        router_top # (
85
                        .P(K)
86
                )
87
                root_router
88
                (
89
                        .current_r_addr  (current_r_addr [ROOT_ID]),
90
                        .chan_in         (router_chan_in [ROOT_ID][K-1:0]),
91
                        .chan_out        (router_chan_out[ROOT_ID][K-1:0]),
92
                        .clk             (clk            ),
93
                        .reset           (reset          )
94
                );
95
 
96
 
97
        genvar pos,level;
98
 
99
 
100
        //add leaves
101
        generate
102
                for( level=1; level
103
                        localparam NPOS1 = powi(K,level); // number of routers in this level
104
                        localparam NRATTOP1 = sum_powi ( K,level); // number of routers at top levels : from root until last level
105
                        for( pos=0; pos
106
 
107
                                router_top # (
108
                                                .P(K+1)// leaves have K+1 port number
109
                                        )
110
                                        the_router
111
                                        (
112
                                                .current_r_addr  (current_r_addr [NRATTOP1+pos]),
113
                                                .chan_in         (router_chan_in [NRATTOP1+pos]),
114
                                                .chan_out        (router_chan_out[NRATTOP1+pos]),
115
                                                .clk             (clk            ),
116
                                                .reset           (reset          )
117
                                        );
118
 
119
                        end//pos
120
                end // level
121
 
122
 
123
                //connect all up connections
124
                for (level = 1; level
125
                        localparam  NPOS = powi(K,level); // number of routers in this level
126
                        localparam L1 = L-1-level;
127
                        localparam level2= level - 1;
128
                        localparam L2 = L-1-level2;
129
                        for ( pos = 0; pos < NPOS; pos=pos+1 ) begin : pos_c
130
 
131
                                localparam ID1 = sum_powi ( K,level) + pos;
132
                                localparam FATTREE_EQ_POS1 = pos*(K**L1);
133
                                localparam ADR_CODE1=addrencode(FATTREE_EQ_POS1,K,L,Kw);
134
                                localparam POS2 = pos /K ;
135
                                localparam ID2 = sum_powi ( K,level-1) + (pos/K);
136
                                localparam PORT2= pos % K;
137
                                localparam FATTREE_EQ_POS2 = POS2*(K**L2);
138
                                localparam ADR_CODE2=addrencode(FATTREE_EQ_POS2,K,L,Kw);
139
 
140
                                // node_connection('Router[id1][k] to router[id2][pos%k];
141
                                assign  router_chan_in [ID1][K] = router_chan_out [ID2][PORT2];
142
                                assign  router_chan_in [ID2][PORT2] = router_chan_out [ID1][K];
143
 
144
                                assign current_layer_addr [ID1] = L1[Lw-1 : 0];
145
                                assign current_pos_addr [ID1] = ADR_CODE1 [LKw-1 : 0];
146
                                assign current_r_addr [ID1] = {current_layer_addr [ID1],current_pos_addr[ID1]};
147
 
148
 
149
                        end// pos
150
 
151
                end //level
152
 
153
 
154
                // connect endpoints
155
 
156
                for ( pos = 0; pos <  NE; pos=pos+1 ) begin : endpoints
157
                        //  node_connection T[pos] R[rid][pos %k];
158
                        localparam RID= sum_powi(K,L-1)+(pos/K);
159
                        localparam RPORT = pos%K;
160
 
161
                        //$dotfile=$dotfile.node_connection('T',$i,undef,undef,'R',$r,undef,$i%($k));
162
                        assign router_chan_in [RID][RPORT] =    chan_in_all [pos];
163
                        assign chan_out_all [pos] = router_chan_out [RID][RPORT];
164
 
165
                end
166
        endgenerate
167
 
168
 
169
endmodule

powered by: WebSVN 2.1.0

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