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 17

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

powered by: WebSVN 2.1.0

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