OpenCores
URL https://opencores.org/ocsvn/wb_builder/wb_builder/trunk

Subversion Repositories wb_builder

[/] [wb_builder/] [trunk/] [generator/] [wishbone.pl] - Blame information for rev 14

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

Line No. Rev Author Line
1 2 unneback
#!/usr/bin/perl
2
 
3
#use POSIX;
4
use Tk;
5
use Time::Local;
6
 
7
#
8
# usage perl wishbone_gui.pl [-nogui] [wishbone.defines]
9
#
10
 
11
# description: users manual
12
 
13
my $infile = "wishbone.defines";
14
my $outfile = wb;
15
 
16
my $a;
17
my $i=0;
18
my $j=0;
19
 
20
# default settings
21
my $syscon=syscon;
22
my $intercon=intercon;
23
my $target="generic";
24
my $hdl=vhdl;
25
my $ext=".vhd";
26
my $signal_groups=0;
27
my $comment="--";
28
my $dat_size=32;
29
my $adr_size=32;
30
my $tgd_bits=0;
31
my $tga_bits=2;
32
my $tgc_bits=3;
33
my $rename_tgc="cti";
34
my $rename_tga="bte";
35
my $rename_tgd="tgd";
36
my $classic="000";
37
my $endofburst="111";
38
my $interconnect="sharedbus";
39
my $mux_type="andor";
40
my $optimize="speed";
41 13 unneback
my $priority="0";
42 2 unneback
 
43
# keep track of implementation size
44
my $masters=0;
45
my $slaves=0;
46
my $rty_o=0;
47
my $rty_i=0;
48
my $err_o=0;
49
my $err_i=0;
50
my $tgc_o=0;
51
my $tgc_i=0;
52
my $tga_o=0;
53
my $tga_i=0;
54
 
55
# GUI FSM
56
my $state='WinGlobal';
57
my $next=0;
58
my $back=0;
59
my $amp=0;
60
my $asp=0;
61
my $del=0;
62
my $i;
63
 
64
# open input file
65
#if (open(FILE,"<$file")) {
66
 
67
# read in settings from infile
68
 
69
sub master_init {
70
  $masters += 1;
71
  $master[$masters]{"wbm"}=$_[0];
72
  $master[$masters]{"dat_size"}=$dat_size;
73
  $master[$masters]{"adr_size"}=$adr_size;
74
  $master[$masters]{"type"}="rw";
75
  $master[$masters]{"adr_o_hi"}=31;
76
  $master[$masters]{"adr_o_lo"}=0;
77
  $master[$masters]{"lock_o"}=0;
78
  $master[$masters]{"err_i"}=1;
79
  $master[$masters]{"rty_i"}=1;
80
  $master[$masters]{"tga_o"}=0;
81
  $master[$masters]{"tgd_o"}=0;
82
  $master[$masters]{"tgc_o"}=0;
83
  $master[$masters]{"priority"}=1;
84
};
85
 
86
sub slave_init {
87
  $slaves += 1;
88
  $slave[$slaves]{"wbs"}=$_[0];
89
  $slave[$slaves]{"dat_size"}=$dat_size;
90
  $slave[$slaves]{"type"}="rw";
91
  $slave[$slaves]{"sel_i"}=1;
92
  $slave[$slaves]{"adr_i_hi"}=31;
93
  $slave[$slaves]{"adr_i_lo"}=2;
94
  $slave[$slaves]{"lock_i"}=0;
95
  $slave[$slaves]{"tgd_i"}=0;
96
  $slave[$slaves]{"tga_i"}=0;
97
  $slave[$slaves]{"tgc_i"}=0;
98
  $slave[$slaves]{"err_o"}=0;
99
  $slave[$slaves]{"rty_o"}=0;
100
  $slave[$slaves]{"baseadr"}="00000000";
101
  $slave[$slaves]{"size"}="00100000";
102
  $slave[$slaves]{"baseadr1"}="00000000";
103
  $slave[$slaves]{"size1"}="ffffffff";
104
  $slave[$slaves]{"baseadr2"}="00000000";
105
  $slave[$slaves]{"size2"}="ffffffff";
106
  $slave[$slaves]{"baseadr3"}="00000000";
107
  $slave[$slaves]{"size3"}="ffffffff";
108
};
109
 
110
sub read_defines {
111 14 unneback
$priority=0;
112 2 unneback
open(FILE,"<$_[0]") or die "could not read from $file";
113
while($a = <FILE>)
114
{
115
  if ($a =~ /^(syscon|intercon|filename)( *)(=)( *)([a-zA-Z0-9_\/\.]+)(;?)$/) {
116
    if($1 eq "syscon")   { $syscon = $5; }
117
    if($1 eq "intercon") { $intercon = $5; }
118
    if($1 eq "filename") { $outfile = $5; }
119
  }
120
 
121
  if ($a =~ /^(target)( *)(=)( *)(generic|xilinx|altera)(;?)$/) {
122
    $target = $5; };
123
 
124
  if ($a =~ /^(hdl)( *)(=)( *)(vhdl|verilog|perlilog);?$/) {
125
    $hdl = $5;
126
    if ($5 eq "vhdl") {
127
      $comment="--";
128
      $ext=".vhd";
129
    } else {
130
      $comment="//";
131
      $ext=".v";
132
    };
133
  };
134
 
135
  if ($a =~ /^(interconnect)( *)(=)( *)(crossbarswitch|sharedbus)(;?)$/) {
136
    $interconnect = $5; };
137
 
138
  if ($a =~ /^(signal_groups)( *)(=)( *)([0-1])(;?)($*)/) {
139
    $signal_groups = $5; };
140
 
141
  if ($a =~ /^(mux_type)( *)(=)( *)(mux|andor|tristate)(;?)$/) {
142
    $mux_type = $5; };
143
 
144
  if ($a =~ /^(optimize)( *)(=)( *)(speed|area);?$/) {
145
    $optimize = $5; };
146
 
147
  if ($a =~ /^(dat_size|adr_size|tgd_bits|tga_bits|tgc_bits)( *)(=)( *)([0-9]+)(;?)($*)/) {
148
    if ($1 eq "dat_size"){$dat_size = $5};
149
    if ($1 eq "adr_size"){$adr_size = $5};
150
    if ($1 eq "tgd_bits"){$tgd_bits = $5};
151
    if ($1 eq "tga_bits"){$tga_bits = $5};
152
    if ($1 eq "tgc_bits"){$tgc_bits = $5};
153
  };
154
 
155
  if ($a =~ /^(rename)(_)(tga|tgc|tgd)( *)(=)( *)([a-zA-Z_-]+)(;?)($*)/) {
156
    if ($3 eq "tga"){$rename_tga=$7};
157
    if ($3 eq "tgc"){$rename_tgc=$7};
158
    if ($3 eq "tgd"){$rename_tgd=$7};
159
  };
160
 
161
  # master port setup
162
  if ($a =~ /^(master)( *)([A-Za-z0-9_-]+)($*)/) {
163
    if($1 eq "master") {
164
      master_init($3);
165
    };
166
    $a = <FILE>;
167
    until ($a =~ /^(end master)($*)/) {
168 13 unneback
      if ($a =~ /^( *)(dat_size|adr_o_hi|adr_o_lo|lock_o|err_i|rty_i|tga_o|tgc_o|priority)( *)(=)( *)(0x)?([0-9a-fA-F]*)(;?)($*)/) {
169 12 unneback
        $master[$masters]{"$2"}=$7;
170 2 unneback
        if (($2 eq "rty_i") && ($7 eq 1)) {
171
          $rty_i++; };
172
        if (($2 eq "err_i") && ($7 eq 1)) {
173
          $err_i++; };
174
        if (($2 eq "tgc_o") && ($7 eq 1)) {
175
          $tgc_o++; };
176
        if (($2 eq "tga_o") && ($7 eq 1)) {
177
          $tga_o++; };
178 12 unneback
        # priority for shared bus system
179 14 unneback
        if ($2 eq "priority") {
180
          $priority += $7; };
181 2 unneback
      }; #end if
182
      if ($a =~ /^( *)(type)( *)(=)( *)(ro|wo|rw)(;?)($*)/) {
183
        $master[$masters]{"$2"}=$6; };
184
      # priority for crossbarswitch
185 4 unneback
      if ($a =~ /^( *)(priority)(_)([0-9a-zA-Z_]*)( *)(=)( *)([0-9]*)(;?)($*)/) {
186 2 unneback
        $master[$masters]{("priority_"."$4")}=$8; };
187
      $a = <FILE>;
188
    };
189
  };
190
 
191
  # slave port setup
192
  if ($a =~ /^(slave)( *)([A-Za-z0-9_-]+)($*)/) {
193
    if ($1 eq "slave") {
194
      slave_init($3);
195
    };
196
    $a = <FILE>;
197
    until ($a =~ /^(end slave)($*)/) {
198
      if ($a =~ /^( *)(dat_i|dat_o|sel_i|adr_i_hi|adr_i_lo|lock_i|tga_i|tgc_i|err_o|rty_o|baseadr|size|baseadr1|size1|baseadr2|size2|baseadr3|size3)( *)(=)( *)(0x)?([0-9a-fA-F]+)(;?)($*)/) {
199
        $slave[$slaves]{"$2"}=$7;
200
        if (($2 eq "rty_o") && ($7 eq 1)) {
201
          $rty_o++; };
202
        if (($2 eq "err_o") && ($7 eq 1)) {
203
          $err_o++; };
204
        if (($2 eq "tgc_i") && ($7 eq 1)) {
205
          $tgc_i++; };
206
        if (($2 eq "tga_i") && ($7 eq 1)) {
207
          $tga_i++; };
208
      }; #end if
209
      if ($a =~ /^( *)(type)( *)(=)( *)(ro|wo|rw)(;?)($*)/) {
210
        $slave[$slaves]{"$2"}=$6; };
211
      $a = <FILE>;
212
    };
213
  };
214
}; #end while
215
close($_[0]);
216 14 unneback
#$priority = 0;
217
#if ($interconnect eq "sharedbus") {
218
#  for ($i=1; $i le $masters; $i++) {
219
#      $priority = $priority + $master[$i]{"priority"}; 
220
#  };
221
#};
222 2 unneback
}; #end sub
223
 
224
################################################################################
225
# GUI
226
 
227
my $mw;
228
 
229
sub WinGlobalExit {
230
  $mw->destroy();
231
};
232
 
233
# global assignments
234
sub WinGlobal {
235
  $mw = MainWindow->new;
236
  $mw->title ("Wishbone generator");
237
  $frame=$mw->Frame(-label=>"Global definitions");
238
  # define file
239
  $frame->pack(-side => 'top', -fill => 'y', -expand => 'y');
240
  $frame->Label(-text => "Define file:")->pack(-side=>'left');
241
  $frame->Entry(-textvariable => \$infile)->pack(-side=>'right');
242
  # HDL file
243
  $frame=$mw->Frame();
244
  $frame->pack(-side => 'top', -fill => 'y', -expand => 'y');
245
  $frame->Label(-text => "HDL file   :")->pack(-side=>'left');
246
  $frame->Entry(-textvariable => \$outfile)->pack(-side=>'right');
247
  # intercon
248
  $frame=$mw->Frame();
249
  $frame->pack(-side => 'top', -fill => 'y', -expand => 'y');
250
  $frame->Label(-text => "intercon   :")->pack(-side=>'left');
251
  $frame->Entry(-textvariable => \$intercon)->pack(-side=>'right');
252
  # syscon
253
  $frame=$mw->Frame();
254
  $frame->pack(-side => 'top', -fill => 'y', -expand => 'y');
255
  $frame->Label(-text => "syscon     :")->pack(-side=>'left');
256
  $frame->Entry(-textvariable => \$syscon)->pack(-side=>'right');
257
  # target
258
  $frame=$mw->Frame();
259
  $frame->pack(-side => 'top', -fill => 'y', -expand => 'y');
260
  $frame->Label(-text => "Target :")->pack(-side=>'left');
261
  $a = $frame->Radiobutton ( -variable => \$target, -text => 'Generic', -value => 'generic')->pack(-side=>'left');
262
  $b = $frame->Radiobutton ( -variable => \$target, -text => 'XILINX', -value => 'xilinx')->pack(-side=>'left');
263
  $c = $frame->Radiobutton ( -variable => \$target, -text => 'ALTERA', -value => 'altera')->pack(-side=>'left');
264
  # interconnect
265
  $frame=$mw->Frame();
266
  $frame->pack(-side => 'top', -fill => 'y', -expand => 'y');
267
  $frame->Label(-text => "Interconnection :")->pack(-side=>'left');
268
  $a = $frame->Radiobutton ( -variable => \$interconnect, -text => 'Shared bus', -value => 'sharedbus')->pack( -side=>'left');
269
  $b = $frame->Radiobutton ( -variable => \$interconnect, -text => 'Crossbar switch', -value => 'crossbarswitch' )->pack( -side=>'right');
270
  # mux
271
  $frame=$mw->Frame();
272
  $frame->pack(-side => 'top', -fill => 'y', -expand => 'y');
273
  $frame->Label(-text => "Mux type :")->pack(-side=>'left');
274
  $a = $frame->Radiobutton ( -variable => \$mux_type, -text => 'mux', -value => 'mux')->pack( -side=>'left');
275
  $b = $frame->Radiobutton ( -variable => \$mux_type, -text => 'andor', -value => 'andor')->pack( -side=>'left');
276
  $c = $frame->Radiobutton ( -variable => \$mux_type, -text => 'tristate', -value => 'tristate' )->pack( -side=>'right');
277
  # hdl
278
  $frame=$mw->Frame();
279
  $frame->pack(-side => 'top', -fill => 'y', -expand => 'y');
280
  $frame->Label(-text => "HDL type :")->pack(-side=>'left');
281
  $a = $frame->Radiobutton ( -variable => \$hdl, -text => 'VHDL', -value => 'vhdl')->pack(-side=>'left');
282
  $b = $frame->Radiobutton ( -variable => \$hdl, -text => 'Verilog', -value => 'verilog')->pack(-side=>'left');
283
  $c = $frame->Radiobutton ( -variable => \$hdl, -text => 'Perlilog', -value => 'perlilog')->pack(-side=>'left');
284
  # signalgroups
285
  $frame=$mw->Frame();
286
  $frame->pack(-side => 'top', -fill => 'y', -expand => 'y');
287
  $frame->Label(-text => "Signal groups :")->pack(-side=>'left');
288
  $a = $frame->Radiobutton ( -variable => \$signal_groups, -text => 'No', -value => 0)->pack( -side=>'left');
289
  $b = $frame->Radiobutton ( -variable => \$signal_groups, -text => 'Yes', -value => 1 )->pack( -side=>'right');
290
  # dat size
291
  $frame=$mw->Frame();
292
  $frame->pack(-side => 'top', -fill => 'y', -expand => 'y');
293
  $frame->Label(-text => "Data bus size :")->pack(-side=>'left');
294
  $frame->Entry(-textvariable => \$dat_size)->pack(-side=>'right');
295
  # adr size
296
  $frame=$mw->Frame();
297
  $frame->pack(-side => 'top', -fill => 'y', -expand => 'y');
298
  $frame->Label(-text => "Adr bus size    :")->pack(-side=>'left');
299
  $frame->Entry(-textvariable => \$adr_size)->pack(-side=>'right');
300
  # tga
301
  $frame=$mw->Frame();
302
  $frame->pack(-side => 'top', -fill => 'y', -expand => 'y');
303
  $frame->Label(-text => "tga bits           :")->pack(-side=>'left');
304
  $frame->Entry(-textvariable => \$tga_bits)->pack(-side=>'right');
305
  $frame=$mw->Frame();
306
  $frame->pack(-side => 'top', -fill => 'y', -expand => 'y');
307
  $frame->Label(-text => "tga rename     :")->pack(-side=>'left');
308
  $frame->Entry(-textvariable => \$rename_tga)->pack(-side=>'right');
309
  # tgc
310
  $frame=$mw->Frame();
311
  $frame->pack(-side => 'top', -fill => 'y', -expand => 'y');
312
  $frame->Label(-text => "tgc bits           :")->pack(-side=>'left');
313
  $frame->Entry(-textvariable => \$tgc_bits)->pack(-side=>'right');
314
  $frame=$mw->Frame();
315
  $frame->pack(-side => 'top', -fill => 'y', -expand => 'y');
316
  $frame->Label(-text => "tgc rename     :")->pack(-side=>'left');
317
  $frame->Entry(-textvariable => \$rename_tgc)->pack(-side=>'right');
318
  $frame=$mw->Frame();
319
  $frame->pack(-side => 'top', -fill => 'y', -expand => 'y');
320
  $frame->Label(-text => "classic           :")->pack(-side=>'left');
321
  $frame->Entry(-textvariable => \$classic)->pack(-side=>'right');
322
  $frame=$mw->Frame();
323
  $frame->pack(-side => 'top', -fill => 'y', -expand => 'y');
324
  $frame->Label(-text => "end of burst   :")->pack(-side=>'left');
325
  $frame->Entry(-textvariable => \$endofburst)->pack(-side=>'right');
326
  # tgd
327
  $frame=$mw->Frame();
328
  $frame->pack(-side => 'top', -fill => 'y', -expand => 'y');
329
  $frame->Label(-text => "tgd bits           :")->pack(-side=>'left');
330
  $frame->Entry(-textvariable => \$tgd_bits)->pack(-side=>'right');
331
  $frame=$mw->Frame();
332
  $frame->pack(-side => 'top', -fill => 'y', -expand => 'y');
333
  $frame->Label(-text => "tgd rename     :")->pack(-side=>'left');
334
  $frame->Entry(-textvariable => \$rename_tgd)->pack(-side=>'right');
335
  # exit
336
  $frame=$mw->Frame(-label=>"\n");
337
  $frame->pack(-side => 'right', -fill => 'y', -expand => 'y');
338
  $frame->Button(-text => "add master port", -command =>sub {WinGlobalExit(); $amp=1;})->pack (-side => 'left');
339
  $frame->Button(-text => "add slave  port", -command =>sub {WinGlobalExit(); $asp=1;})->pack (-side => 'left');
340
  if (($masters > 0) && ($slaves > 0)) {
341
    $frame->Button(-text => "set priority", -command =>sub {WinGlobalExit();})->pack (-side => 'left');
342
  };
343
  $frame->Button(-text => "next", -command =>sub {WinGlobalExit(); $next=1;})->pack (-side => 'right');
344
  MainLoop;
345
};
346
 
