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_synfull/] [synfull_top.sv] - Blame information for rev 54

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

Line No. Rev Author Line
1 54 alirezamon
// synthesis translate_off
2
`timescale   1ns/1ns
3
 
4
 
5
module synfull_top;
6
 
7
    import pronoc_pkg::*;
8
    import dpi_int_pkg::*;
9
 
10
    reg     reset ,clk;
11
    reg print_router_st;
12
 
13
    initial begin
14
        clk = 1'b0;
15
        forever clk = #10 ~clk;
16
    end
17
 
18
 
19
    smartflit_chanel_t chan_in_all  [NE-1 : 0];
20
    smartflit_chanel_t chan_out_all [NE-1 : 0];
21
    router_event_t router_event [NR-1 : 0] [MAX_P-1 : 0];
22
 
23
    pck_injct_t pck_injct_in [NE-1 : 0];
24
    pck_injct_t _pck_injct_in [NE-1 : 0];
25
    pck_injct_t pck_injct_out[NE-1 : 0];
26
 
27
    logic [NE-1 : 0] NE_ready_all    ;
28
    logic [NE-1 : 0] init_socket     ;
29
    logic [NE-1 : 0] wakeup_synfull  ;
30
    logic [NE-1 : 0] end_injection   ;
31
    logic            end_synfull     ;
32
 
33
    req_t     [NE-1 : 0] synfull_pronoc_req_all  ;
34
    deliver_t [NE-1 : 0] pronoc_synfull_del_all  ;
35
 
36
    noc_top     the_noc
37
    (
38
        .reset(reset),
39
        .clk(clk),
40
        .chan_in_all(chan_in_all),
41
        .chan_out_all(chan_out_all),
42
        .router_event(router_event)
43
    );
44
 
45
 
46
    top_dpi_interface synfull (
47
        .clk_i(clk), .rst_i(reset),
48
        .init_i                     (init_socket[0]         ),
49
        .startCom_i                 (wakeup_synfull[0]      ),
50
        .pronoc_synfull_del_all_i   (pronoc_synfull_del_all ),
51
        .synfull_pronoc_req_all_o   (synfull_pronoc_req_all ),
52
        .NE_ready_all_i             (NE_ready_all           ),
53
        .endCom_o                   (end_injection[0]       )
54
    );
55
 
56
 
57
    reg [NEw-1 : 0] dest_id [NE-1 : 0];
58
    wire [NEw-1: 0] current_e_addr [NE-1 : 0];
59
 
60
    reg [63 : 0]  total_sent_pck_count;
61
    reg [63 : 0]  total_sent_flit_count;
62
    reg [63 : 0]  total_rsv_pck_count;
63
    reg [63 : 0]  total_rsv_flit_count;
64
    reg [63 : 0]  total_queued_pck_count;
65
    reg [63 : 0]  clk_count;
66
 
67
 
68
 
69
    initial begin
70
 
71
                //print_parameter
72
        display_noc_parameters();
73
                $display ("Simulation parameters-------------");
74
                if(DEBUG_EN)
75
                        $display ("\tDebuging is enabled");
76
                else
77
                        $display ("\tDebuging is disabled");
78
 
79
 
80
 
81
        end//initial
82
 
83
 
84
 
85
        wire [31:0] fifo_id [NE-1 : 0];
86
        wire [PCK_SIZw-1 : 0]  fifo_size [NE-1 :0];
87
    wire [NEw-1 : 0] fifo_dest [NE-1 : 0];
88
    wire [NE-1 : 0] fifo_wr,fifo_rd ,fifo_full,fifo_not_empty;
89
 
90
    genvar i;
91
    generate
92
    for(i=0; i< NE; i=i+1) begin
93
 
94
        assign fifo_wr[i] =
95
                (pck_injct_out[i].ready == 1'b0 &&  synfull_pronoc_req_all[i].valid==1'b1) ||
96
                (fifo_not_empty[i]==1'b1  &&  synfull_pronoc_req_all[i].valid==1'b1);
97
 
98
 
99
        assign fifo_rd[i] =
100
                (pck_injct_out[i].ready == 1'b1 && fifo_not_empty[i]==1'b1 );
101
 
102
 
103
            fwft_fifo_bram #(
104
                        .DATA_WIDTH(32+PCK_SIZw+NEw),
105
                        .MAX_DEPTH(1000000),
106
                        .IGNORE_SAME_LOC_RD_WR_WARNING("NO")
107
                )
108
                fifo
109
                (
110
                        .din({synfull_pronoc_req_all[i].id,synfull_pronoc_req_all[i].size,synfull_pronoc_req_all[i].dest}),     // Data in
111
                        .wr_en(fifo_wr[i]),   // Write enable
112
                        .rd_en(fifo_rd[i]),   // Read the next word
113
                        .dout({fifo_id[i],fifo_size[i],fifo_dest[i]}),    // Data out
114
                        .full( fifo_full[i]),
115
                        .nearly_full(),
116
                        .recieve_more_than_0(fifo_not_empty[i]),
117
                        .recieve_more_than_1(),
118
                        .reset(reset),
119
                        .clk (clk)
120
 
121
                );
122
 
123
 
124
 
125
 
126
 
127
        //from synfull
128
        assign pck_injct_in[i].data = (fifo_not_empty[i])?  fifo_id[i] : synfull_pronoc_req_all[i].id;
129
        assign pck_injct_in[i].size = (fifo_not_empty[i])?  fifo_size[i] : synfull_pronoc_req_all[i].size;
130
        assign pck_injct_in[i].pck_wr =  (fifo_not_empty[i])?   fifo_rd[i] :  (  synfull_pronoc_req_all[i].valid & pck_injct_out[i].ready == 1'b1);
131
        assign pck_injct_in[i].ready = 1'b1;
132
        assign dest_id[i] =(fifo_not_empty[i])? fifo_dest[i] : synfull_pronoc_req_all[i].dest;
133
 
134
        //to synfull
135
        assign pronoc_synfull_del_all[i].id    = pck_injct_out[i].data   ;
136
        assign pronoc_synfull_del_all[i].valid = pck_injct_out[i].pck_wr ;
137
        assign NE_ready_all[i] = 1'b1 ; //pck_injct_out[i].ready;
138
 
139
        assign pck_injct_in[i].class_num = _pck_injct_in[i].class_num;
140
        assign pck_injct_in[i].init_weight = _pck_injct_in[i].init_weight;
141
        assign pck_injct_in[i].vc = _pck_injct_in[i].vc;
142
 
143
 
144
        endp_addr_encoder #( .TOPOLOGY(TOPOLOGY), .T1(T1), .T2(T2), .T3(T3), .EAw(EAw),  .NE(NE)) encode1 ( .id(i[NEw-1 :0]), .code(current_e_addr[i]));
145
 
146
        packet_injector pck_inj(
147
            //general
148
            .current_e_addr(current_e_addr[i]),
149
            .reset(reset),
150
            .clk(clk),
151
            //noc port
152
            .chan_in(chan_out_all[i]),
153
            .chan_out(chan_in_all[i]),
154
            //control interafce
155
            .pck_injct_in(pck_injct_in[i]),
156
            .pck_injct_out(pck_injct_out[i])
157
        );
158
 
159
 
160
        endp_addr_encoder #( .TOPOLOGY(TOPOLOGY), .T1(T1), .T2(T2), .T3(T3), .EAw(EAw),  .NE(NE)) encode2 ( .id(dest_id[i]), .code(pck_injct_in[i].endp_addr));
161
 
162
 
163
       reg [31:0]k;
164
 
165
 
166
 
167
 
168
        initial begin
169
            reset = 1'b1;
170
            k=0;
171
            init_socket[i] = 1'b0;
172
            wakeup_synfull[i] = 1'b0;
173
            print_router_st=1'b0;
174
 
175
            @(posedge clk) #1;
176
            _pck_injct_in[i].class_num=0;
177
            _pck_injct_in[i].init_weight=1;
178
            _pck_injct_in[i].vc=1;
179
            #100
180
            @(posedge clk) #1;
181
            reset=1'b0;
182
            #100
183
            init_socket[i] = 1'b1;
184
            @(posedge clk) #1;
185
            init_socket[i] = 1'b0;
186
            #100
187
            wakeup_synfull[i] = 1'b1;
188
            @(posedge clk) #1;
189
            while (!end_injection[0]) @(posedge clk) #1;
190
            // if(i==0) $display ( "All packet are sent. We wait for NoC to be ideal now");
191
            // while (total_sent_pck_count != total_rsv_pck_count) @(posedge clk) #1;
192
            print_router_st=1;
193
            #1
194
            $display ( "Statistics:");
195
            $display ( "\t simulation clk count = %d",   clk_count);
196
            $display ( "\t Total queued packets = %d",total_queued_pck_count);
197
            $display ( "\t Total sent packets = %d", total_sent_pck_count);
198
                        $display ( "\t Total sent flits = %d",   total_sent_flit_count);
199
                        $display ( "\t Total received packets = %d", total_rsv_pck_count);
200
                        $display ( "\t Total received flits = %d",       total_rsv_flit_count);
201
 
202
 
203
            $finish;
204
        end
205
 
206
        always @(posedge clk) begin
207
                        if(pck_injct_out[i].pck_wr) begin
208
                                $display ("%t:pck_inj(%d) got a packet: source=%d, size=%d, data=%h",$time,i,
209
                                pck_injct_out[i].endp_addr,pck_injct_out[i].size,pck_injct_out[i].data);
210
 
211
                        end
212
        end
213
 
214
 
215
    end//for
216
    endgenerate
217
 
218
    integer k;
219
 
220
    always @(posedge clk) begin
221
        if(reset) begin
222
                clk_count =0;
223
                total_sent_pck_count =0;
224
                total_sent_flit_count=0;
225
                total_rsv_pck_count  =0;
226
                total_rsv_flit_count =0;
227
                total_queued_pck_count = 0;
228
        end else begin
229
                clk_count++;
230
                for(k=0; k< NE; k=k+1) begin : endpoints
231
                        if(pck_injct_out[k].pck_wr) begin
232
                                total_rsv_pck_count++;
233
                                total_rsv_flit_count+=pck_injct_out[k].size;
234
                        end
235
                        if(pck_injct_in[k].pck_wr) begin
236
                                total_sent_pck_count++;
237
                                total_sent_flit_count+=pck_injct_in[k].size;
238
                        end
239
                        if(synfull_pronoc_req_all[k].valid) begin
240
                                total_queued_pck_count++;
241
                        end
242
                end
243
            end
244
 
245
    end
246
 
247
 
248
    routers_statistic_collector router_stat(
249
                .reset(reset),
250
                .clk(clk),
251
                .router_event(router_event),
252
                .print(print_router_st)
253
        );
254
 
255
 
256
 
257
endmodule
258
// synthesis translate_on
259
 

powered by: WebSVN 2.1.0

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