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/] [perl_gui/] [lib/] [perl/] [mpsoc_verilog_gen.pl] - Blame information for rev 28

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

Line No. Rev Author Line
1 16 alirezamon
 
2
 
3
use strict;
4
use warnings;
5
use mpsoc;
6
use soc;
7
use ip;
8
use ip_gen;
9
use Cwd;
10
use rvp;
11
 
12
 
13
 
14
sub mpsoc_generate_verilog{
15
        my $mpsoc=shift;
16 25 alirezamon
        my $mpsoc_name=$mpsoc->object_get_attribute('mpsoc_name');
17 16 alirezamon
        my $io_v="\tclk,\n\treset";
18
        my $io_def_v="
19
//IO
20
\tinput\tclk,reset;\n";
21
        my $param_as_in_v;
22 28 alirezamon
        # generate top 
23
        my $top_io="\t\t.clk(clk) ,\n\t\t.reset(reset_ored_jtag)";
24 16 alirezamon
 
25 28 alirezamon
 
26 16 alirezamon
        #generate socs_parameter
27
        my $socs_param= gen_socs_param($mpsoc);
28
 
29
        #generate noc_parameter
30 25 alirezamon
        my ($noc_param,$pass_param)=gen_noc_param_v($mpsoc);
31 16 alirezamon
 
32
        #generate the noc
33 28 alirezamon
        my $noc_v=gen_noc_v($pass_param);
34 16 alirezamon
 
35
        #generate socs
36 28 alirezamon
        my $socs_v=gen_socs_v($mpsoc,\$io_v,\$io_def_v,\$top_io);
37 16 alirezamon
 
38
        #functions
39
        my $functions=get_functions();
40
 
41
        my $mpsoc_v = (defined $param_as_in_v )? "module $mpsoc_name #(\n $param_as_in_v\n)(\n$io_v\n);\n": "module $mpsoc_name (\n$io_v\n);\n";
42
        add_text_to_string (\$mpsoc_v,$functions);
43
        add_text_to_string (\$mpsoc_v,$socs_param);
44
        add_text_to_string (\$mpsoc_v,$noc_param);
45
        add_text_to_string (\$mpsoc_v,$io_def_v);
46
        add_text_to_string (\$mpsoc_v,$noc_v);
47
        add_text_to_string (\$mpsoc_v,$socs_v);
48
        add_text_to_string (\$mpsoc_v,"\nendmodule\n");
49
 
50 28 alirezamon
        my $top_v = (defined $param_as_in_v )? "module ${mpsoc_name}_top #(\n $param_as_in_v\n)(\n$io_v\n);\n": "module ${mpsoc_name}_top (\n $io_v\n);\n";
51
        add_text_to_string (\$top_v,$socs_param);
52
        add_text_to_string (\$top_v,$io_def_v);
53
        add_text_to_string(\$top_v,"
54
// Allow software to remote reset/enable the cpu via jtag
55
 
56
        wire jtag_cpu_en, jtag_system_reset;
57
 
58
        jtag_system_en jtag_en (
59
                .cpu_en(jtag_cpu_en),
60
                .system_reset(jtag_system_reset)
61 16 alirezamon
 
62 28 alirezamon
        );
63
 
64
        wire reset_ored_jtag = reset | jtag_system_reset;
65
        wire processors_en_anded_jtag = processors_en & jtag_cpu_en;
66
 
67
        ${mpsoc_name} the_${mpsoc_name} (
68
 
69
$top_io
70
 
71
 
72
        );
73
 
74
endmodule
75
 
76
 
77
");
78
 
79
        #my $ins= gen_mpsoc_instance_v($mpsoc,$mpsoc_name,$param_pass_v);
80
 
81
        #add_text_to_string(\$top_v,$local_param_v_all."\n".$io_full_v_all);
82
        #add_text_to_string(\$top_v,$ins);
83
        return ($mpsoc_v,$top_v);
84 16 alirezamon
}
85
 
86
sub get_functions{
87
        my $p='
88
//functions
89
        function integer log2;
90
                input integer number; begin
91
                        log2=0;
92
                        while(2**log2<number) begin
93
                                log2=log2+1;
94
                        end
95
        end
96
        endfunction // log2
97
 
98
        function integer CORE_NUM;
99
                input integer x,y;
100
                begin
101
                        CORE_NUM = ((y * NX) +  x);
102
                end
103
        endfunction
104
 
105
 
106
 
107
        localparam      Fw      =   2+V+Fpay,
108 25 alirezamon
                                NC     =        (TOPOLOGY=="RING")? NX    :   NX*NY,    //number of cores
109 16 alirezamon
                                Xw      =   log2(NX),
110
                                Yw      =   log2(NY) ,
111
                                Cw      =   (C>1)? log2(C): 1,
112
                                NCw     =   log2(NC),
113
                                NCV     =   NC  * V,
114
                                NCFw    =   NC  * Fw;
115
        ';
116
 
117
        return $p;
118
 
119
 
120
 
121
}
122
 
123
 
124
sub  gen_socs_param{
125
        my $mpsoc=shift;
126
        my $socs_param="
127
//SOC parameters\n";
128 25 alirezamon
        my $nx= $mpsoc->object_get_attribute('noc_param',"NX");
129
    my $ny= $mpsoc->object_get_attribute('noc_param',"NY");
130 16 alirezamon
    my $processors_en=0;
131
    for (my $y=0;$y<$ny;$y++){
132
                for (my $x=0; $x<$nx;$x++){
133
                        my $tile=($nx*$y)+ $x;
134
                        my ($soc_name,$n,$soc_num)=$mpsoc->mpsoc_get_tile_soc_name($tile);
135
                        if(defined $soc_name) {
136
                                my $param=      gen_soc_param($mpsoc,$soc_name,$soc_num,$tile);
137
                                add_text_to_string(\$socs_param,$param);
138
                        }
139
        }}#x&y
140
        $socs_param="$socs_param \n";
141
        return $socs_param;
142
 
143
}
144
 
145
 
146
sub  gen_soc_param {
147
        my ($mpsoc,$soc_name,$soc_num,$tile)=@_;
148
        my $top=$mpsoc->mpsoc_get_soc($soc_name);
149
        my $setting=$mpsoc->mpsoc_get_tile_param_setting($tile);
150
        my %params;
151
        if ($setting eq 'Custom'){
152
                 %params= $top->top_get_custom_soc_param($tile);
153
        }else{
154
                 %params=$top->top_get_default_soc_param();
155
        }
156
        my $params="\n\t //Parameter setting for $soc_name  located in tile: $tile \n";
157
        foreach my $p (sort keys %params){
158
                        $params="$params\t localparam ${soc_name}_${soc_num}_$p=$params{$p};\n";
159
        }
160
 
161
 
162
 
163
        return $params;
164
}
165
 
166
 
167
sub gen_noc_param_v{
168
        my $mpsoc=shift;
169
        my $param_v="\n\n//NoC parameters\n";
170 25 alirezamon
        my $pass_param;
171
        my @params=$mpsoc->object_get_attribute_order('noc_param');
172 16 alirezamon
        foreach my $p (@params){
173 25 alirezamon
                my $val=$mpsoc->object_get_attribute('noc_param',$p);
174 16 alirezamon
                add_text_to_string (\$param_v,"\tlocalparam $p=$val;\n");
175 25 alirezamon
                add_text_to_string (\$pass_param,".$p($p),\n");
176
                #print "$p:$val\n";
177 16 alirezamon
 
178
        }
179 25 alirezamon
        my $class=$mpsoc->object_get_attribute('noc_param',"C");
180 16 alirezamon
        my $str;
181
        if( $class > 1){
182
                $str="CLASS_SETTING={";
183
                for (my $i=$class-1; $i>=0;$i--){
184
                        $str=($i==0)?  "${str}Cn_0};\n " : "${str}Cn_$i,";
185
                }
186
        }else {
187
                $str="CLASS_SETTING={V{1\'b1}};\n";
188
        }
189
        add_text_to_string (\$param_v,"\tlocalparam $str");
190 25 alirezamon
        add_text_to_string (\$pass_param,".CLASS_SETTING(CLASS_SETTING),\n");
191
        my $v=$mpsoc->object_get_attribute('noc_param',"V")-1;
192
        my $escape=$mpsoc->object_get_attribute('noc_param',"ESCAP_VC_MASK");
193
        if (! defined $escape){
194
                add_text_to_string (\$param_v,"\tlocalparam [$v :0] ESCAP_VC_MASK=1;\n");
195
                add_text_to_string (\$pass_param,".ESCAP_VC_MASK(ESCAP_VC_MASK),\n");
196
        }
197 16 alirezamon
        add_text_to_string (\$param_v," \tlocalparam  CVw=(C==0)? V : C * V;\n");
198 25 alirezamon
        add_text_to_string (\$pass_param,".CVw(CVw)\n");
199 16 alirezamon
 
200
 
201 25 alirezamon
        return ($param_v,$pass_param);
202 16 alirezamon
 
203
 
204
 
205
}
206
 
207
 
208
 
209
 
210
sub gen_noc_v{
211 28 alirezamon
        my $pass_param = shift;
212 16 alirezamon
 
213
        my $noc =  read_file("../src_noc/noc.v");
214
        my @noc_param=$noc->get_modules_parameters_not_local_order('noc');
215
 
216
 
217
        my $noc_v='
218
 
219
//NoC ports
220
        wire [Fw-1      :   0]  ni_flit_out                 [NC-1           :0];
221
        wire [NC-1      :   0]  ni_flit_out_wr;
222
        wire [V-1       :   0]  ni_credit_in                [NC-1           :0];
223
        wire [Fw-1      :   0]  ni_flit_in                  [NC-1           :0];
224
        wire [NC-1      :   0]  ni_flit_in_wr;
225
        wire [V-1       :   0]  ni_credit_out               [NC-1           :0];
226
        wire [NCFw-1    :   0]  flit_out_all;
227
        wire [NC-1      :   0]  flit_out_wr_all;
228
        wire [NCV-1     :   0]  credit_in_all;
229
        wire [NCFw-1    :   0]  flit_in_all;
230
        wire [NC-1      :   0]  flit_in_wr_all;
231
        wire [NCV-1     :   0]  credit_out_all;
232
        wire                                    noc_clk,noc_reset;
233
 
234
    ';
235
 
236
 
237
 
238
        $noc_v="$noc_v
239
//NoC\n \tnoc #(\n";
240
        my $i=0;
241
        foreach my $p (@noc_param){
242
                my $param=($i==0)?  "\t\t.$p($p)":",\n\t\t.$p($p)";
243
                $i=1;
244 28 alirezamon
                #add_text_to_string(\$noc_v,$param);                    
245 16 alirezamon
        }
246 28 alirezamon
        add_text_to_string(\$noc_v,"$pass_param\n\t)\n\tthe_noc\n\t(\n");
247 16 alirezamon
 
248
        my @ports= $noc->get_module_ports_order('noc');
249
        $i=0;
250
        foreach my $p (@ports){
251
                my $port;
252
                if($p eq 'reset' ){
253
                        $port=($i==0)?  "\t\t.$p(noc_reset)":",\n\t\t.$p(noc_reset)";
254
                }elsif( $p eq 'clk'){
255
                        $port=($i==0)?  "\t\t.$p(noc_clk)":",\n\t\t.$p(noc_clk)";
256
                }else {
257
                        $port=($i==0)?  "\t\t.$p($p)":",\n\t\t.$p($p)";
258
                }
259
                $i=1;
260
                add_text_to_string(\$noc_v,$port);
261
        }
262
        add_text_to_string(\$noc_v,"\n\t);\n\n");
263
 
264
add_text_to_string(\$noc_v,'
265
        clk_source  src         (
266
                .clk_in(clk),
267
                .clk_out(noc_clk),
268
                .reset_in(reset),
269
                .reset_out(noc_reset)
270
        );
271
');
272
 
273
 
274
 
275
 
276
add_text_to_string(\$noc_v,'
277
 
278
//NoC port assignment
279
  genvar x,y;
280
  generate
281
    for (x=0;   x<NX; x=x+1) begin :x_loop1
282
        for (y=0;   y<NY;   y=y+1) begin: y_loop1
283
                localparam IP_NUM   =   ((y * NX) +  x);
284
 
285
 
286
            assign  ni_flit_in      [IP_NUM] =   flit_out_all    [(IP_NUM+1)*Fw-1    : IP_NUM*Fw];
287
            assign  ni_flit_in_wr   [IP_NUM] =   flit_out_wr_all [IP_NUM];
288
            assign  credit_in_all   [(IP_NUM+1)*V-1 : IP_NUM*V]     =   ni_credit_out   [IP_NUM];
289
            assign  flit_in_all     [(IP_NUM+1)*Fw-1    : IP_NUM*Fw]    =   ni_flit_out     [IP_NUM];
290
            assign  flit_in_wr_all  [IP_NUM] =   ni_flit_out_wr  [IP_NUM];
291
            assign  ni_credit_in    [IP_NUM] =   credit_out_all  [(IP_NUM+1)*V-1 : IP_NUM*V];
292
 
293
 
294
 
295
 
296
 
297
        end
298
    end
299
endgenerate
300
 
301
'
302
);
303
 
304
 
305
 
306
 
307
 
308
 
309
 
310
 
311
 
312
 
313
 
314
 
315
 
316
 
317
 
318
 
319
 
320
 
321
 
322
 
323
        return $noc_v;
324
 
325
}
326
 
327
 
328
 
329
 
330
sub gen_socs_v{
331 28 alirezamon
        my ($mpsoc,$io_v_ref,$io_def_v,$top_io_ref)=@_;
332
 
333 16 alirezamon
        #generate loop
334
 
335
#       my $socs_v='
336
#       genvar x,y;    
337
#    
338
#    generate 
339
#    for (x=0;   x<NX; x=x+1) begin :x_loop1
340
#        for (y=0;   y<NY;   y=y+1) begin: y_loop1
341
#                localparam IP_NUM   =   CORE_NUM(x,y);'  ;     
342
 
343
 
344
 
345
#       my @socs= $mpsoc->mpsoc_get_soc_list();
346
#       foreach my $soc (@socs){
347
 
348
#       #tile num condition
349
#               my @tiles= $mpsoc->mpsoc_get_soc_tiles_num($soc);
350
#       if(scalar @tiles>0){
351
#               my $condition="\n\t\tif(";
352
#               my $s=compress_nums( @tiles);
353
#               my @sep=split(',',$s);
354
#                       my $i=0;
355
#                       foreach my $p (@sep){
356
#                               my @range=split(':',$p);
357
#                               my $tt;
358
#                               if($i==0){
359
#                                       $tt= (scalar @range>1)? "(IP_NUM>=$range[0] && IP_NUM<=$range[1])":"(IP_NUM==$range[0])" ;
360
#                               }else{
361
#                               }
362
#                               add_text_to_string(\$condition,$tt);
363
#                               $i=1;
364
#                       }
365
#                       add_text_to_string(\$condition,") begin :${soc}_if\n ");        
366
#                       #soc instance
367
#                       my $soc_v= gen_soc_v($mpsoc,$soc);
368
#         
369
#                       add_text_to_string(\$socs_v,$condition );
370
#                       add_text_to_string(\$socs_v,$soc_v);
371
#                       add_text_to_string(\$socs_v,"\t\tend // ${soc}_if \n");
372
#               }#scalar @tile  
373
# }     #froeach soc
374
 
375
 
376
 
377
 my $socs_v;
378
 
379 25 alirezamon
   my $nx= $mpsoc->object_get_attribute('noc_param',"NX");
380
   my $ny= $mpsoc->object_get_attribute('noc_param',"NY");
381 16 alirezamon
   my $processors_en=0;
382
   for (my $y=0;$y<$ny;$y++){
383
                for (my $x=0; $x<$nx;$x++){
384
                        my $tile_num=($nx*$y)+ $x;
385
                        my ($soc_name,$n,$soc_num)=$mpsoc->mpsoc_get_tile_soc_name($tile_num);
386
 
387
                        if(defined $soc_name) {
388 28 alirezamon
 
389
 
390
 
391
                                my ($soc_v,$en)= gen_soc_v($mpsoc,$soc_name,$tile_num,$x,$y,$soc_num,$io_v_ref,$io_def_v,$top_io_ref);
392 16 alirezamon
                                add_text_to_string(\$socs_v,$soc_v);
393
                                $processors_en|=$en;
394 28 alirezamon
 
395 16 alirezamon
                        }else{
396
                                #this tile is not connected to any ip. the noc input ports will be connected to ground
397
                                my $soc_v="\n\n // Tile:$tile_num (x=$x,y=$y)   is not assigned to any ip\n";
398
                                $soc_v="$soc_v
399
 
400
        assign ni_credit_out[$tile_num]={V{1'b0}};
401
        assign ni_flit_out[$tile_num]={Fw{1'b0}};
402
        assign ni_flit_out_wr[$tile_num]=1'b0;
403
        ";
404
                add_text_to_string(\$socs_v,$soc_v);
405
 
406
                        }
407
 
408
        }}
409
 
410
    if($processors_en){
411
        add_text_to_string($io_v_ref,",\n\tprocessors_en");
412
        add_text_to_string($io_def_v,"\t input processors_en;");
413 28 alirezamon
        add_text_to_string($top_io_ref,",\n\t\t.processors_en(processors_en_anded_jtag)");
414 16 alirezamon
 
415
    }
416
 
417
 
418
        return $socs_v;
419
 
420
}
421
 
422
##############
423
#       gen_soc_v
424
##############
425
 
426
 
427
 
428
sub   gen_soc_v{
429 28 alirezamon
        my ($mpsoc,$soc_name,$tile_num,$x,$y,$soc_num,$io_v_ref,$io_def_v,$top_io_ref)=@_;
430 16 alirezamon
        my $soc_v;
431
        my $processor_en=0;
432 25 alirezamon
        my $xw= log2($mpsoc->object_get_attribute('noc_param',"NX"));
433
        my $yw= log2($mpsoc->object_get_attribute('noc_param',"NY"));
434 16 alirezamon
        $soc_v="\n\n // Tile:$tile_num (x=$x,y=$y)\n   \t$soc_name #(\n";
435
 
436
        # core id
437
        add_text_to_string(\$soc_v,"\t\t.CORE_ID($tile_num)");
438
 
439
        # ni parameter
440
        my $top=$mpsoc->mpsoc_get_soc($soc_name);
441
        my @noc_param=$top->top_get_parameter_list('ni0');
442
        my $inst_name=$top->top_get_def_of_instance('ni0','instance');
443
 
444
        #other parameters
445
        my %params=$top->top_get_default_soc_param();
446
 
447
        foreach my $p (@noc_param){
448
                my $parm_next = $p;
449
                $parm_next =~ s/${inst_name}_//;
450
                my $param=  ",\n\t\t.$p($parm_next)";
451
                add_text_to_string(\$soc_v,$param);
452
        }
453
        foreach my $p (sort keys %params){
454
                my $parm_next= "${soc_name}_${soc_num}_$p";
455
                my $param=  ",\n\t\t.$p($parm_next)";
456
                add_text_to_string(\$soc_v,$param);
457
 
458
        }
459
 
460
        add_text_to_string(\$soc_v,"\n\t)the_${soc_name}_$soc_num(\n");
461
 
462
        my @intfcs=$top->top_get_intfc_list();
463
 
464
        my $i=0;
465 25 alirezamon
 
466
        my $dir = Cwd::getcwd();
467
        my $mpsoc_name=$mpsoc->object_get_attribute('mpsoc_name');
468 28 alirezamon
        my $target_dir  = "$ENV{'PRONOC_WORK'}/MPSOC/$mpsoc_name";
469 25 alirezamon
        my $soc_file="$target_dir/src_verilog/tiles/$soc_name.v";
470
 
471
        my $vdb =read_file($soc_file);
472
 
473
        my %soc_localparam = $vdb->get_modules_parameters($soc_name);
474
 
475
 
476 16 alirezamon
        foreach my $intfc (@intfcs){
477
 
478
                # ni intfc      
479
                if( $intfc eq 'socket:ni[0]'){
480
                        my @ports=$top->top_get_intfc_ports_list($intfc);
481
 
482
                        foreach my $p (@ports){
483
                                my($inst,$range,$type,$intfc_name,$intfc_port)= $top->top_get_port($p);
484
                                my $q=($intfc_port eq "current_x")? "$xw\'d$x" :
485
                                                                  ($intfc_port eq "current_y")? "$yw\'d$y" :"ni_$intfc_port\[$tile_num\]";
486
                                add_text_to_string(\$soc_v,',') if ($i);
487
                                add_text_to_string(\$soc_v,"\n\t\t.$p($q)");
488
                                $i=1;
489
 
490
 
491
                        }
492
                }
493
                # clk source
494
                elsif( $intfc eq 'plug:clk[0]'){
495
                        my @ports=$top->top_get_intfc_ports_list($intfc);
496
                        foreach my $p (@ports){
497
                                my($inst,$range,$type,$intfc_name,$intfc_port)= $top->top_get_port($p);
498
                                add_text_to_string(\$soc_v,',') if ($i);
499
                            add_text_to_string(\$soc_v,"\n\t\t.$p(clk)");
500
                            $i=1;
501
 
502
                        }
503
                }
504
                #reset
505
                elsif( $intfc eq 'plug:reset[0]'){
506
                        my @ports=$top->top_get_intfc_ports_list($intfc);
507
                        foreach my $p (@ports){
508
                                my($inst,$range,$type,$intfc_name,$intfc_port)= $top->top_get_port($p);
509
                                add_text_to_string(\$soc_v,',') if ($i);
510
                            add_text_to_string(\$soc_v,"\n\t\t.$p(reset)");
511
                            $i=1;
512
 
513
                        }
514
 
515
 
516
 
517
                }
518
                elsif( $intfc eq 'plug:enable[0]'){
519
                        my @ports=$top->top_get_intfc_ports_list($intfc);
520
                        foreach my $p (@ports){
521
                                my($inst,$range,$type,$intfc_name,$intfc_port)= $top->top_get_port($p);
522
                                add_text_to_string(\$soc_v,',') if ($i);
523
                            add_text_to_string(\$soc_v,"\n\t\t.$p(processors_en)");
524
                            $processor_en=1;
525
                            $i=1;
526
 
527
                        }
528
 
529
 
530
                }
531
                else {
532
                #other interface
533
                        my @ports=$top->top_get_intfc_ports_list($intfc);
534
                        foreach my $p (@ports){
535
                        my($inst,$range,$type,$intfc_name,$intfc_port)= $top->top_get_port($p);
536
                        my $io_port="${soc_name}_${soc_num}_${p}";
537 25 alirezamon
                        #resolve range parameter
538
                        if (defined $range ){
539
                                my @a= split (/\b/,$range);
540
                                foreach my $l (@a){
541
                                        #if defined in parameter list ignore it
542
                                        next  if(defined $params{$l});
543
                                        ($range=$range)=~ s/\b$l\b/$soc_localparam{$l}/g      if(defined $soc_localparam{$l});
544
                                        #else s
545
 
546
                                        #print "$l\n";
547
                                }
548
 
549
                        }
550 16 alirezamon
                        #io name 
551
                        add_text_to_string($io_v_ref,",\n\t$io_port");
552 28 alirezamon
                        add_text_to_string($top_io_ref,",\n\t\t.$io_port($io_port)");
553 16 alirezamon
                        #io definition
554
                        my $new_range = add_instantc_name_to_parameters(\%params,"${soc_name}_$soc_num",$range);
555
                        #my $new_range=$range;
556
                        my $port_def=(length ($range)>1 )?      "\t$type\t [ $new_range    ] $io_port;\n": "\t$type\t\t\t$io_port;\n";
557
 
558
 
559
                        add_text_to_string($io_def_v,"$port_def");
560
                        add_text_to_string(\$soc_v,',') if ($i);
561
                        add_text_to_string(\$soc_v,"\n\t\t.$p($io_port)");
562
                        $i=1;
563
 
564
                        }
565
 
566
 
567
                }
568
 
569
 
570
        }
571
 
572
        add_text_to_string(\$soc_v,"\n\t);\n");
573
 
574
 
575
 
576
 
577
 
578
 
579
 
580
 
581
 
582
 
583
        return ($soc_v,$processor_en);
584
 
585
}
586
 
587
 
588
sub log2{
589
        my $num=shift;
590
        my $log=0;
591 25 alirezamon
        while( (1<< $log)  < $num) {
592 16 alirezamon
                                $log++;
593
        }
594
        return  $log;
595
}
596
 
597
 
598 25 alirezamon
 
599
sub gen_emulate_top_v{
600
                my $emulate=shift;
601
                my ($localparam, $pass_param)=gen_noc_param_v( $emulate);
602
                my $top_v="
603
 
604
module  emulator_top (
605
        output [0:0]LEDR,
606
        output [0:0]LEDG,
607
        input  [0:0]KEY,
608
        input  CLOCK_50
609
);
610
 
611
 
612
 
613
 
614
        $localparam
615
 
616
 
617
        wire reset_in,jtag_reset,reset,reset_sync;
618
 
619
        assign  reset_in        =       ~KEY[0];
620
        assign  LEDG[0]         =       reset;
621
        assign  reset           =       (jtag_reset | reset_in);
622
        wire done;
623
        reg[31:0]time_cnt;
624
 
625
        // a reset source which can be controled using jtag
626
        jtag_source_probe #(
627
                .VJTAG_INDEX(127),
628
                .Dw(1)  //source/probe width in bits
629
        )the_reset(
630
                .probe(done),
631
                .source(jtag_reset)
632
        );
633
 
634
        altera_reset_synchronizer rst_sync
635
        (
636
                .reset_in(reset),
637
                .clk(CLOCK_50),
638
                .reset_out(reset_sync)
639
        );
640
 
641
 
642
 
643
        noc_emulator #(
644
                $pass_param
645
 
646
                    // simulation
647
                   // parameter MAX_PCK_NUM=2560000,
648
                   // parameter MAX_SIM_CLKs=1000000,
649
                  //  parameter MAX_PCK_SIZ=10,
650
                 //   parameter TIMSTMP_FIFO_NUM=16
651
        )
652
        emulate_top
653
        (
654
                .reset(reset_sync),
655
                .clk(CLOCK_50),
656
                .done(done)
657
        );
658
 
659
 
660
         jtag_source_probe #(
661
                .VJTAG_INDEX(126),
662
                .Dw(32) //source/probe width in bits
663
 
664
 
665
        )
666
        src_pb
667
        (
668
                .probe(time_cnt),
669
                .source()
670
        );
671
 
672
 
673
        always @(posedge CLOCK_50 or posedge reset)begin
674
                if(reset) begin
675
                        time_cnt<=0;
676
                end else begin
677
                         if(!done) time_cnt<=time_cnt+1;
678
                end
679
        end
680
 
681
 
682
 assign LEDR[0]=done;
683
 
684
 
685
endmodule
686
 
687
 
688
                ";
689
                return $top_v;
690
 
691
 
692
 
693
 
694
}
695
 
696
 
697 16 alirezamon
1

powered by: WebSVN 2.1.0

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