347
# add master port
348
sub WinAddMaster {
349
  master_init("wbm". ($masters+1));
350
  $mw = MainWindow->new;
351
  $mw->title ("Wishbone generator");
352
  $frame=$mw->Frame(-label=>"Add wishbone master port");
353
  # port name
354
  $frame->pack(-side => 'top', -fill => 'y', -expand => 'y');
355
  $frame->Label(-text => "Master port name:")->pack(-side=>'left');
356
  $frame->Entry(-textvariable => \$master[$masters]{"wbm"})->pack(-side=>'right');
357
  # exit
358
  $frame=$mw->Frame(-label=>"\n");
359
  $frame->pack(-side => 'right', -fill => 'y', -expand => 'y');
360
  $frame->Button(-text => "add master port", -command =>sub {WinGlobalExit(); $amp=1;})->pack ( -side => 'left');
361
  $frame->Button(-text => "next", -command =>sub {WinGlobalExit(); $next=1;})->pack ( -side => 'right');
362
  MainLoop;
363
};
364
 
365
sub WinMaster {
366
  $mw = MainWindow->new;
367
  $mw->title ("Wishbone generator");
368
  $frame=$mw->Frame(-label=>"Master port");
369
  # Master port
370
  $frame->pack(-side => 'top', -fill => 'y', -expand => 'y');
371
  $frame->Label(-text => "Master port    :")->pack(-side=>'left');
372
  $frame->Entry(-textvariable => \$master[$i]{"wbm"})->pack(-side=>'right');
373
  # dat_size
374
  $frame=$mw->Frame();
375
  $frame->pack(-side => 'top', -fill => 'y', -expand => 'y');
376
  $frame->Label(-text => "Data bus size :")->pack(-side=>'left');
377
  $frame->Entry(-textvariable => \$master[$i]{"dat_size"})->pack(-side=>'right');
378
  # adr size
379
  $frame=$mw->Frame();
380
  $frame->pack(-side => 'top', -fill => 'y', -expand => 'y');
381
  $frame->Label(-text => "Adr bus size   :")->pack(-side=>'left');
382
  $frame->Entry(-textvariable => \$master[$i]{"adr_size"})->pack(-side=>'right');
383
  # type
384
  $frame=$mw->Frame();
385
  $frame->pack(-side => 'top', -fill => 'y', -expand => 'y');
386
  $frame->Label(-text => "Master type   :")->pack(-side=>'left');
387
  $a = $frame->Radiobutton ( -variable => \$master[$i]{"type"}, -text => 'Read/Write', -value => 'rw')->pack(-side=>'left');
388
  $b = $frame->Radiobutton ( -variable => \$master[$i]{"type"}, -text => 'Read only', -value => 'ro')->pack(-side=>'left');
389
  $c = $frame->Radiobutton ( -variable => \$master[$i]{"type"}, -text => 'Write only', -value => 'wo')->pack(-side=>'left');
390
  # err_i
391
  $frame=$mw->Frame();
392
  $frame->pack(-side => 'top', -fill => 'y', -expand => 'y');
393
  $frame->Label(-text => "err_i   :")->pack(-side=>'left');
394
  $a = $frame->Radiobutton ( -variable => \$master[$i]{"err_i"}, -text => 'No', -value => 0)->pack( -side=>'left');
395
  $b = $frame->Radiobutton ( -variable => \$master[$i]{"err_i"}, -text => 'Yes', -value => 1 )->pack( -side=>'right');
396
  # rty_i
397
  $frame=$mw->Frame();
398
  $frame->pack(-side => 'top', -fill => 'y', -expand => 'y');
399
  $frame->Label(-text => "rty_i   :")->pack(-side=>'left');
400
  $a = $frame->Radiobutton ( -variable => \$master[$i]{"rty_i"}, -text => 'No', -value => 0)->pack( -side=>'left');
401
  $b = $frame->Radiobutton ( -variable => \$master[$i]{"rty_i"}, -text => 'Yes', -value => 1 )->pack( -side=>'right');
402
  # lock_o
403
  $frame=$mw->Frame();
404
  $frame->pack(-side => 'top', -fill => 'y', -expand => 'y');
405
  $frame->Label(-text => "lock_o :")->pack(-side=>'left');
406
  $a = $frame->Radiobutton ( -variable => \$master[$i]{"lock_o"}, -text => 'No', -value => 0)->pack( -side=>'left');
407
  $b = $frame->Radiobutton ( -variable => \$master[$i]{"lock_o"}, -text => 'Yes', -value => 1 )->pack( -side=>'right');
408
  # tga_o
409
  $frame=$mw->Frame();
410
  $frame->pack(-side => 'top', -fill => 'y', -expand => 'y');
411
  $frame->Label(-text => "tga_o  :")->pack(-side=>'left');
412
  $a = $frame->Radiobutton ( -variable => \$master[$i]{"tga_o"}, -text => 'No', -value => 0)->pack( -side=>'left');
413
  $b = $frame->Radiobutton ( -variable => \$master[$i]{"tga_o"}, -text => 'Yes', -value => 1 )->pack( -side=>'right');
414
  # tgc_o
415
  $frame=$mw->Frame();
416
  $frame->pack(-side => 'top', -fill => 'y', -expand => 'y');
417
  $frame->Label(-text => "tgc_o  :")->pack(-side=>'left');
418
  $a = $frame->Radiobutton ( -variable => \$master[$i]{"tgc_o"}, -text => 'No', -value => 0)->pack( -side=>'left');
419
  $b = $frame->Radiobutton ( -variable => \$master[$i]{"tgc_o"}, -text => 'Yes', -value => 1 )->pack( -side=>'right');
420
  # tgd_o
421
  $frame=$mw->Frame();
422
  $frame->pack(-side => 'top', -fill => 'y', -expand => 'y');
423
  $frame->Label(-text => "tgd_o  :")->pack(-side=>'left');
424
  $a = $frame->Radiobutton ( -variable => \$master[$i]{"tgd_o"}, -text => 'No', -value => 0)->pack( -side=>'left');
425
  $b = $frame->Radiobutton ( -variable => \$master[$i]{"tgd_o"}, -text => 'Yes', -value => 1 )->pack( -side=>'right');
426
  # exit
427
  $frame=$mw->Frame(-label=>"\n");
428
  $frame->pack(-side => 'right', -fill => 'y', -expand => 'y');
429
  if ($i == $masters) {
430
    $frame->Button(-text => "add slave port", -command =>sub {WinGlobalExit(); $am=1;})->pack (-side => 'left');
431
  };
432
  $frame->Button(-text => "delete", -command =>sub {WinGlobalExit(); $del=1;})->pack (-side => 'left');
433
  $frame->Button(-text => "back", -command =>sub {WinGlobalExit(); $back=1;})->pack (-side => 'left');
434
  $frame->Button(-text => "next", -command =>sub {WinGlobalExit(); $next=1;})->pack (-side => 'left');
435
  MainLoop;
436
};
437
 
438
# add slave port
439
sub WinAddSlave {
440
  slave_init("wbs" . ($slaves+1));
441
  $mw = MainWindow->new;
442
  $mw->title ("Wishbone generator");
443
  $frame=$mw->Frame(-label=>"Add wishbone slave port");
444
  # port name
445
  $frame->pack(-side => 'top', -fill => 'y', -expand => 'y');
446
  $frame->Label(-text => "Slave port name:")->pack(-side=>'left');
447
  $frame->Entry(-textvariable => \$slave[$slaves]{"wbs"})->pack(-side=>'right');
448
  # exit
449
  $frame=$mw->Frame(-label=>"\n");
450
  $frame->pack(-side => 'right', -fill => 'y', -expand => 'y');
451
  $frame->Button(-text => "add slave port", -command =>sub {WinGlobalExit(); $asp=1;})->pack ( -side => 'left');
452
  $frame->Button(-text => "next", -command =>sub {WinGlobalExit(); $next=1;})->pack ( -side => 'right');
453
  MainLoop;
454
};
455
 
456
# slave port
457
sub WinSlave {
458
  $mw = MainWindow->new;
459
  $mw->title ("Wishbone generator");
460
  $frame=$mw->Frame(-label=>"Slave port");
461
  # Slave port
462
  $frame->pack(-side => 'top', -fill => 'y', -expand => 'y');
463
  $frame->Label(-text => "Slave port       :")->pack(-side=>'left');
464
  $frame->Entry(-textvariable => \$slave[$i]{"wbs"})->pack(-side=>'right');
465
  # dat_size
466
  $frame=$mw->Frame();
467
  $frame->pack(-side => 'top', -fill => 'y', -expand => 'y');
468
  $frame->Label(-text => "Data bus size :")->pack(-side=>'left');
469
  $frame->Entry(-textvariable => \$slave[$i]{"dat_size"})->pack(-side=>'right');
470
  # adr
471
  $frame=$mw->Frame();
472
  $frame->pack(-side => 'top', -fill => 'y', -expand => 'y');
473
  $frame->Label(-text => "adr hi              :")->pack(-side=>'left');
474
  $frame->Entry(-textvariable => \$slave[$i]{"adr_i_hi"})->pack(-side=>'left');
475
  $frame=$mw->Frame();
476
  $frame->pack(-side => 'top', -fill => 'y', -expand => 'y');
477
  $frame->Label(-text => "adr lo              :")->pack(-side=>'left');
478
  $frame->Entry(-textvariable => \$slave[$i]{"adr_i_lo"})->pack(-side=>'right');
479
  # type
480
  $frame=$mw->Frame();
481
  $frame->pack(-side => 'top', -fill => 'y', -expand => 'y');
482
  $frame->Label(-text => "Slave type   :")->pack(-side=>'left');
483
  $a = $frame->Radiobutton ( -variable => \$slave[$i]{"type"}, -text => 'Read/Write', -value => 'rw')->pack(-side=>'left');
484
  $b = $frame->Radiobutton ( -variable => \$slave[$i]{"type"}, -text => 'Read only', -value => 'ro')->pack(-side=>'left');
485
  $c = $frame->Radiobutton ( -variable => \$slave[$i]{"type"}, -text => 'Write only', -value => 'wo')->pack(-side=>'left');
486
  # lock_i
487
  $frame=$mw->Frame();
488
  $frame->pack(-side => 'top', -fill => 'y', -expand => 'y');
489
  $frame->Label(-text => "lock_i   :")->pack(-side=>'left');
490
  $a = $frame->Radiobutton ( -variable => \$slave[$i]{"lock_i"}, -text => 'No', -value => 0)->pack( -side=>'left');
491
  $b = $frame->Radiobutton ( -variable => \$slave[$i]{"lock_i"}, -text => 'Yes', -value => 1 )->pack( -side=>'right');
492
  # tga_i
493
  $frame=$mw->Frame();
494
  $frame->pack(-side => 'top', -fill => 'y', -expand => 'y');
495
  $frame->Label(-text => "tga_i   :")->pack(-side=>'left');
496
  $a = $frame->Radiobutton ( -variable => \$slave[$i]{"tga_i"}, -text => 'No', -value => 0)->pack( -side=>'left');
497
  $b = $frame->Radiobutton ( -variable => \$slave[$i]{"tga_i"}, -text => 'Yes', -value => 1 )->pack( -side=>'right');
498
  # tgc_i
499
  $frame=$mw->Frame();
500
  $frame->pack(-side => 'top', -fill => 'y', -expand => 'y');
501
  $frame->Label(-text => "tgc_i   :")->pack(-side=>'left');
502
  $a = $frame->Radiobutton ( -variable => \$slave[$i]{"tgc_i"}, -text => 'No', -value => 0)->pack( -side=>'left');
503
  $b = $frame->Radiobutton ( -variable => \$slave[$i]{"tgc_i"}, -text => 'Yes', -value => 1 )->pack( -side=>'right');
504
  # tgd_i
505
  $frame=$mw->Frame();
506
  $frame->pack(-side => 'top', -fill => 'y', -expand => 'y');
507
  $frame->Label(-text => "tgd_i   :")->pack(-side=>'left');
508
  $a = $frame->Radiobutton ( -variable => \$slave[$i]{"tgd_i"}, -text => 'No', -value => 0)->pack( -side=>'left');
509
  $b = $frame->Radiobutton ( -variable => \$slave[$i]{"tgd_i"}, -text => 'Yes', -value => 1 )->pack( -side=>'right');
510
  # err_o
511
  $frame=$mw->Frame();
512
  $frame->pack(-side => 'top', -fill => 'y', -expand => 'y');
513
  $frame->Label(-text => "err_o   :")->pack(-side=>'left');
514
  $a = $frame->Radiobutton ( -variable => \$slave[$i]{"err_o"}, -text => 'No', -value => 0)->pack( -side=>'left');
515
  $b = $frame->Radiobutton ( -variable => \$slave[$i]{"err_o"}, -text => 'Yes', -value => 1 )->pack( -side=>'right');
516
  # rty_o
517
  $frame=$mw->Frame();
518
  $frame->pack(-side => 'top', -fill => 'y', -expand => 'y');
519
  $frame->Label(-text => "rty_o   :")->pack(-side=>'left');
520
  $a = $frame->Radiobutton ( -variable => \$slave[$i]{"rty_o"}, -text => 'No', -value => 0)->pack( -side=>'left');
521
  $b = $frame->Radiobutton ( -variable => \$slave[$i]{"rty_o"}, -text => 'Yes', -value => 1 )->pack( -side=>'right');
522
  # ss
523
  $frame=$mw->Frame();
524
  $frame->pack(-side => 'top', -fill => 'y', -expand => 'y');
525
  $frame->Label(-text => "Base_adr  :")->pack(-side=>'left');
526
  $frame->Entry(-textvariable => \$slave[$i]{"baseadr"})->pack(-side=>'right');
527
  $frame=$mw->Frame();
528
  $frame->pack(-side => 'top', -fill => 'y', -expand => 'y');
529
  $frame->Label(-text => "Size           :")->pack(-side=>'left');
530
  $frame->Entry(-textvariable => \$slave[$i]{"size"})->pack(-side=>'right');
531
  $frame=$mw->Frame();
532
  $frame->pack(-side => 'top', -fill => 'y', -expand => 'y');
533
  $frame->Label(-text => "Base_adr1 :")->pack(-side=>'left');
534
  $frame->Entry(-textvariable => \$slave[$i]{"baseadr1"})->pack(-side=>'right');
535
  $frame=$mw->Frame();
536
  $frame->pack(-side => 'top', -fill => 'y', -expand => 'y');
537
  $frame->Label(-text => "Size1          :")->pack(-side=>'left');
538
  $frame->Entry(-textvariable => \$slave[$i]{"size1"})->pack(-side=>'right');
539
  $frame=$mw->Frame();
540
  $frame->pack(-side => 'top', -fill => 'y', -expand => 'y');
541
  $frame->Label(-text => "Base_adr2 :")->pack(-side=>'left');
542
  $frame->Entry(-textvariable => \$slave[$i]{"baseadr2"})->pack(-side=>'right');
543
  $frame=$mw->Frame();
544
  $frame->pack(-side => 'top', -fill => 'y', -expand => 'y');
545
  $frame->Label(-text => "Size2          :")->pack(-side=>'left');
546
  $frame->Entry(-textvariable => \$slave[$i]{"size2"})->pack(-side=>'right');
547
 
548
  # exit
549
  $frame=$mw->Frame(-label=>"\n");
550
  $frame->pack(-side => 'right', -fill => 'y', -expand => 'y');
551
  $frame->Button(-text => "back", -command =>sub {WinGlobalExit(); $back=1;})->pack ( -side => 'left');
552
  $frame->Button(-text => "delete", -command =>sub {WinGlobalExit(); $del=1;})->pack ( -side => 'left');
553
  $frame->Button(-text => "next", -command =>sub {WinGlobalExit(); $next=1;})->pack ( -side => 'right');
554
  MainLoop;
555
};
556
 
557
# Prio shared bus
558
sub WinPrioshb {
559
  $mw = MainWindow->new;
560
  $mw->title ("Wishbone generator");
561
  $frame=$mw->Frame(-label=>"Priority for shared bus system")->pack();
562
  for ($i=1; $i le $masters; $i++) {
563
    $frame=$mw->Frame();
564
    $frame->pack(-side => 'top', -fill => 'y', -expand => 'y');
565
    $frame->Label(-text => $master[$i]{"wbm"})->pack(-side=>'left');
566
    $frame->Entry(-textvariable => \$master[$i]{"priority"})->pack(-side=>'right');
567
  };
568
  # exit
569
  $frame=$mw->Frame(-label=>"\n");
570
  $frame->pack(-side => 'right', -fill => 'y', -expand => 'y');
571
  $frame->Button(-text => "back", -command =>sub {WinGlobalExit(); $back=1;})->pack ( -side => 'left');
572
  $frame->Button(-text => "generate", -command =>sub {WinGlobalExit(); $next=1;})->pack ( -side => 'right');
573
  MainLoop;
574
};
575
 
576
# Prio cross bar switch
577
sub WinPriocbs {
578
  my $tmp="";
579
  $mw = MainWindow->new;
580
  $mw->title ("Wishbone generator");
581
  $frame=$mw->Frame(-label=>"Priority for crossbar switch bus system")->pack();
582
  $frame=$mw->Frame();
583
  $frame->pack(-side => 'top', -fill => 'x', -expand => 'y');
584
  $frame->Entry(-textvariable => \$tmp)->pack(-side=>'left');
585
  for ($j=1; $j le $slaves; $j++) {
586
    $frame->Entry(-textvariable => \$slave[$j]{"wbs"})->pack(-side=>'left');
587
  };
588
  for ($i=1; $i le $masters; $i++) {
589
    $frame=$mw->Frame();
590
    $frame->pack(-side => 'top', -fill => 'x', -expand => 'y');
591
    #$frame->Label(-text => $master[$i]{"wbm"})->pack(-side=>'left');
592
    $frame->Entry(-textvariable => \$master[$i]{"wbm"})->pack(-side=>'left');
593
    for ($j=1; $j le $slaves; $j++) {
594
      #$frame->Label(-text => $master[$i]{"priority_".($slave[$j]{"wbs"})})->pack(-side=>'left');
595
      $frame->Entry(-textvariable => \$master[$i]{"priority_".($slave[$j]{"wbs"})})->pack(-side=>'left');
596
    };
597
  };
598
  # exit
599
  $frame=$mw->Frame(-label=>"\n");
600
  $frame->pack(-side => 'right', -fill => 'y', -expand => 'y');
601
  $frame->Button(-text => "back", -command =>sub {WinGlobalExit(); $back=1;})->pack ( -side => 'left');
602
  $frame->Button(-text => "generate", -command =>sub {WinGlobalExit(); $next=1;})->pack ( -side => 'right');
603
  MainLoop;
604
};
605
 
606
# delete wishbone master
607
sub wbm_del {
608
  my $i;
609
  if ($_[0] != $masters) {
610
    for ($i=$_[0]; $i lt $masters; $i++) {
611
      $master[$i]=$master[$i+1];
612
    };
613
  };
614
  $masters--;
615
};
616
 
617
# delete wishbone slave
618
sub wbs_del {
619
  my $i;
620
  if ($_[0] != $slaves) {
621
    for ($i=$_[0]; $i lt $slaves; $i++) {
622
      $slave[$i]=$slave[$i+1];
623
    };
624
  };
625
  $slaves--;
626
};
627
 
628
# GUI FSM
629
sub gui_fsm {
630
$i=1;
631
until ($state eq "bye") {
632
  $amp=0; $asp=0; $back=0; $next=0; $del=0;
633
  if ($state eq 'WinGlobal') {
634
    WinGlobal;
635
    if ($amp == 1) {
636
      $state='WinAddMaster';
637
    } elsif ($asp == 1) {
638
      $state='WinAddSlave';
639
    } elsif ($next == 1) {
640
      $i=1;
641
      if ($masters == 0) {
642
        $state='WinAddMaster';
643
      } else {
644
        $state='WinMaster';
645
      };
646
    } else {
647
      $state='WinPrio';
648
    };
649
  } elsif ($state eq 'WinAddMaster') {
650
    WinAddMaster;
651
    if ($next == 1) {
652
      $i=1;
653
      $state='WinMaster';
654
    };
655
  } elsif ($state eq 'WinMaster') {
656
    WinMaster;
657
    if ($del == 1) {
658
      wbm_del($i);
659
      $state='WinGlobal';
660
      $i=1;
661
    } elsif ($asp == 1) {
662
      $state='WinAddSlave';
663
    } elsif ($next == 1) {
664
      if ($i == $masters) {
665
        $i=1;
666
        if ($slaves == 0) {
667
          $state='WinAddSlave';
668
        } else {
669
          $state='WinSlave';
670
        };
671
      } else {
672
        $i++
673
      };
674
    } else {
675
      if ($i == 1) {
676
        $state='WinGlobal';
677
      } else {
678
        $i--;
679
      }
680
    };
681
  } elsif ($state eq 'WinAddSlave') {
682
    WinAddSlave;
683
    if ($next == 1) {
684
      $i=1;
685
      $state='WinSlave';
686
    };
687
  } elsif ($state eq 'WinSlave') {
688
    WinSlave;
689
    if ($del == 1) {
690
      wbs_del($i);
691
      $i=1;
692
      $state='WinGlobal';
693
    } elsif ($next == 1) {
694
      if ($i eq $slaves) {
695
        $state='WinPrio';
696
      } else {
697
        $i++
698
      };
699
    } else {
700
      if ($i == 1) {
701
        $state='WinGlobal';
702
      } else {
703
        $i--;
704
      }
705
    };
706
  } elsif ($state eq 'WinPrio') {
707
    if ($interconnect eq "sharedbus") {
708
      WinPrioshb;
709
    } else {
710
      WinPriocbs;
711
    };
712
    if ($next == 1) {
713
      $state='bye';
714
    } else {
715
      $state='WinGlobal';
716
    };
717
  };
718
};
719
};
720
 
721
sub generate_defines {
722
  open(OUTFILE,"> $_[0]") or die "could not open $infile for writing";
723
  printf OUTFILE "# Generated by PERL program wishbone.pl.\n";
724
  printf OUTFILE "# File used as input for wishbone arbiter generation\n";
725
  $tmp=localtime(time);
726
  printf OUTFILE "# Generated %s\n\n",$tmp;
727
  printf OUTFILE "filename=%s\n",$outfile;
728
  printf OUTFILE "intercon=%s\n",$intercon;
729
  printf OUTFILE "syscon=%s\n",$syscon;
730
  printf OUTFILE "target=%s\n",$target;
731
  printf OUTFILE "hdl=%s\n",$hdl;
732
  printf OUTFILE "signal_groups=%s\n",$signal_groups;
733
  printf OUTFILE "tga_bits=%s\n",$tga_bits;
734
  printf OUTFILE "tgc_bits=%s\n",$tgc_bits;
735
  printf OUTFILE "tgd_bits=%s\n",$tgd_bits;
736
  printf OUTFILE "rename_tga=%s\n",$rename_tga;
737
  printf OUTFILE "rename_tgc=%s\n",$rename_tgc;
738
  printf OUTFILE "rename_tgd=%s\n",$rename_tgd;
739
  printf OUTFILE "classic=%s\n",$classic;
740
  printf OUTFILE "endofburst=%s\n",$endofburst;
741
  printf OUTFILE "dat_size=%s\n",$dat_size;
742
  printf OUTFILE "adr_size=%s\n",$adr_size;
743
  printf OUTFILE "mux_type=%s\n",$mux_type;
744
  printf OUTFILE "interconnect=%s\n",$interconnect;
745
  for ($i=1; $i le $masters; $i++) {
746
    printf OUTFILE "\nmaster %s\n",$master[$i]{"wbm"};
747
    printf OUTFILE "  type=%s\n",$master[$i]{"type"};
748
    printf OUTFILE "  lock_o=%s\n",$master[$i]{"lock_o"};
749
    printf OUTFILE "  tga_o=%s\n",$master[$i]{"tga_o"};
750
    printf OUTFILE "  tgc_o=%s\n",$master[$i]{"tgc_o"};
751
    printf OUTFILE "  tgd_o=%s\n",$master[$i]{"tgd_o"};
752
    printf OUTFILE "  err_i=%s\n",$master[$i]{"err_i"};
753
    printf OUTFILE "  rty_i=%s\n",$master[$i]{"rty_i"};
754 13 unneback
    if ($interconnect eq "sharedbus") {
755 2 unneback
      printf OUTFILE "  priority=%s\n",$master[$i]{"priority"};
756
    } else {
757
      for ($j=1; $j le $slaves; $j++) {
758
        printf OUTFILE "  priority_%s=%s\n",$slave[$j]{"wbs"},$master[$i]{"priority_".($slave[$j]{"wbs"})};
759
      };
760
    };
761
    printf OUTFILE "end master %s\n",$master[$i]{"wbm"};
762
  };
763
  for ($i=1; $i le $slaves; $i++) {
764
    printf OUTFILE "\nslave %s\n",$slave[$i]{"wbs"};
765
    printf OUTFILE "  type=%s\n",$slave[$i]{"type"};
766
    printf OUTFILE "  adr_i_hi=%s\n",$slave[$i]{"adr_i_hi"};
767
    printf OUTFILE "  adr_i_lo=%s\n",$slave[$i]{"adr_i_lo"};
768
    printf OUTFILE "  tga_i=%s\n",$slave[$i]{"tga_i"};
769
    printf OUTFILE "  tgc_i=%s\n",$slave[$i]{"tgc_i"};
770
    printf OUTFILE "  tgd_i=%s\n",$slave[$i]{"tgd_i"};
771
    printf OUTFILE "  lock_i=%s\n",$slave[$i]{"lock_i"};
772
    printf OUTFILE "  err_o=%s\n",$slave[$i]{"err_o"};
773
    printf OUTFILE "  rty_o=%s\n",$slave[$i]{"rty_o"};
774
    printf OUTFILE "  baseadr=0x%s\n",$slave[$i]{"baseadr"};
775
    printf OUTFILE "  size=0x%s\n",$slave[$i]{"size"};
776
    printf OUTFILE "  baseadr1=0x%s\n",$slave[$i]{"baseadr1"};
777
    printf OUTFILE "  size1=0x%s\n",$slave[$i]{"size1"};
778
    printf OUTFILE "  baseadr2=0x%s\n",$slave[$i]{"baseadr2"};
779
    printf OUTFILE "  size2=0x%s\n",$slave[$i]{"size2"};
780
    printf OUTFILE "end slave %s\n",$slave[$i]{"wbs"};
781
  };
782
  close(OUTFILE);
783
};
784
 
785
# print header
786
sub gen_header {
787
  printf OUTFILE "%s Generated by PERL program wishbone.pl. Do not edit this file.\n%s\n",$comment,$comment;
788
  printf OUTFILE "%s For defines see %s\n%s\n",$comment,$infile,$comment;
789
  $tmp=localtime(time);
790
  printf OUTFILE "%s Generated %s\n%s\n",$comment,$tmp,$comment;
791
  printf OUTFILE "%s Wishbone masters:\n",$comment;
792
  for ($i=1; $i le $masters; $i++) {
793
    printf OUTFILE "%s   %s\n",$comment,$master[$i]{"wbm"}; };
794
  printf OUTFILE "%s\n%s Wishbone slaves:\n",$comment,$comment;
795
  for ($i=1; $i le $slaves; $i++) {
796
    printf OUTFILE "%s   %s\n",$comment,$slave[$i]{"wbs"};
797
    if ($slave[$i]{"size"} ne ffffffff) {
798
      printf OUTFILE "%s     baseadr 0x%s - size 0x%s\n",$comment,$slave[$i]{"baseadr"},$slave[$i]{"size"}};
799
    if ($slave[$i]{"size1"} ne ffffffff) {
800
      printf OUTFILE "%s     baseadr 0x%s - size 0x%s\n",$comment,$slave[$i]{"baseadr1"},$slave[$i]{"size1"}};
801
    if ($slave[$i]{"size2"} ne ffffffff) {
802
      printf OUTFILE "%s     baseadr 0x%s - size 0x%s\n",$comment,$slave[$i]{"baseadr2"},$slave[$i]{"size2"}};
803
    if ($slave[$i]{"size3"} ne ffffffff) {
804
      printf OUTFILE "%s     baseadr 0x%s - size 0x%s\n",$comment,$slave[$i]{"baseadr3"},$slave[$i]{"size3"}};
805
  };
806
};
807
 
808
sub gen_vhdl_package {
809
  printf OUTFILE "-----------------------------------------------------------------------------------------\n";
810
  printf OUTFILE "library IEEE;\nuse IEEE.std_logic_1164.all;\n\n";
811
  printf OUTFILE "package %s_package is\n\n",$intercon;
812
 
813
  # records ?
814
  if ($signal_groups eq 1) {
815
    for ($i=1; $i le $masters; $i++) {
816
      # input record
817
      printf OUTFILE "type %s_wbm_i_type is record\n",$master[$i]{"wbm"};
818
      if ($master[$i]{"type"} =~ /(ro|rw)/) { printf OUTFILE "  dat_i : std_logic_vector(%s downto 0);\n",$master[$i]{"dat_size"}-1;};
819
      if ($master[$i]{"err_i"} eq 1) { printf OUTFILE "  err_i : std_logic;\n";};
820
      if ($master[$i]{"rty_i"} eq 1) { printf OUTFILE "  rty_i : std_logic;\n";};
821
      printf OUTFILE "  ack_i : std_logic;\n";
822
      printf OUTFILE "end record;\n";
823
      # output record
824
      printf OUTFILE "type %s_wbm_o_type is record\n",$master[$i]{"wbm"};
825
      if ($master[$i]{"type"} =~ /(wo|rw)/) {
826
        printf OUTFILE "  dat_o : std_logic_vector(%s downto 0);\n",$master[$i]{"dat_size"}-1;
827
        printf OUTFILE "  we_o  : std_logic;\n"; };
828
      if ($dat_size eq 8) {
829
        printf OUTFILE "  sel_o : std_logic;\n";
830
      } else {
831
        printf OUTFILE "  sel_o : std_logic_vector(%s downto 0);\n",$dat_size/8-1; };
832
      printf OUTFILE "  adr_o : std_logic_vector(%s downto 0);\n",$adr_size-1;
833
      if ($master[$i]{"lock_o"} eq 1) { printf OUTFILE "  lock_o : std_logic;\n";};
834
      if ($master[$i]{"tga_o"} eq 1) { printf OUTFILE "  %s_o : std_logic_vector(%s downto 0);\n",$rename_tga, $tga_bits-1;};
835
      if ($master[$i]{"tgc_o"} eq 1) { printf OUTFILE "  %s_o : std_logic_vector(%s downto 0);\n",$rename_tgc, $tgc_bits-1;};
836
      printf OUTFILE "  cyc_o : std_logic;\n";
837
      printf OUTFILE "  stb_o : std_logic;\n";
838
      printf OUTFILE "end record;\n\n";
839
    }; #end for
840
    for ($i=1; $i le $slaves; $i++) {
841
      # input record
842
      printf OUTFILE "type %s_wbs_i_type is record\n",$slave[$i]{"wbs"};
843
      if ($slave[$i]{"type"} ne "ro") {
844 4 unneback
        printf OUTFILE "  dat_i : std_logic_vector(%s downto 0);\n",$slave[$i]{"dat_size"}-1;
845 2 unneback
        printf OUTFILE "  we_i  : std_logic;\n"; };
846
      if ($dat_size eq 8) {
847
        printf OUTFILE "  sel_i : std_logic;\n";
848
      } else {
849
        printf OUTFILE "  sel_i : std_logic_vector(%s downto 0);\n",$dat_size/8-1; };
850
      if ($slave[$i]{"adr_i_hi"} gt 0) { printf OUTFILE "  adr_i : std_logic_vector(%s downto %s);\n",$slave[$i]{"adr_i_hi"},$slave[$i]{"adr_i_lo"};};
851
      if ($slave[$i]{"tga_i"} eq 1) { printf OUTFILE "  %s_i : std_logic_vector(%s downto 0);\n",$rename_tga,$tga_bits-1; };
852
      if ($slave[$i]{"tgc_i"} eq 1) { printf OUTFILE "  %s_i : std_logic_vector(%s downto 0);\n",$rename_tgc,$tgc_bits-1; };
853
      printf OUTFILE "  cyc_i : std_logic;\n";
854
      printf OUTFILE "  stb_i : std_logic;\n";
855
      printf OUTFILE "end record;\n";
856
      # output record
857
      printf OUTFILE "type %s_wbs_o_type is record\n",$slave[$i]{"wbs"};
858 4 unneback
      if ($slave[$i]{"type"} =~ /(ro|rw)/) { printf OUTFILE "  dat_o : std_logic_vector(%s downto 0);\n",$slave[$i]{"dat_size"}-1 };
859 2 unneback
      if ($slave[$i]{"rty_o"} eq 1) { printf OUTFILE "  rty_o : std_logic;\n" };
860
      if ($slave[$i]{"err_o"} eq 1) { printf OUTFILE "  err_o : std_logic;\n" };
861
      printf OUTFILE "  ack_o : std_logic;\n";
862
      printf OUTFILE "end record;\n";
863
    }; #end for
864
  }; #end if signal groups
865
 
866
  # overload of "and"
867
  printf OUTFILE "\nfunction \"and\" (\n  l : std_logic_vector;\n  r : std_logic)\nreturn std_logic_vector;\n";
868
  printf OUTFILE "end %s_package;\n",$intercon;
869
  printf OUTFILE "package body %s_package is\n",$intercon;
870
  printf OUTFILE "\nfunction \"and\" (\n  l : std_logic_vector;\n  r : std_logic)\nreturn std_logic_vector is\n";
871
  printf OUTFILE "  variable result : std_logic_vector(l'range);\n";
872
  printf OUTFILE "begin  -- \"and\"\n  for i in l'range loop\n  result(i) := l(i) and r;\nend loop;  -- i\nreturn result;\nend \"and\";\n";
873
  printf OUTFILE "end %s_package;\n",$intercon;
874
};
875
 
876
sub gen_trafic_ctrl {
877
  if ($hdl eq "vhdl") {
878
  if ($target eq "xilinx") {
879
    print OUTFILE <<EOP;
880
 
881
library IEEE;
882
use IEEE.std_logic_1164.all;
883
 
884
entity trafic_supervision is
885
 
886
  generic (
887 10 unneback
    priority     : integer := 1;
888
    tot_priority : integer := 2);
889 2 unneback
 
890
  port (
891
    bg           : in  std_logic;       -- bus grant
892
    ce           : in  std_logic;       -- clock enable
893
    trafic_limit : out std_logic;
894
    clk          : in  std_logic;
895
    reset        : in  std_logic);
896
 
897
end trafic_supervision;
898
 
899
architecture rtl of trafic_supervision is
900
 
901
  signal shreg : std_logic_vector(tot_priority-1 downto 0);
902
  signal cntr : integer range 0 to tot_priority;
903
 
904
begin  -- rtl
905
 
906
  -- purpose: holds information of usage of latest cycles
907
  -- type   : sequential
908
  -- inputs : clk, reset, ce, bg
909
  -- outputs: shreg('left)
910
  sh_reg: process (clk)
911
  begin  -- process shreg
912
    if clk'event and clk = '1' then  -- rising clock edge
913
      if ce='1' then
914
        shreg <= shreg(tot_priority-2 downto 0) & bg;
915
      end if;
916
    end if;
917
  end process sh_reg;
918
 
919
  -- purpose: keeps track of used cycles
920
  -- type   : sequential
921
  -- inputs : clk, reset, shreg('left), bg, ce
922
  -- outputs: trafic_limit
923
  counter: process (clk, reset)
924
  begin  -- process counter
925
    if reset = '1' then                 -- asynchronous reset (active hi)
926
      cntr <= 0;
927
      trafic_limit <= '0';
928
    elsif clk'event and clk = '1' then  -- rising clock edge
929
      if ce='1' then
930 4 unneback
        if bg='1' and shreg(tot_priority-1)/='1' then
931 2 unneback
          cntr <= cntr + 1;
932
          if cntr=priority-1 then
933
            trafic_limit <= '1';
934
          end if;
935
        elsif bg='0' and shreg(tot_priority-1)='1' then
936
          cntr <= cntr - 1;
937
          if cntr=priority then
938
            trafic_limit <= '0';
939
          end if;
940
        end if;
941
      end if;
942
    end if;
943
  end process counter;
944
 
945
end rtl;
946
EOP
947
  } else {
948
    print OUTFILE<<EOP;
949
library IEEE;
950
use IEEE.std_logic_1164.all;
951
 
952
entity trafic_supervision is
953
 
954
  generic (
955 11 unneback
    priority     : integer := 1;
956
    tot_priority : integer := 2);
957 2 unneback
 
958
  port (
959
    bg           : in  std_logic;       -- bus grant
960
    ce           : in  std_logic;       -- clock enable
961
    trafic_limit : out std_logic;
962
    clk          : in  std_logic;
963
    reset        : in  std_logic);
964
 
965
end trafic_supervision;
966
 
967
architecture rtl of trafic_supervision is
968
 
969
  signal shreg : std_logic_vector(tot_priority-1 downto 0);
970
  signal cntr : integer range 0 to tot_priority;
971
 
972
begin  -- rtl
973
 
974
  -- purpose: holds information of usage of latest cycles
975
  -- type   : sequential
976
  -- inputs : clk, reset, ce, bg
977
  -- outputs: shreg('left)
978
  sh_reg: process (clk,reset)
979
  begin  -- process shreg
980
    if reset = '1' then                 -- asynchronous reset (active hi)
981
      shreg <= (others=>'0');
982
    elsif clk'event and clk = '1' then  -- rising clock edge
983
      if ce='1' then
984
        shreg <= shreg(tot_priority-2 downto 0) & bg;
985
      end if;
986
    end if;
987
  end process sh_reg;
988
 
989
  -- purpose: keeps track of used cycles
990
  -- type   : sequential
991
  -- inputs : clk, reset, shreg('left), bg, ce
992
  -- outputs: trafic_limit
993
  counter: process (clk, reset)
994
  begin  -- process counter
995
    if reset = '1' then                 -- asynchronous reset (active hi)
996
      cntr <= 0;
997
      trafic_limit <= '0';
998
    elsif clk'event and clk = '1' then  -- rising clock edge
999
      if ce='1' then
1000
        if bg='1' and shreg(tot_priority-1)='0' then
1001
          cntr <= cntr + 1;
1002
          if cntr=priority-1 then
1003
            trafic_limit <= '1';
1004
          end if;
1005
        elsif bg='0' and shreg(tot_priority-1)='1' then
1006
          cntr <= cntr - 1;
1007
          if cntr=priority then
1008
            trafic_limit <= '0';
1009
          end if;
1010
        end if;
1011
      end if;
1012
    end if;
1013
  end process counter;
1014
 
1015
end rtl;
1016
EOP
1017
};
1018
} else {
1019
 
1020
};
1021
};
1022
 
1023
sub gen_entity {
1024
  # library usage
1025
  printf OUTFILE "\nlibrary IEEE;\nuse IEEE.std_logic_1164.all;\n";
1026
  printf OUTFILE "use work.%s_package.all;\n",$intercon;
1027
 
1028
  # entity intercon
1029
  printf OUTFILE "\nentity %s is\n  port (\n",$intercon;
1030
  # records
1031
  if ($signal_groups eq 1) {
1032
    # master port(s)
1033
    printf OUTFILE "  -- wishbone master port(s)\n";
1034
    for ($i=1; $i le $masters; $i++) {
1035
            printf OUTFILE "  -- %s\n",$master[$i]{"wbm"};
1036
      printf OUTFILE "  %s_wbm_i : out %s_wbm_i_type;\n",$master[$i]{"wbm"},$master[$i]{"wbm"};
1037
      printf OUTFILE "  %s_wbm_o : in  %s_wbm_o_type;\n",$master[$i]{"wbm"},$master[$i]{"wbm"};
1038
    }; #end for
1039
    # slave port(s)
1040
    printf OUTFILE "  -- wishbone slave port(s)\n";
1041
    for ($i=1; $i le $slaves; $i++) {
1042
      printf OUTFILE "  -- %s\n",$slave[$i]{"wbs"};
1043
      printf OUTFILE "  %s_wbs_i : out %s_wbs_i_type;\n",$slave[$i]{"wbs"},$slave[$i]{"wbs"};
1044
      printf OUTFILE "  %s_wbs_o : in %s_wbs_o_type;\n",$slave[$i]{"wbs"},$slave[$i]{"wbs"};
1045
    };
1046
  # separate signals
1047
  } else {
1048
    printf OUTFILE "  -- wishbone master port(s)\n";
1049
    for ($i=1; $i le $masters; $i++) {
1050
      printf OUTFILE "  -- %s\n",$master[$i]{"wbm"};
1051
      if ($master[$i]{"type"} ne "wo") {
1052
        printf OUTFILE "  %s_dat_i : out std_logic_vector(%s downto 0);\n",$master[$i]{"wbm"},$dat_size-1; };
1053
      printf OUTFILE "  %s_ack_i : out std_logic;\n",$master[$i]{"wbm"};
1054
      if ($master[$i]{"err_i"} eq 1) {
1055
        printf OUTFILE "  %s_err_i : out std_logic;\n",$master[$i]{"wbm"}; };
1056
      if ($master[$i]{"rty_i"} eq 1) {
1057
        printf OUTFILE "  %s_rty_i : out std_logic;\n",$master[$i]{"wbm"}; };
1058
      if ($master[$i]{"type"} ne "ro") {
1059
        printf OUTFILE "  %s_dat_o : in  std_logic_vector(%s downto 0);\n",$master[$i]{"wbm"},$dat_size-1;
1060
        printf OUTFILE "  %s_we_o  : in  std_logic;\n",$master[$i]{"wbm"};
1061
      };
1062
      if ($dat_size ge 16) {
1063
        printf OUTFILE "  %s_sel_o : in  std_logic_vector(%s downto 0);\n",$master[$i]{"wbm"},$dat_size/8-1; };
1064
      printf OUTFILE "  %s_adr_o : in  std_logic_vector(%s downto 0);\n",$master[$i]{"wbm"},$adr_size-1;
1065
      if ($master[$i]{"tgc_o"} eq 1) {
1066
        printf OUTFILE "  %s_%s_o : in  std_logic_vector(%s downto 0);\n",$master[$i]{"wbm"},$rename_tgc,$tgc_bits-1; };
1067
      if ($master[$i]{"tga_o"} eq 1) {
1068
        printf OUTFILE "  %s_%s_o : in  std_logic_vector(%s downto 0);\n",$master[$i]{"wbm"},$rename_tga,$tga_bits-1; };
1069
      printf OUTFILE "  %s_cyc_o : in  std_logic;\n",$master[$i]{"wbm"};
1070
      printf OUTFILE "  %s_stb_o : in  std_logic;\n",$master[$i]{"wbm"};
1071
    };
1072
    printf OUTFILE "  -- wishbone slave port(s)\n";
1073
    for ($i=1; $i le $slaves; $i++) {
1074
      printf OUTFILE "  -- %s\n",$slave[$i]{"wbs"};
1075
      if ($slave[$i]{"type"} ne "wo") {
1076
        printf OUTFILE "  %s_dat_o : in  std_logic_vector(%s downto 0);\n",$slave[$i]{"wbs"},$dat_size-1; };
1077
      printf OUTFILE "  %s_ack_o : in  std_logic;\n",$slave[$i]{"wbs"};
1078
      if ($slave[$i]{"err_o"} eq 1) {
1079
        printf OUTFILE "  %s_err_o : in  std_logic;\n",$slave[$i]{"wbs"}; };
1080
      if ($slave[$i]{"rty_o"} eq 1) {
1081
        printf OUTFILE "  %s_rty_o : in  std_logic;\n",$slave[$i]{"wbs"}; };
1082
      if ($slave[$i]{"type"} ne "ro") {
1083
        printf OUTFILE "  %s_dat_i : out std_logic_vector(%s downto 0);\n",$slave[$i]{"wbs"},$dat_size-1;
1084
        printf OUTFILE "  %s_we_i  : out std_logic;\n",$slave[$i]{"wbs"};
1085
      };
1086
      if ($dat_size ge 16) {
1087
        printf OUTFILE "  %s_sel_i : out std_logic_vector(%s downto 0);\n",$slave[$i]{"wbs"},$dat_size/8-1; };
1088
      printf OUTFILE "  %s_adr_i : out std_logic_vector(%s downto %s);\n",$slave[$i]{"wbs"},$slave[$i]{"adr_i_hi"},$slave[$i]{"adr_i_lo"};
1089
      if ($slave[$i]{"tgc_i"} eq 1) {
1090
        printf OUTFILE "  %s_%s_i : out std_logic_vector(%s downto 0);\n",$slave[$i]{"wbs"},$rename_tgc,$tgc_bits-1; };
1091
      if ($slave[$i]{"tga_i"} eq 1) {
1092
        printf OUTFILE "  %s_%s_i : out std_logic_vector(%s downto 0);\n",$slave[$i]{"wbs"},$rename_tga,$tga_bits-1; };
1093
      printf OUTFILE "  %s_cyc_i : out std_logic;\n",$slave[$i]{"wbs"};
1094
      printf OUTFILE "  %s_stb_i : out std_logic;\n",$slave[$i]{"wbs"};
1095
    };
1096
  };
1097
  # clock and reset
1098
  printf OUTFILE "  -- clock and reset\n";
1099
  printf OUTFILE "  clk   : in std_logic;\n";
1100
  printf OUTFILE "  reset : in std_logic);\n";
1101
  printf OUTFILE "end %s;\n",$intercon;
1102
};
1103
 
1104
 
1105
# generate signals for remapping (for records)
1106
sub gen_sig_remap {
1107
  sub gen_sig_dec {
1108
    if ($_[1] gt 0) {
1109
      printf OUTFILE "  signal %s : std_logic_vector(%s downto %s);\n",$_[0],$_[1]-1,$_[2];
1110
    } else {
1111
      printf OUTFILE "  signal %s : std_logic;\n",$_[0];
1112
    };
1113
  };
1114
    for ($i=1; $i le $masters; $i++) {
1115
      if ($master[$i]{"type"} ne "wo") {
1116
        gen_sig_dec($master[$i]{"wbm"}.'_dat_i',$dat_size,0); };
1117
      gen_sig_dec($master[$i]{"wbm"}.'_ack_i');
1118
      if ($master[$i]{"err_i"} eq 1) {
1119
        gen_sig_dec($master[$i]{"wbm"}.'_err_i'); };
1120
      if ($master[$i]{"rty_i"} eq 1) {
1121
        gen_sig_dec($master[$i]{"wbm"}.'_rty_i') };
1122
      if ($master[$i]{"type"} ne "ro") {
1123
        gen_sig_dec($master[$i]{"wbm"}.'_dat_o',$dat_size,0);
1124
        gen_sig_dec($master[$i]{"wbm"}.'_we_o ');
1125
      };
1126
      if ($dat_size > 8) {
1127
        gen_sig_dec($master[$i]{"wbm"}.'_sel_o',$dat_size/8,0); };
1128
      gen_sig_dec($master[$i]{"wbm"}.'_adr_o',$adr_size,0);
1129
      if ($master[$i]{"tga_o"} eq 1) {
1130
        gen_sig_dec($master[$i]{"wbm"}.'_'.$rename_tga.'_o',$tga_bits,0); };
1131
      if ($master[$i]{"tgc_o"} eq 1) {
1132
        gen_sig_dec($master[$i]{"wbm"}.'_'.$rename_tgc.'_o',$tgc_bits,0); };
1133
      if ($master[$i]{"tgd_o"} eq 1) {
1134
        gen_sig_dec($master[$i]{"wbm"}.'_'.$rename_tgd.'_o',$tgd_bits,0); };
1135
      gen_sig_dec($master[$i]{"wbm"}.'_cyc_o');
1136
      gen_sig_dec($master[$i]{"wbm"}.'_stb_o');
1137
    };
1138
    for ($i=1; $i le $slaves; $i++) {
1139
      if ($slave[$i]{"type"} ne "wo") {
1140
        gen_sig_dec($slave[$i]{"wbs"}.'_dat_o',$dat_size,0); };
1141
      gen_sig_dec($slave[$i]{"wbs"}.'_ack_o');
1142
      if ($slave[$i]{"err_o"} eq 1) {
1143
        gen_sig_dec($slave[$i]{"wbs"}.'_err_o'); };
1144
      if ($slave[$i]{"rty_o"} eq 1) {
1145
        gen_sig_dec($slave[$i]{"wbs"}.'_rty_o'); };
1146
      if ($slave[$i]{"type"} ne "ro") {
1147
        gen_sig_dec($slave[$i]{"wbs"}.'_dat_i',$dat_size,0);
1148
        gen_sig_dec($slave[$i]{"wbs"}.'_we_i ');
1149
      };
1150
      if ($dat_size > 8) {
1151
        gen_sig_dec($slave[$i]{"wbs"}.'_sel_i',$dat_size/8,0); };
1152
      gen_sig_dec($slave[$i]{"wbs"}.'_adr_i',$slave[$i]{"adr_i_hi"}+1,$slave[$i]{"adr_i_lo"});
1153
      if ($slave[$i]{"tga_i"} eq 1) {
1154
        gen_sig_dec($slave[$i]{"wbs"}.'_'.$rename_tga.'_i',$tga_bits,0); };
1155
      if ($slave[$i]{"tgc_i"} eq 1) {
1156
        gen_sig_dec($slave[$i]{"wbs"}.'_'.$rename_tgc.'_i',$tgc_bits,0); };
1157
      if ($slave[$i]{"tgd_i"} eq 1) {
1158
        gen_sig_dec($slave[$i]{"wbs"}.'_'.$rename_tgd.'_i',$tgd_bits,0); };
1159
      gen_sig_dec($slave[$i]{"wbs"}.'_cyc_i');
1160
      gen_sig_dec($slave[$i]{"wbs"}.'_stb_i');
1161
    };
1162
};
1163
 
1164
sub gen_global_signals {
1165
  # single master
1166
  if ($masters eq 1) {
1167
    # slave select for generation of stb_i to slaves
1168
    for ($i=1; $i le $slaves; $i++) {
1169
      printf OUTFILE "  signal %s_ss : std_logic; -- slave select\n",$slave[$i]{"wbs"}; };
1170
  # shared bus
1171
  } elsif ($interconnect eq "sharedbus") {
1172
    # bus grant
1173
    for ($i=1; $i le $masters; $i++) {
1174
      printf OUTFILE "  signal %s_bg : std_logic; -- bus grant\n",$master[$i]{"wbm"}; };
1175
    # slave select for generation of stb_i to slaves
1176
    for ($i=1; $i le $slaves; $i++) {
1177
      printf OUTFILE "  signal %s_ss : std_logic; -- slave select\n",$slave[$i]{"wbs"}; };
1178
  # crossbarswitch
1179
  } else {
1180
    for ($i=1; $i le $masters; $i++) {
1181
      for ($j=1; $j le $slaves; $j++) {
1182
        if ($master[$i]{("priority_".($slave[$j]{"wbs"}))} ne 0) {
1183
          printf OUTFILE "  signal %s_%s_ss : std_logic; -- slave select\n",$master[$i]{"wbm"},$slave[$j]{"wbs"};
1184
          printf OUTFILE "  signal %s_%s_bg : std_logic; -- bus grant\n",$master[$i]{"wbm"},$slave[$j]{"wbs"};
1185
        };
1186
      };
1187
    };
1188
  };
1189
};
1190
 
1191
sub gen_arbiter {
1192
  # out: wbm_bg (bus grant)
1193
  if ($masters eq 1) {
1194
    # ack_i
1195
    # cyc_i
1196
    # printf OUTFILE "%s_bg <= %s_cyc_o;\n",$master[1]{"wbm"},$master[1]{"wbm"};
1197
  # sharedbus
1198
  } elsif ($interconnect eq "sharedbus") {
1199
    printf OUTFILE "arbiter_sharedbus: block\n";
1200
    for ($i=1; $i le $masters; $i++) {
1201
      printf OUTFILE "  signal %s_bg_1, %s_bg_2, %s_bg_q : std_logic;\n",$master[$i]{"wbm"},$master[$i]{"wbm"},$master[$i]{"wbm"}; };
1202
    for ($i=1; $i le $masters; $i++) {
1203
      printf OUTFILE "  signal %s_trafic_ctrl_limit : std_logic;\n",$master[$i]{"wbm"}; };
1204
    printf OUTFILE "  signal ack, ce, idle :std_logic;\n";
1205
    printf OUTFILE "begin -- arbiter\n";
1206
    printf OUTFILE "ack <= %s_ack_o",$slave[1]{"wbs"};
1207
    for ($i=2; $i le $slaves; $i++) {
1208
      printf OUTFILE " or %s_ack_o",$slave[$i]{"wbs"}; };
1209
    printf OUTFILE ";\n";
1210
    # instantiate trafic_supervision(s)
1211
    for ($i=1; $i le $masters; $i++) {
1212
      printf OUTFILE "\ntrafic_supervision_%s : entity work.trafic_supervision\n",$i;
1213
      printf OUTFILE "generic map(\n";
1214
      printf OUTFILE "  priority => %s,\n",$master[$i]{"priority"};
1215
      printf OUTFILE "  tot_priority => %s)\n",$priority;
1216
      printf OUTFILE "port map(\n";
1217
      printf OUTFILE "  bg => %s_bg,\n",$master[$i]{"wbm"};
1218
      printf OUTFILE "  ce => ce,\n";
1219
      printf OUTFILE "  trafic_limit => %s_trafic_ctrl_limit,\n",$master[$i]{"wbm"};
1220
      printf OUTFILE "  clk => clk,\n";
1221
      printf OUTFILE "  reset => reset);\n"; };
1222
    # _bg_q
1223
    # bg eq 1 => set
1224
    # end of cycle => reset
1225
    for ($i=1; $i le $masters; $i++) {
1226
      printf OUTFILE "\nprocess(clk,reset)\nbegin\nif reset='1' then\n";
1227
      printf OUTFILE "  %s_bg_q <= '0';\n",$master[$i]{"wbm"};
1228
      printf OUTFILE "elsif clk'event and clk='1' then\n";
1229
      printf OUTFILE "if %s_bg_q='0' then\n",$master[$i]{"wbm"};
1230
      printf OUTFILE "  %s_bg_q <= %s_bg;\n",$master[$i]{"wbm"},$master[$i]{"wbm"};
1231
      printf OUTFILE "elsif ack='1'";
1232
      if ($master[$i]{"tgc_o"} eq 1) {
1233
        printf OUTFILE " and (%s_%s_o=\"%s\" or %s_%s_o=\"%s\")",$master[$i]{"wbm"},$rename_tgc,$classic,$master[$i]{"wbm"},$rename_tgc,$endofburst; };
1234
      printf OUTFILE " then\n  %s_bg_q <= '0';\nend if;\nend if;\nend process;\n",$master[$i]{"wbm"};
1235
    }; # end for
1236
    # _bg
1237
    printf OUTFILE "\nidle <= '1' when %s_bg_q='0'",$master[1]{"wbm"};
1238
    for ($i=2; $i le $masters; $i++) {
1239
      printf OUTFILE " and %s_bg_q='0'",$master[$i]{"wbm"}; };
1240
    printf OUTFILE " else '0';\n";
1241
    printf OUTFILE "%s_bg_1 <= '1' when idle='1' and %s_cyc_o='1' and %s_trafic_ctrl_limit='0' else '0';\n",$master[1]{"wbm"},$master[1]{"wbm"},$master[1]{"wbm"};
1242 7 unneback
    $depend = $master[1]{"wbm"}."_bg_1='0'";
1243 2 unneback
    for ($i=2; $i le $masters; $i++) {
1244 7 unneback
      printf OUTFILE "%s_bg_1 <= '1' when idle='1' and %s_cyc_o='1' and %s_trafic_ctrl_limit='0' and (%s) else '0';\n",$master[$i]{"wbm"},$master[$i]{"wbm"},$master[$i]{"wbm"},$depend;
1245
      $depend = $depend." and ".$master[$i]{"wbm"}."_bg_1='0'";
1246
    };
1247
 
1248
    printf OUTFILE "%s_bg_2 <= '1' when idle='1' and (%s) and %s_cyc_o='1' else '0';\n",$master[1]{"wbm"},$depend,$master[1]{"wbm"};
1249
    $depend = $depend." and ".$master[1]{"wbm"}."_bg_2='0'";
1250 2 unneback
    for ($i=2; $i le $masters; $i++) {
1251 7 unneback
      printf OUTFILE "%s_bg_2 <= '1' when idle='1' and (%s) and %s_cyc_o='1' else '0';\n",$master[$i]{"wbm"},$depend,$master[$i]{"wbm"};
1252
      $depend = $depend." and ".$master[$i]{"wbm"}."_bg_2='0'";
1253
    };
1254 2 unneback
    for ($i=1; $i le $masters; $i++) {
1255 7 unneback
      printf OUTFILE "%s_bg <= %s_bg_q or %s_bg_1 or %s_bg_2;\n",$master[$i]{"wbm"},$master[$i]{"wbm"},$master[$i]{"wbm"},$master[$i]{"wbm"}; };
1256 2 unneback
    # ce
1257
    printf OUTFILE "ce <= %s_cyc_o",$master[1]{"wbm"};
1258
    for ($i=2; $i le $masters; $i++) {
1259
      printf OUTFILE " or %s_cyc_o",$master[$i]{"wbm"}; };
1260
    printf OUTFILE " when idle='1' else '0';\n\n";
1261
    # thats it
1262
    printf OUTFILE "end block arbiter_sharedbus;\n\n";
1263
  # interconnect crossbarswitch
1264
  } else {
1265
    for ($j=1; $j le $slaves; $j++) {
1266
      # single master ?
1267
      $tmp=0;
1268
      for ($l=1; $l le $masters; $l++) {
1269
        if ($master[$l]{("priority_".($slave[$j]{"wbs"}))} ne 0) {
1270
          $only_master = $l;
1271
          $tmp++;
1272
        };
1273
      };
1274
      if ($tmp == 1) {
1275
        printf OUTFILE "%s_%s_bg <= %s_%s_ss and %s_cyc_o;\n",$master[$only_master]{"wbm"},$slave[$j]{"wbs"},$master[$only_master]{"wbm"},$slave[$j]{"wbs"},$master[$only_master]{"wbm"};
1276
      } else {
1277
        printf OUTFILE "arbiter_%s : block\n",$slave[$j]{"wbs"};
1278
        for ($i=1; $i le $masters; $i++) {
1279
          if ($master[$i]{("priority_".($slave[$j]{"wbs"}))} ne 0) {
1280
            printf OUTFILE "  signal %s_bg, %s_bg_1, %s_bg_2, %s_bg_q : std_logic;\n",$master[$i]{"wbm"},$master[$i]{"wbm"},$master[$i]{"wbm"},$master[$i]{"wbm"};
1281
            printf OUTFILE "  signal %s_trafic_limit : std_logic;\n",$master[$i]{"wbm"};
1282
          };
1283
        };
1284
        printf OUTFILE "  signal ce, idle, ack : std_logic;\n";
1285
        printf OUTFILE "begin\n";
1286
        printf OUTFILE "ack <= %s_ack_o;\n",$slave[$j]{"wbs"};
1287
        # instantiate trafic_supervision(s)
1288
        # calc tot priority per slave
1289
        $priority = 0;
1290
        for ($i=1; $i le $masters; $i++) {
1291
          $priority += $master[$i]{("priority_".($slave[$j]{"wbs"}))}; };
1292
        for ($i=1; $i le $masters; $i++) {
1293
          if ($master[$i]{("priority_".($slave[$j]{"wbs"}))} ne 0) {
1294
            printf OUTFILE "\ntrafic_supervision_%s : entity work.trafic_supervision\n",$i;
1295
            printf OUTFILE "generic map(\n";
1296
            printf OUTFILE "  priority => %s,\n",$master[$i]{("priority_".($slave[$j]{"wbs"}))};
1297
            printf OUTFILE "  tot_priority => %s)\n",$priority;
1298
            printf OUTFILE "port map(\n";
1299
            printf OUTFILE "  bg => %s_%s_bg,\n",$master[$i]{"wbm"},$slave[$j]{"wbs"};
1300
            printf OUTFILE "  ce => ce,\n";
1301
            printf OUTFILE "  trafic_limit => %s_trafic_limit,\n",$master[$i]{"wbm"};
1302
            printf OUTFILE "  clk => clk,\n";
1303
            printf OUTFILE "  reset => reset);\n";
1304
          };
1305
        };
1306
        # _bg_q
1307
        # bg eq 1 => set
1308
        # end of cycle => reset
1309
        for ($i=1; $i le $masters; $i++) {
1310
          if ($master[$i]{("priority_".($slave[$j]{"wbs"}))} ne 0) {
1311
            printf OUTFILE "\nprocess(clk,reset)\nbegin\nif reset='1' then\n";
1312
            printf OUTFILE "  %s_bg_q <= '0';\n",$master[$i]{"wbm"};
1313
            printf OUTFILE "elsif clk'event and clk='1' then\n";
1314
            printf OUTFILE "if %s_bg_q='0' then\n",$master[$i]{"wbm"};
1315
            printf OUTFILE "  %s_bg_q <= %s_bg;\n",$master[$i]{"wbm"},$master[$i]{"wbm"};
1316
            printf OUTFILE "elsif ack='1'";
1317
            if ($master[$i]{"tgc_o"} eq 1) {
1318
              printf OUTFILE " and (%s_%s_o=\"%s\" or %s_%s_o=\"%s\")",$master[$i]{"wbm"},$rename_tgc,$classic,$master[$i]{"wbm"},$rename_tgc,$endofburst; };
1319
            printf OUTFILE " then\n  %s_bg_q <= '0';\nend if;\nend if;\nend process;\n",$master[$i]{"wbm"};
1320
          };
1321
        }; # end for
1322
        # _bg
1323 7 unneback
        $depend = "";
1324 2 unneback
        $tmp=1; until ($master[$tmp]{("priority_".($slave[$j]{"wbs"}))} ne 0) {$tmp++};
1325
        printf OUTFILE "\nidle <= '1' when %s_bg_q='0'",$master[$tmp]{"wbm"};
1326
        for ($i=$tmp+1; $i le $masters; $i++) {
1327
          if ($master[$i]{("priority_".($slave[$j]{"wbs"}))} ne 0) {
1328
            printf OUTFILE " and %s_bg_q='0'",$master[$i]{"wbm"};
1329
          };
1330
        };
1331
        printf OUTFILE " else '0';\n";
1332
        printf OUTFILE "%s_bg_1 <= '1' when idle='1' and %s_cyc_o='1' and %s_%s_ss='1' and %s_trafic_limit='0' else '0';\n",$master[$tmp]{"wbm"},$master[$tmp]{"wbm"},$master[$tmp]{"wbm"},$slave[$j]{"wbs"},$master[$tmp]{"wbm"};
1333 7 unneback
        $depend = $master[$tmp]{"wbm"}."_bg_1='0'",;
1334 2 unneback
        for ($i=$tmp+1; $i le $masters; $i++) {
1335
          if ($master[$i]{("priority_".($slave[$j]{"wbs"}))} ne 0) {
1336 7 unneback
            printf OUTFILE "%s_bg_1 <= '1' when idle='1' and (%s) and %s_cyc_o='1' and %s_%s_ss='1' and %s_trafic_limit='0' else '0';\n",$master[$i]{"wbm"},$depend,$master[$i]{"wbm"},$master[$i]{"wbm"},$slave[$j]{"wbs"},$master[$i]{"wbm"},$slave[$j]{"wbs"},$master[$i]{"wbm"};;
1337
            $depend = $depend." and ".$master[$i]{"wbm"}."_bg_1='0'";
1338 2 unneback
          };
1339
        };
1340 7 unneback
        printf OUTFILE "%s_bg_2 <= '1' when idle='1' and (%s) and %s_cyc_o='1' and %s_%s_ss='1' else '0';\n",$master[$tmp]{"wbm"},$depend,$master[$tmp]{"wbm"},$master[$tmp]{"wbm"},$slave[$j]{"wbs"};
1341
        $depend = $depend." and ".$master[$tmp]{"wbm"}."_bg_2='0'";
1342 2 unneback
        $tmp1 = $tmp;
1343
        for ($i=$tmp+1; $i le $masters; $i++) {
1344
          if ($master[$i]{("priority_".($slave[$j]{"wbs"}))} ne 0) {
1345 7 unneback
            printf OUTFILE "%s_bg_2 <= '1' when idle='1' and (%s) and %s_cyc_o='1' and %s_%s_ss='1' else '0';\n",$master[$i]{"wbm"},$depend,$master[$i]{"wbm"},$master[$i]{"wbm"},$slave[$j]{"wbs"};
1346
          $depend = $depend." and ".$master[$i]{"wbm"}."_bg_2='0'";
1347 2 unneback
          };
1348
        };
1349
        for ($i=1; $i le $masters; $i++) {
1350
          if ($master[$i]{("priority_".($slave[$j]{"wbs"}))} ne 0) {
1351
            printf OUTFILE "%s_bg <= %s_bg_q or %s_bg_1 or %s_bg_2;\n",$master[$i]{"wbm"},$master[$i]{"wbm"},$master[$i]{"wbm"},$master[$i]{"wbm"};
1352
          };
1353
        };
1354
        # ce
1355
        $tmp=1; until ($master[$tmp]{("priority_".($slave[$j]{"wbs"}))} ne 0) {$tmp++};
1356
        printf OUTFILE "ce <= (%s_cyc_o and %s_%s_ss)",$master[$tmp]{"wbm"},$master[$tmp]{"wbm"},$slave[$j]{"wbs"};
1357
          for ($i=$tmp+1; $i le $masters; $i++) {
1358
            if ($master[$i]{("priority_".($slave[$j]{"wbs"}))} ne 0) {
1359
              printf OUTFILE " or (%s_cyc_o and %s_%s_ss)",$master[$i]{"wbm"},$master[$i]{"wbm"},$slave[$j]{"wbs"};
1360
            };
1361
          };
1362
        printf OUTFILE " when idle='1' else '0';\n";
1363
        # global bg
1364
        for ($i=1; $i le $masters; $i++) {
1365
          if ($master[$i]{("priority_".($slave[$j]{"wbs"}))} ne 0) {
1366
            printf OUTFILE "%s_%s_bg <= %s_bg;\n",$master[$i]{"wbm"},$slave[$j]{"wbs"},$master[$i]{"wbm"};
1367
          };
1368
        };
1369
        printf OUTFILE "end block arbiter_%s;\n",$slave[$j]{"wbs"};
1370
      };
1371
    };
1372
  }; #end if
1373
};
1374
 
1375
sub gen_adr_decoder{
1376
  printf OUTFILE "decoder:block\n";
1377
  if ($interconnect eq "sharedbus") {
1378
    printf OUTFILE "  signal adr : std_logic_vector(%s downto 0);\n",$adr_size-1;
1379
    printf OUTFILE "begin\n";
1380
    # adr
1381
    printf OUTFILE "adr <= (%s_adr_o and %s_bg)",$master[1]{"wbm"},$master[1]{"wbm"};
1382
    if ($masters gt 1){
1383
      for ($i=2; $i le $masters; $i++) {
1384
        printf OUTFILE " or (%s_adr_o and %s_bg)",$master[$i]{"wbm"},$master[$i]{"wbm"}; };
1385
    };
1386
    printf OUTFILE ";\n";
1387
    # slave select
1388
    for ($i=1; $i le $slaves; $i++) {
1389
      printf OUTFILE "%s_ss <= '1' when adr(%s downto %s)=\"",$slave[$i]{"wbs"}, $adr_size-1,log(hex($slave[$i]{"size"}))/log(2);
1390
      $slave[$i]{"baseadr"}=hex($slave[$i]{"baseadr"});
1391
      for ($j=$adr_size-1; $j ge (log(hex($slave[$i]{"size"}))/log(2)); $j--) {
1392
        if (($slave[$i]{"baseadr"}) >= (2**$j)) {
1393
          $slave[$i]{"baseadr"} -= 2**$j;
1394
          printf OUTFILE "1";
1395
        } else {
1396
          printf OUTFILE "0";
1397
        };
1398
      };
1399
      printf OUTFILE "\"";
1400
      # 1
1401
      if ($slave[$i]{"size1"} ne "ffffffff") {
1402
        printf OUTFILE " else\n'1' when adr(%s downto %s)=\"",$adr_size-1,log(hex($slave[$i]{"size1"}))/log(2);
1403
        $slave[$i]{"baseadr1"}=hex($slave[$i]{"baseadr1"});
1404
        for ($j=$adr_size-1; $j ge (log(hex($slave[$i]{"size1"}))/log(2)); $j--) {
1405
                      if (($slave[$i]{"baseadr1"}) >= (2**$j)) {
1406
            $slave[$i]{"baseadr1"} -= 2**$j;
1407
            printf OUTFILE "1";
1408
                      } else {
1409
                        printf OUTFILE "0";
1410
                      }; # end if
1411
        }; # end for
1412
        printf OUTFILE "\"";
1413
      };
1414
      # 2
1415
      if ($slave[$i]{"size2"} ne "ffffffff") {
1416
        printf OUTFILE " else\n'1' when adr(%s downto %s)=\"",$adr_size-1,log(hex($slave[$i]{"size2"}))/log(2);
1417
        $slave[$i]{"baseadr2"}=hex($slave[$i]{"baseadr2"});
1418
        for ($j=$adr_size-1; $j ge (log(hex($slave[$i]{"size2"}))/log(2)); $j--) {
1419
                      if (($slave[$i]{"baseadr2"}) >= (2**$j)) {
1420
                        $slave[$i]{"baseadr2"} -= 2**$j;
1421
                        printf OUTFILE "1";
1422
                      } else {
1423
                        printf OUTFILE "0";
1424
                      };
1425
        };
1426
        printf OUTFILE "\"";
1427
      };
1428
      # 3
1429
      if ($slave[$i]{"size3"} ne "ffffffff") {
1430
        printf OUTFILE " else\n'1' when adr(%s downto %s)=\"",$adr_size-1,log(hex($slave[$i]{"size3"}))/log(2);
1431
        $slave[$i]{"baseadr3"}=hex($slave[$i]{"baseadr3"});
1432
        for ($j=$adr_size-1; $j ge (log(hex($slave[$i]{"size3"}))/log(2)); $j--) {
1433
                      if (($slave[$i]{"baseadr3"}) >= (2**$j)) {
1434
            $slave[$i]{"baseadr3"} -= 2**$j;
1435
                        printf OUTFILE "1";
1436
                      } else {
1437
                        printf OUTFILE "0";
1438
                      };
1439
        };
1440
        printf OUTFILE "\"";
1441
      };
1442
      printf OUTFILE " else\n'0';\n";
1443
      # adr to slaves
1444
    };
1445
    for ($i=1; $i le $slaves; $i++) {
1446
      printf OUTFILE "%s_adr_i <= adr(%s downto %s);\n",$slave[$i]{"wbs"},$slave[$i]{"adr_i_hi"},$slave[$i]{"adr_i_lo"}; };
1447
  # crossbar switch
1448
  } else {
1449
    printf OUTFILE "begin\n";
1450
    # master_slave_ss
1451
#    $j=0;
1452
    for ($i=1; $i le $masters; $i++) {
1453
      $slave[$j]{"baseadr"}=hex($slave[$j]{"baseadr"});
1454
      for ($j=1; $j le $slaves; $j++) {
1455
        if ($master[$i]{("priority_".($slave[$j]{"wbs"}))} ne 0) {
1456
        printf OUTFILE "%s_%s_ss <= '1' when %s_adr_o(%s downto %s)=\"",$master[$i]{"wbm"},$slave[$j]{"wbs"},$master[$i]{"wbm"},$adr_size-1,log(hex($slave[$j]{"size"}))/log(2);
1457
        $tmp=hex($slave[$j]{"baseadr"});
1458
        for ($k=$adr_size-1; $k ge (log(hex($slave[$j]{"size"}))/log(2)); $k--) {
1459
          if ($tmp >= (2**$k)) {
1460
            $tmp -= 2**$k;
1461
            printf OUTFILE "1";
1462
          } else {
1463
            printf OUTFILE "0";
1464
          };
1465
        };
1466
        printf OUTFILE "\"";
1467
        # 2?
1468
        if ($slave[$j]{"size1"} ne "ffffffff") {
1469
          printf OUTFILE " else\n'1' when %s_adr_o(%s downto %s)=\"",$master[$i]{"wbm"},$adr_size-1,log(hex($slave[$j]{"size1"}))/log(2);
1470
          $tmp=hex($slave[$j]{"baseadr1"});
1471
          for ($k=$adr_size-1; $k ge (log(hex($slave[$j]{"size1"}))/log(2)); $k--) {
1472
                        if ($tmp >= (2**$k)) {
1473
                          $tmp -= 2**$k;
1474
                          printf OUTFILE "1";
1475
                        } else {
1476
                          printf OUTFILE "0";
1477
                        };
1478
          };
1479
          printf OUTFILE "\"";
1480
        };
1481
        # 3?
1482
        if ($slave[$j]{"size2"} ne "ffffffff") {
1483
          printf OUTFILE " else\n'1' when %s_adr_o(%s downto %s)=\"",$master[$i]{"wbm"},$adr_size-1,log(hex($slave[$j]{"size2"}))/log(2);
1484
          $tmp=hex($slave[$j]{"baseadr2"});
1485
          for ($k=$adr_size-1; $k ge (log(hex($slave[$j]{"size2"}))/log(2)); $k--) {
1486
                        if ($tmp >= (2**$k)) {
1487
                          $tmp -= 2**$k;
1488
                          printf OUTFILE "1";
1489
                        } else {
1490
                          printf OUTFILE "0";
1491
                        };
1492
          };
1493
          printf OUTFILE "\"";
1494
        };
1495
        printf OUTFILE " else \n'0';\n";
1496
        }; #if
1497
      };
1498
    };
1499
    # _adr_o
1500
    for ($i=1; $i le $slaves; $i++) {
1501
      # mux ?
1502
      $tmp=0;
1503
      for ($l=1; $l le $masters; $l++) {
1504
        if ($master[$l]{("priority_".($slave[$i]{"wbs"}))} ne 0) {
1505
          $tmp++;
1506
        };
1507
      };
1508
      if ($tmp eq 1) {
1509
        $k=1; until ($master[$k]{("priority_".($slave[$i]{"wbs"}))} ne 0) {$k++};
1510
        printf OUTFILE "%s_adr_i <= %s_adr_o(%s downto %s);\n",$slave[$i]{"wbs"},$master[$k]{"wbm"},$slave[$i]{"adr_i_hi"},$slave[$i]{"adr_i_lo"};
1511
      } else {
1512
        $k=1; until ($master[$k]{("priority_".($slave[$i]{"wbs"}))} ne 0) {$k++};
1513
        printf OUTFILE "%s_adr_i <= (%s_adr_o(%s downto %s) and %s_%s_bg)",$slave[$i]{"wbs"},$master[$k]{"wbm"},$slave[$i]{"adr_i_hi"},$slave[$i]{"adr_i_lo"},$master[$k]{"wbm"},$slave[$i]{"wbs"};
1514
        for ($j=$k+1; $j le $masters; $j++) {
1515
          if ($master[$j]{("priority_".($slave[$i]{"wbs"}))} ne 0) {
1516
            printf OUTFILE " or (%s_adr_o(%s downto %s) and %s_%s_bg)",$master[$j]{"wbm"},$slave[$i]{"adr_i_hi"},$slave[$i]{"adr_i_lo"},$master[$j]{"wbm"},$slave[$i]{"wbs"};
1517
          };
1518
        };
1519
        printf OUTFILE ";\n";
1520
      };
1521
    };
1522
  };
1523
  printf OUTFILE "end block decoder;\n\n";
1524
};
1525
 
1526
sub gen_muxshb{
1527
    printf OUTFILE "mux: block\n";
1528
    printf OUTFILE "  signal cyc, stb, we, ack : std_logic;\n";
1529
    if (($rty_i gt 0) && ($rty_o gt 1)) {
1530
      printf OUTFILE "  signal rty : std_logic;\n"; };
1531
    if (($err_i gt 0) && ($err_o gt 1)) {
1532
      printf OUTFILE "  signal err : std_logic;\n"; };
1533
    if ($dat_size eq 8) {
1534
      printf OUTFILE "  signal sel : std_logic;\n";
1535
    } else {
1536
      printf OUTFILE "  signal sel : std_logic_vector(%s downto 0);\n",$dat_size/8-1;
1537
    };
1538
    printf OUTFILE "  signal dat_m2s, dat_s2m : std_logic_vector(%s downto 0);\n",$dat_size-1;
1539
    if (($tgc_o gt 0) && ($tgc_i gt 0)) {
1540
      printf OUTFILE "  signal tgc : std_logic_vector(%s downto 0);\n",$tgc_bits-1; };
1541
    if (($tga_o gt 0) && ($tga_i gt 0)) {
1542
      printf OUTFILE "  signal tga : std_logic_vector(%s downto 0);\n",$tga_bits-1; };
1543
    printf OUTFILE "begin\n";
1544
    # cyc
1545
    printf OUTFILE "cyc <= (%s_cyc_o and %s_bg)",$master[1]{"wbm"},$master[1]{"wbm"};
1546
    if ($masters gt 1) {
1547
      for ($i=2; $i le $masters; $i++) {
1548
        printf OUTFILE " or (%s_cyc_o and %s_bg)",$master[$i]{"wbm"},$master[$i]{"wbm"}; };
1549
    };
1550
    printf OUTFILE ";\n";
1551
    for ($i=1; $i le $slaves; $i++) {
1552
      printf OUTFILE "%s_cyc_i <= %s_ss and cyc;\n",$slave[$i]{"wbs"},$slave[$i]{"wbs"}; };
1553
    # stb
1554
    printf OUTFILE "stb <= (%s_stb_o and %s_bg)",$master[1]{"wbm"},$master[1]{"wbm"};
1555
    if ($masters gt 1) {
1556
      for ($i=2; $i le $masters; $i++) {
1557
        printf OUTFILE " or (%s_stb_o and %s_bg)",$master[$i]{"wbm"},$master[$i]{"wbm"}; };
1558
    };
1559
    printf OUTFILE ";\n";
1560
    for ($i=1; $i le $slaves; $i++) {
1561
      printf OUTFILE "%s_stb_i <= stb;\n",$slave[$i]{"wbs"}; };
1562
    # we
1563
    $i=1; until ($master[$i]{"type"} ne "ro") {$i++};
1564
    printf OUTFILE "we <= (%s_we_o and %s_bg)",$master[$i]{"wbm"},$master[$i]{"wbm"};
1565
    if ($i lt $masters) {
1566
      for ($j=$i+1; $j le $masters; $j++) {
1567
        if ($master[$j]{"type"} ne "ro") {
1568
          printf OUTFILE " or (%s_we_o and %s_bg)",$master[$j]{"wbm"},$master[$j]{"wbm"};
1569
        };
1570
      };
1571
    };
1572
    printf OUTFILE ";\n";
1573
    for ($i=1; $i le $slaves; $i++) {
1574
      if ($slave[$i]{"type"} ne "ro") {
1575
        printf OUTFILE "%s_we_i <= we;\n",$slave[$i]{"wbs"};
1576
      };
1577
    };
1578
    # ack
1579
    printf OUTFILE "ack <= %s_ack_o",$slave[1]{"wbs"};
1580
    for ($i=2; $i le $slaves; $i++) {
1581
      printf OUTFILE " or %s_ack_o",$slave[$i]{"wbs"}; };
1582
    printf OUTFILE ";\n";
1583
    for ($i=1; $i le $masters; $i++) {
1584
      printf OUTFILE "%s_ack_i <= ack and %s_bg;\n",$master[$i]{"wbm"},$master[$i]{"wbm"}; };
1585
    # rty
1586
    if (($rty_o eq 0) && ($rty_i gt 0)) {
1587
      for ($i=1; $i le $masters; $i++) {
1588
        if ($master[$i]{"rty_i"} eq 1) {
1589
          printf OUTFILE "%s_rty_i <= '0';\n",$master[$i]{"wbm"};
1590
        };
1591
      };
1592
    } elsif (($rty_o eq 1) && ($rty_i gt 0)) {
1593
      $i=1; until ($slave[$i]{"rty_o"} eq 1) {$i++};
1594
      for ($j=1; $j le $masters; $j++) {
1595
        if ($master[$j]{"rty_i"} eq 1) {
1596
          printf OUTFILE "%s_rty_i <= %s_rty_o;\n",$master[$j]{"wbm"},$slave[$i]{"wbs"};
1597
        };
1598
      };
1599
    } elsif (($rty_o gt 1) && ($rty_i gt 0)) {
1600
      $i=1; until ($slave[$i]{"rty_o"} eq 1) {$i++};
1601
      printf OUTFILE "rty <= %s_rty_o",$slave[$i]{"wbs"};
1602
      for ($j=$i+1; $j le $slaves; $j++) {
1603
        if ($slave[$j]{"rty_o"} eq 1) {
1604
          printf OUTFILE " or %s_rty_o",$slave[$j]{"wbs"};
1605
        };
1606
      };
1607
      printf OUTFILE ";\n";
1608
      for ($i=1; $i le $masters; $i++) {
1609
        if ($master[$i]{"rty_i"} eq 1) {
1610
          printf OUTFILE "%s_rty_i <= rty;\n",$master[$i]{"wbm"};
1611
        };
1612
      };
1613
    };
1614
    # err
1615
    if (($err_o eq 0) && ($err_i gt 0)) {
1616
      for ($i=1; $i le $masters; $i++) {
1617
        if ($master[$i]{"err_i"} eq 1) {
1618
          printf OUTFILE "%s_err_i <= '0';\n",$master[$i]{"wbm"};
1619
        };
1620
      };
1621
    } elsif (($err_o eq 1) && ($err_i gt 0)) {
1622
      $i=1; until ($slave[$i]{"err_o"} eq 1) {$i++};
1623
      for ($j=1; $j le $masters; $j++) {
1624
        if ($master[$j]{"err_i"} eq 1) {
1625
          printf OUTFILE "%s_err_i <= %s_err_o;\n",$master[$j]{"wbm"},$slave[$i]{"wbs"};
1626
        };
1627
      };
1628
    } elsif (($err_o gt 1) && ($err_i gt 0)) {
1629
      $i=1; until ($slave[$i]{"err_o"} eq 1) {$i++};
1630
      printf OUTFILE "err <= %s_err_o",$slave[$i]{"wbs"};
1631
      for ($j=$i+1; $j le $slaves; $j++) {
1632
        if ($slave[$j]{"err_o"} eq 1) {
1633
          printf OUTFILE " or %s_err_o",$slave[$j]{"wbs"};
1634
        };
1635
      };
1636
      printf OUTFILE ";\n";
1637
      for ($i=1; $i le $masters; $i++) {
1638
        if ($master[$i]{"err_i"} eq 1) {
1639
          printf OUTFILE "%s_err_i <= err;\n",$master[$i]{"wbm"};
1640
        };
1641
      };
1642
    };
1643
    # sel
1644
    printf OUTFILE "sel <= (%s_sel_o and %s_bg)",$master[1]{"wbm"},$master[1]{"wbm"};
1645
    if ($masters gt 1) {
1646
      for ($i=2; $i le $masters; $i++) {
1647
        printf OUTFILE " or (%s_sel_o and %s_bg)",$master[$i]{"wbm"},$master[$i]{"wbm"};
1648
      };
1649
    };
1650
    printf OUTFILE ";\n";
1651
    for ($i=1; $i le $slaves; $i++) {
1652
      printf OUTFILE "%s_sel_i <= sel;\n",$slave[$i]{"wbs"}; };
1653
    # data m2s
1654
    $i=1; until ($master[$i]{"type"} ne "ro") {$i++};
1655
    printf OUTFILE "dat_m2s <= (%s_dat_o and %s_bg)",$master[$i]{"wbm"},$master[$i]{"wbm"};
1656
    if ($i lt $masters) {
1657
      for ($j=$i+1; $j le $masters; $j++) {
1658
        printf OUTFILE " or (%s_dat_o and %s_bg)",$master[$j]{"wbm"},$master[$j]{"wbm"};
1659
      };
1660
    };
1661
    printf OUTFILE ";\n";
1662
    for ($i=1; $i le $slaves; $i++) {
1663
      if ($slave[$i]{"type"} ne "ro") {
1664
        printf OUTFILE "%s_dat_i <= dat_m2s;\n",$slave[$i]{"wbs"};
1665
      };
1666
    };
1667
    # data s2m
1668
    $i=1; until ($slave[$i]{"type"} ne "wo") {$i++};
1669
    printf OUTFILE "dat_s2m <= (%s_dat_o and %s_ss)",$slave[$i]{"wbs"},$slave[$i]{"wbs"};
1670
    if ($i lt $slaves) {
1671
      for ($j=$i+1; $j le $slaves; $j++) {
1672
        printf OUTFILE " or (%s_dat_o and %s_ss)",$slave[$j]{"wbs"},$slave[$j]{"wbs"};
1673
      };
1674
    };
1675
    printf OUTFILE ";\n";
1676
    for ($i=1; $i le $masters; $i++) {
1677
      if ($master[$i]{"type"} ne "wo") {
1678
        printf OUTFILE "%s_dat_i <= dat_s2m;\n",$master[$i]{"wbm"};
1679
      };
1680
    };
1681
    # tgc
1682
    if (($tgc_o eq 0) && ($tgc_i gt 0)) {
1683
      for ($i=1; $i le $slaves; $i++) {
1684
        if ($slave[$i]{"tgc_i"} eq 1) {
1685
          printf OUTFILE "%s_%s_i <= %s;\n",$slave[$i]{"wbs"},$rename_tgc,$classic;
1686
        };
1687
      };
1688
    } elsif (($tgc_o gt 0) && ($tgc_i gt 0)) {
1689
      $i=1; until ($master[$i]{"tgc_o"} eq 1) {$i++};
1690
      printf OUTFILE "tgc <= (%s_%s_o and %s_bg)",$master[$i]{"wbm"},$rename_tgc,$master[$i]{"wbm"};
1691
      for ($j=$i+1; $j le $masters; $j++) {
1692
        if ($master[$j]{"tgc_o"} eq 1) {
1693
          printf OUTFILE " or (%s_%s_o and %s_bg)",$master[$j]{"wbm"},$rename_tgc,$master[$j]{"wbm"};
1694
        };
1695
      };
1696
      printf OUTFILE ";\n";
1697
      for ($i=1; $i le $slaves; $i++) {
1698
        if ($slave[$i]{"tgc_i"} eq 1) {
1699
          printf OUTFILE "%s_%s_i <= tgc;\n",$slave[$i]{"wbs"},$rename_tgc,$slave[$i]{"wbs"};
1700
        };
1701
      };
1702
    };
1703
    # tga
1704
    if (($tga_o eq 0) && ($tga_i gt 0)) {
1705
      for ($i=1; $i le $slaves; $i++) {
1706
        if ($slave[$i]{"tga_i"} eq 1) {
1707
          printf OUTFILE "%s_%s_i <= (others=>'0');\n",$slave[$i]{"wbs"},$rename_tga;
1708
        };
1709
      };
1710
    } elsif (($tga_o gt 0) && ($tga_i gt 0)) {
1711
      $i=1; until ($master[$i]{"tga_o"} eq 1) {$i++};
1712
      printf OUTFILE "tga <= (%s_%s_o and %s_bg)",$master[$i]{"wbm"},$rename_tga,$master[$i]{"wbm"};
1713
      for ($j=$i+1; $j le $masters; $j++) {
1714
        if ($master[$j]{"tga_o"} eq 1) {
1715
          printf OUTFILE " or (%s_%s_o and %s_bg)",$master[$j]{"wbm"},$rename_tga,$master[$j]{"wbm"};
1716
        };
1717
      };
1718
      printf OUTFILE ";\n";
1719
      for ($i=1; $i le $slaves; $i++) {
1720
        if ($slave[$i]{"tga_i"} eq 1) {
1721
          printf OUTFILE "%s_%s_i <= tga;\n",$slave[$i]{"wbs"},$rename_tga,$slave[$i]{"wbs"};
1722
        };
1723
      };
1724
    };
1725
    # end block
1726
    printf OUTFILE "end block mux;\n\n";
1727
};
1728
 
1729
sub gen_muxcbs{
1730
    # cyc
1731
    printf OUTFILE "-- cyc_i(s)\n";
1732
    for ($i=1; $i le $slaves; $i++) {
1733
      $tmp=1; until ($master[$tmp]{("priority_".($slave[$i]{"wbs"}))} ne 0) {$tmp++};
1734
      printf OUTFILE "%s_cyc_i <= (%s_cyc_o and %s_%s_bg)",$slave[$i]{"wbs"},$master[$tmp]{"wbm"},$master[$tmp]{"wbm"},$slave[$i]{"wbs"};
1735
      for ($j=$tmp+1; $j le $masters; $j++) {
1736
        if ($master[$j]{("priority_".($slave[$i]{"wbs"}))} ne 0) {
1737
          printf OUTFILE " or (%s_cyc_o and %s_%s_bg)",$master[$j]{"wbm"},$master[$j]{"wbm"},$slave[$i]{"wbs"};
1738
        };
1739
      };
1740
      printf OUTFILE ";\n";
1741
    };
1742
    # stb
1743
    printf OUTFILE "-- stb_i(s)\n";
1744
    for ($i=1; $i le $slaves; $i++) {
1745
      $tmp=1; until ($master[$tmp]{("priority_".($slave[$i]{"wbs"}))} ne 0) {$tmp++};
1746
      printf OUTFILE "%s_stb_i <= (%s_stb_o and %s_%s_bg)",$slave[$i]{"wbs"},$master[$tmp]{"wbm"},$master[$tmp]{"wbm"},$slave[$i]{"wbs"};
1747
      for ($j=$tmp+1; $j le $masters; $j++) {
1748
        if ($master[$j]{("priority_".($slave[$i]{"wbs"}))} ne 0) {
1749
          printf OUTFILE " or (%s_stb_o and %s_%s_bg)",$master[$j]{"wbm"},$master[$j]{"wbm"},$slave[$i]{"wbs"};
1750
        };
1751
      };
1752
      printf OUTFILE ";\n";
1753
    };
1754
    # we
1755
    printf OUTFILE "-- we_i(s)\n";
1756
    for ($i=1; $i le $slaves; $i++) {
1757
      if ($slave[$i]{"type"} ne "ro") {
1758
        $tmp=1; until (($master[$tmp]{("priority_".($slave[$i]{"wbs"}))} ne 0) && ($master[$tmp]{"type"} ne "ro")) {$tmp++};
1759
        printf OUTFILE "%s_we_i <= (%s_we_o and %s_%s_bg)",$slave[$i]{"wbs"},$master[$tmp]{"wbm"},$master[$tmp]{"wbm"},$slave[$i]{"wbs"};
1760
        for ($j=$tmp+1; $j le $masters; $j++) {
1761
          if (($master[$j]{("priority_".($slave[$i]{"wbs"}))} ne 0) && ($master[$j]{"type"} ne "ro")) {
1762
            printf OUTFILE " or (%s_we_o and %s_%s_bg)",$master[$j]{"wbm"},$master[$j]{"wbm"},$slave[$i]{"wbs"};
1763
          };
1764
        };
1765
        printf OUTFILE ";\n";
1766
      };
1767
    };
1768
    # ack
1769
    printf OUTFILE "-- ack_i(s)\n";
1770
    for ($i=1; $i le $masters; $i++) {
1771
      $tmp=1; until ($master[$i]{("priority_".($slave[$tmp]{"wbs"}))} ne 0) {$tmp++};
1772
      printf OUTFILE "%s_ack_i <= (%s_ack_o and %s_%s_bg)",$master[$i]{"wbm"},$slave[$tmp]{"wbs"},$master[$i]{"wbm"},$slave[$tmp]{"wbs"};
1773
      for ($j=$tmp+1; $j le $slaves; $j++) {
1774
        if ($master[$i]{("priority_".($slave[$j]{"wbs"}))} ne 0) {
1775
          printf OUTFILE " or (%s_ack_o and %s_%s_bg)",$slave[$j]{"wbs"},$master[$i]{"wbm"},$slave[$j]{"wbs"};
1776
        };
1777
      };
1778
      printf OUTFILE ";\n";
1779
    };
1780
    # rty
1781
    printf OUTFILE "-- rty_i(s)\n";
1782
    for ($i=1; $i le $masters; $i++) {
1783
      if ($master[$i]{"rty_i"} eq 1) {
1784
        $rty_o=0;
1785
        for ($j=1; $j le $masters; $j++) {
1786
          if (($slave[$j]{"rty_o"} eq 1) && ($master[$i]{("priority_".($slave[$j]{"wbs"}))} ne 0)) {
1787
            $rty_o+=1;
1788
          };
1789
        };
1790
        if ($rty_o eq 0) {
1791
          printf OUTFILE "%s_rty_i <= '0';\n",$master[$i]{"wbm"};
1792
        } else {
1793 8 unneback
          $tmp=1; until ($master[$i]{("priority_".($slave[$tmp]{"wbs"}))} ne 0) {$tmp++};
1794 2 unneback
          printf OUTFILE "%s_rty_i <= (%s_rty_o and %s_%s_bg)",$master[$i]{"wbm"},$slave[$tmp]{"wbs"},$master[$i]{"wbm"},$slave[$tmp]{"wbs"};
1795
          for ($j=$tmp+1; $j le $slaves; $j++) {
1796
            if ($master[$i]{("priority_".($slave[$j]{"wbs"}))} ne 0) {
1797
              printf OUTFILE " or (%s_rty_o and %s_%s_bg)",$slave[$j]{"wbs"},$master[$i]{"wbm"},$slave[$j]{"wbs"};
1798
            };
1799
          };
1800
          printf OUTFILE ";\n";
1801
        };
1802
      };
1803
    };
1804
    # err
1805
    printf OUTFILE "-- err_i(s)\n";
1806
    for ($i=1; $i le $masters; $i++) {
1807
      if ($master[$i]{"err_i"} eq 1) {
1808 8 unneback
        $err_o=0;
1809 2 unneback
        for ($j=1; $j le $masters; $j++) {
1810
          if (($slave[$j]{"err_o"} eq 1) && ($master[$i]{("priority_".($slave[$j]{"wbs"}))} ne 0)) {
1811
            $err_o+=1;
1812
          };
1813
        };
1814
        if ($err_o eq 0) {
1815
          printf OUTFILE "%s_err_i <= '0';\n",$master[$i]{"wbm"};
1816
        } else {
1817 8 unneback
          $tmp=1; until ($master[$i]{("priority_".($slave[$tmp]{"wbs"}))} ne 0) {$tmp++};
1818 2 unneback
          printf OUTFILE "%s_err_i <= (%s_err_o and %s_%s_bg)",$master[$i]{"wbm"},$slave[$tmp]{"wbs"},$master[$i]{"wbm"},$slave[$tmp]{"wbs"};
1819
          for ($j=$tmp+1; $j le $slaves; $j++) {
1820
            if ($master[$i]{("priority_".($slave[$j]{"wbs"}))} ne 0) {
1821
              printf OUTFILE " or (%s_err_o and %s_%s_bg)",$slave[$j]{"wbs"},$master[$i]{"wbm"},$slave[$j]{"wbs"};
1822
            };
1823
          };
1824
          printf OUTFILE ";\n";
1825
        };
1826
      };
1827
    };
1828
    # sel
1829
    printf OUTFILE "-- sel_i(s)\n";
1830
    for ($i=1; $i le $slaves; $i++) {
1831
      if ($dat_size >= 16) {
1832
        $tmp=1; until ($master[$tmp]{("priority_".($slave[$i]{"wbs"}))} ne 0) {$tmp++};
1833
        printf OUTFILE "%s_sel_i <= (%s_sel_o and %s_%s_bg)",$slave[$i]{"wbs"},$master[$tmp]{"wbm"},$master[$tmp]{"wbm"},$slave[$i]{"wbs"};
1834
        for ($j=$tmp+1; $j le $masters; $j++) {
1835
          if ($master[$j]{("priority_".($slave[$i]{"wbs"}))} ne 0) {
1836
            printf OUTFILE " or (%s_sel_o and %s_%s_bg)",$master[$j]{"wbm"},$master[$j]{"wbm"},$slave[$i]{"wbs"};
1837
          };
1838
        };
1839
        printf OUTFILE ";\n";
1840
      };
1841
    };
1842
    # dat
1843
    printf OUTFILE "-- slave dat_i(s)\n";
1844
    for ($i=1; $i le $slaves; $i++) {
1845
      if ($slave[$i]{"type"} ne "ro") {
1846
        $tmp=0;
1847
        for ($j=1; $j le $masters; $j++) {
1848
          if (($master[$j]{("priority_".($slave[$i]{"wbs"}))} ne 0) && ($master[$j]{"type"} ne "ro")) {
1849
            $tmp+=1;
1850
          };
1851
        };
1852
        if ($tmp eq 1) {
1853
          $j=1; until (($master[$j]{("priority_".($slave[$i]{"wbs"}))} ne 0) && ($master[$j]{"type"} ne "ro")) {$j++};
1854
          printf OUTFILE "%s_dat_i <= %s_dat_o;\n",$slave[$i]{"wbs"},$master[$j]{"wbm"};
1855
        } elsif ($tmp >= 1) {
1856
          $tmp=1; until (($master[$tmp]{("priority_".($slave[$i]{"wbs"}))} ne 0) && ($master[$tmp]{"type"} ne "ro")) {$tmp++};
1857
          printf OUTFILE "%s_dat_i <= (%s_dat_o and %s_%s_bg)",$slave[$i]{"wbs"},$master[$tmp]{"wbm"},$master[$tmp]{"wbm"},$slave[$i]{"wbs"};
1858
          for ($j=$tmp+1; $j le $masters; $j++) {
1859
            if (($master[$j]{("priority_".($slave[$i]{"wbs"}))} ne 0) && ($master[$j]{"type"} ne "ro")) {
1860
              printf OUTFILE " or (%s_dat_o and %s_%s_bg)",$master[$j]{"wbm"},$master[$j]{"wbm"},$slave[$i]{"wbs"};
1861
            };
1862
          };
1863
          printf OUTFILE ";\n";
1864
        };
1865
      };
1866
    };
1867
    printf OUTFILE "-- master dat_i(s)\n";
1868
    for ($i=1; $i le $masters; $i++) {
1869
      if ($master[$i]{"type"} ne "wo") {
1870
        $tmp=0;
1871
        for ($j=1; $j le $slaves; $j++) {
1872
          if ($master[$i]{("priority_".($slave[$j]{"wbs"}))} ne 0) {
1873
            $tmp+=1;
1874
          };
1875
        };
1876
        if ($tmp eq 1) {
1877
          $tmp=1; until ($master[$i]{("priority_".($slave[$tmp]{"wbs"}))} ne 0) {$tmp++};
1878
          printf OUTFILE "%s_dat_i <= %s_dat_o",$master[$i]{"wbm"},$slave[$tmp]{"wbs"};
1879
        } else {
1880
          $tmp=1; until ($master[$i]{("priority_".($slave[$tmp]{"wbs"}))} ne 0) {$tmp++};
1881
          printf OUTFILE "%s_dat_i <= (%s_dat_o and %s_%s_bg)",$master[$i]{"wbm"},$slave[$tmp]{"wbs"},$master[$i]{"wbm"},$slave[$tmp]{"wbs"};
1882
          for ($j=$tmp+1; $j le $slaves; $j++) {
1883 4 unneback
            if (($master[$i]{("priority_".($slave[$j]{"wbs"}))} ne 0) && ($master[$i]{"type"} ne "wo")) {
1884 2 unneback
              printf OUTFILE " or (%s_dat_o and %s_%s_bg)",$slave[$j]{"wbs"},$master[$i]{"wbm"},$slave[$j]{"wbs"};
1885
            };
1886
          };
1887
        };
1888
        printf OUTFILE ";\n";
1889
      };
1890
    };
1891
    # tgc
1892
    printf OUTFILE "-- tgc_i\n";
1893
    for ($i=1; $i le $slaves; $i++) {
1894
      if ($slave[$i]{"tgc_i"} eq 1) {
1895
        $tmp=0;
1896
        for ($j=1; $j le $masters; $j++) {
1897
          if ($master[$j]{("priority_".($slave[$i]{"wbs"}))} ne 0) {
1898
            $tmp+=1;
1899
          };
1900
        };
1901
        if ($tmp eq 1) {
1902
          $tmp=1; until ($master[$tmp]{("priority_".($slave[$i]{"wbs"}))} ne 0) {$tmp++;};
1903
          printf OUTFILE "%s_%s_i <= %s_%s_o",$slave[$i]{"wbs"},$rename_tgc,$master[$tmp]{"wbm"},$rename_tgc;
1904
        } else {
1905
          $tmp=1; until ($master[$tmp]{("priority_".($slave[$i]{"wbs"}))} ne 0) {$tmp++;};
1906 4 unneback
          printf OUTFILE "%s_%s_i <= (%s_%s_o and %s_%s_bg)",$slave[$i]{"wbs"},$rename_tgc,$master[$tmp]{"wbm"},$rename_tgc,$master[$tmp]{"wbm"},$slave[$i]{"wbs"};
1907 2 unneback
          for ($j=$tmp+1; $j le $masters; $j++) {
1908
            if ($master[$j]{("priority_".($slave[$i]{"wbs"}))} ne 0) {
1909 5 unneback
              if ($master[$j]{"tga_o"} eq 1) {
1910 6 unneback
                printf OUTFILE " or (%s_%s_o and %s_%s_bg)",$master[$j]{"wbm"},$rename_tgc,$master[$j]{"wbm"},$slave[$i]{"wbs"};
1911 5 unneback
              } else {
1912 6 unneback
                if ($classic ne "000") {
1913
                  printf OUTFILE " or \"%s\"",$classic;
1914
                };
1915 5 unneback
              };
1916
 
1917 2 unneback
            };
1918
          };
1919
        };
1920
        printf OUTFILE ";\n";
1921
      };
1922
    };
1923
    # tga
1924
    printf OUTFILE "-- tga_i\n";
1925
    for ($i=1; $i le $slaves; $i++) {
1926
      if ($slave[$i]{"tga_i"} eq 1) {
1927
        $tmp=0;
1928
        for ($j=1; $j le $masters; $j++) {
1929
          if ($master[$j]{("priority_".($slave[$i]{"wbs"}))} ne 0) {
1930
            $tmp+=1;
1931
          };
1932
        };
1933
        if ($tmp eq 1) {
1934
          $tmp=1; until ($master[$tmp]{("priority_".($slave[$i]{"wbs"}))} ne 0) {$tmp++;};
1935
          printf OUTFILE "%s_%s_i <= %s_%s_o",$slave[$i]{"wbs"},$rename_tga,$master[$tmp]{"wbm"},$rename_tga;
1936
        } else {
1937
          $tmp=1; until ($master[$tmp]{("priority_".($slave[$i]{"wbs"}))} ne 0) {$tmp++;};
1938 9 unneback
          printf OUTFILE "%s_%s_i <= (%s_%s_o and %s_%s_bg)",$slave[$i]{"wbs"},$rename_tga,$master[$tmp]{"wbm"},$rename_tga,$master[$tmp]{"wbm"},$slave[$i]{"wbs"};
1939 2 unneback
          for ($j=$tmp+1; $j le $masters; $j++) {
1940
            if ($master[$j]{("priority_".($slave[$i]{"wbs"}))} ne 0) {
1941 5 unneback
              if ($master[$j]{"tga_o"} eq 1) {
1942
                printf OUTFILE " or (%s_%s_o and %s_%s_bg)",$master[$j]{"wbm"},$rename_tga,$master[$j]{"wbm"},$slave[$i]{"wbs"};
1943
              };
1944 2 unneback
            };
1945
          };
1946
        };
1947
        printf OUTFILE ";\n";
1948
      };
1949
    };
1950
};
1951
 
1952
sub gen_remap{
1953
    for ($i=1; $i le $masters; $i++) {
1954
      if ($master[$i]{"type"} ne "wo") {
1955
        printf OUTFILE "%s_wbm_i.dat_i <= %s_dat_i;\n",$master[$i]{"wbm"},$master[$i]{"wbm"}; };
1956
      printf OUTFILE "%s_wbm_i.ack_i <= %s_ack_i ;\n",$master[$i]{"wbm"},$master[$i]{"wbm"};
1957
      if ($master[$i]{"err_i"} eq 1) {
1958
        printf OUTFILE "%s_wbm_i.err_i <= %s_err_i;\n",$master[$i]{"wbm"},$master[$i]{"wbm"}; };
1959
      if ($master[$i]{"rty_i"} eq 1) {
1960
        printf OUTFILE "%s_wbm_i.rty_i <= %s_rty_i;\n",$master[$i]{"wbm"},$master[$i]{"wbm"}; };
1961
      if ($master[$i]{"type"} ne "ro") {
1962
        printf OUTFILE "%s_dat_o <= %s_wbm_o.dat_o;\n",$master[$i]{"wbm"},$master[$i]{"wbm"};
1963
        printf OUTFILE "%s_we_o  <= %s_wbm_o.we_o;\n",$master[$i]{"wbm"},$master[$i]{"wbm"};
1964
      };
1965
      printf OUTFILE "%s_sel_o <= %s_wbm_o.sel_o;\n",$master[$i]{"wbm"},$master[$i]{"wbm"};
1966
      printf OUTFILE "%s_adr_o <= %s_wbm_o.adr_o;\n",$master[$i]{"wbm"},$master[$i]{"wbm"};
1967
      if ($master[$i]{"tgc_o"} eq 1) {
1968
        printf OUTFILE "%s_%s_o <= %s_wbm_o.%s_o;\n",$master[$i]{"wbm"},$rename_tgc,$master[$i]{"wbm"},$rename_tgc; };
1969
      if ($master[$i]{"tga_o"} eq 1) {
1970
        printf OUTFILE "%s_%s_o <= %s_wbm_o.%s_o;\n",$master[$i]{"wbm"},$rename_tga,$master[$i]{"wbm"},$rename_tga; };
1971
      printf OUTFILE "%s_cyc_o <= %s_wbm_o.cyc_o;\n",$master[$i]{"wbm"},$master[$i]{"wbm"};
1972
      printf OUTFILE "%s_stb_o <= %s_wbm_o.stb_o;\n",$master[$i]{"wbm"},$master[$i]{"wbm"};
1973
    };
1974
    for ($i=1; $i le $slaves; $i++) {
1975
      if ($slave[$i]{"type"} ne "wo") {
1976
        printf OUTFILE "%s_dat_o <= %s_wbs_o.dat_o;\n",$slave[$i]{"wbs"},$slave[$i]{"wbs"}; };
1977
      printf OUTFILE "%s_ack_o <= %s_wbs_o.ack_o;\n",$slave[$i]{"wbs"},$slave[$i]{"wbs"};
1978
      if ($slave[$i]{"err_o"} eq 1) {
1979
        printf OUTFILE "%s_err_o <= %s_wbs_o.err_o;\n",$slave[$i]{"wbs"},$slave[$i]{"wbs"}; };
1980
      if ($slave[$i]{"rty_o"} eq 1) {
1981
        printf OUTFILE "%s_rty_o <= %s_wbs_o.rty_o;\n",$slave[$i]{"wbs"},$slave[$i]{"wbs"}; };
1982
      if ($slave[$i]{"type"} ne "ro") {
1983
        printf OUTFILE "%s_wbs_i.dat_i <= %s_dat_i;\n",$slave[$i]{"wbs"},$slave[$i]{"wbs"};
1984
        printf OUTFILE "%s_wbs_i.we_i  <= %s_we_i;\n",$slave[$i]{"wbs"},$slave[$i]{"wbs"};
1985
      };
1986
      printf OUTFILE "%s_wbs_i.sel_i <= %s_sel_i;\n",$slave[$i]{"wbs"},$slave[$i]{"wbs"};
1987
      printf OUTFILE "%s_wbs_i.adr_i <= %s_adr_i;\n",$slave[$i]{"wbs"},$slave[$i]{"wbs"};
1988
      if ($slave[$i]{"tgc_i"} eq 1) {
1989
        printf OUTFILE "%s_wbs_i.%s_i <= %s_%s_i;\n",$slave[$i]{"wbs"},$rename_tgc,$slave[$i]{"wbs"},$rename_tgc; };
1990
      if ($slave[$i]{"tga_i"} eq 1) {
1991
        printf OUTFILE "%s_wbs_i.%s_i <= %s_%s_i;\n",$slave[$i]{"wbs"},$rename_tga,$slave[$i]{"wbs"},$rename_tga; };
1992
      printf OUTFILE "%s_wbs_i.cyc_i <= %s_cyc_i;\n",$slave[$i]{"wbs"},$slave[$i]{"wbs"};
1993
      printf OUTFILE "%s_wbs_i.stb_i <= %s_stb_i;\n",$slave[$i]{"wbs"},$slave[$i]{"wbs"};
1994
    };
1995
};
1996
 
1997
# GUI
1998
$tmp=shift;
1999
if ($tmp eq "-nogui") {
2000
  $infile = shift;
2001
  read_defines($infile);
2002
} else {
2003
  if ($tmp ne <undef>) {
2004
    $infile=$tmp;
2005
    read_defines($infile);
2006
  };
2007
  gui_fsm;
2008
  generate_defines($infile);
2009 14 unneback
  read_defines($infile);
2010 2 unneback
};
2011
 
2012
# main
2013
open(OUTFILE,">$outfile$ext") or die "could not write to $outfile$ext";
2014
gen_header;
2015
if ($hdl eq 'vhdl') {
2016
  gen_vhdl_package;
2017
  gen_trafic_ctrl;
2018
  gen_entity;
2019
  printf OUTFILE "architecture rtl of %s is\n",$intercon;
2020
  if ($signal_groups == 1) { gen_sig_remap; };
2021
  gen_global_signals;
2022
  printf OUTFILE "begin  -- rtl\n";
2023
  gen_arbiter;
2024
  gen_adr_decoder;
2025
  if ($interconnect eq 'sharedbus') {
2026
    gen_muxshb;
2027
  } else {
2028
    gen_muxcbs;
2029
  };
2030
  if ($signal_groups == 1) { gen_remap; };
2031
  printf OUTFILE "end rtl;";
2032
} else {
2033
 
2034
};
2035
close(OUTFILE);

powered by: WebSVN 2.1.0

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