25 #include <qfileinfo.h>
34 QObject::tr(
"Name of VHDL file")));
47 p->
Props.getFirst()->Value =
Props.getFirst()->Value;
55 Name = QObject::tr(
"VHDL file");
56 BitmapFile = (
char *)
"vhdlfile";
77 s +=
" generic map (";
79 for(pr =
Props.next(); pr != 0; pr =
Props.next())
80 s +=
", " + pr->
Value;
87 for(pp =
Ports.next(); pp != 0; pp =
Ports.next())
100 QFileInfo Info(
File);
101 if(Info.isRelative())
105 if(!f.open(IO_ReadOnly))
108 QTextStream stream(&f);
109 File = stream.read();
126 int fHeight = metrics.lineSpacing();
130 QString tmp, PortNames =
loadFile();
131 if(!PortNames.isEmpty())
132 No = PortNames.contains(
',') + 1;
135 int h = 30*((No-1)/2) + 15;
141 tmp = QObject::tr(
"vhdl");
142 int w = metrics.width(tmp);
143 Texts.append(
new Text(w/-2, fHeight/-2, tmp));
149 pp =
new Port(-30, y);
152 tmp = PortNames.section(
',', i, i);
153 w = metrics.width(tmp);
154 Texts.append(
new Text(-19-w, y-fHeight-2, tmp));
159 pp =
new Port( 30, y);
162 tmp = PortNames.section(
',', i, i);
163 Texts.append(
new Text( 20, y-fHeight-2, tmp));
178 for(i=0; i<No; i++) {
181 GenDefs.section(
',', i, i),
true,
182 QObject::tr(
"generic variable")+
183 " "+QString::number(i+1));
189 QObject::tr(
"generic variable")+
" "+QString::number(i+1);
196 for(i=No; i<y; i++) {
205 QString FileName =
Props.getFirst()->Value;
215 QString FileName =
Props.getFirst()->Value;
216 if(FileName.isEmpty()) {
217 ErrText += QObject::tr(
"ERROR: No file name in %1 component \"%2\".").
227 if(!f.open(IO_ReadOnly)) {
228 ErrText += QObject::tr(
"ERROR: Cannot open %1 file \"%2\".").
234 QByteArray FileContent = f.readAll();
237 stream->writeRawBytes(FileContent.data(), FileContent.size());
258 if(!f.open(IO_ReadOnly))
261 QByteArray FileContent = f.readAll();
262 File = QString(FileContent);
270 while((i=File.find(
"--", i)) >= 0) {
271 j = File.find(
'\n', i+2);
279 Expr.setCaseSensitive(
false);
282 Expr.setPattern(
"\\bentity\\b");
283 k = File.findRev(Expr, k);
287 Expr.setPattern(
"\\bend\\b");
288 i = File.find(Expr, k+7);
291 s = File.mid(k+7, i-k-7);
293 Expr.setPattern(
"\\b");
297 j = s.find(Expr, i+1);
302 i = s.find(Expr, j+1);
305 j = s.find(Expr, i+1);
308 if(s.mid(i, j-i).lower() ==
"is")
324 Expr.setCaseSensitive(
false);
327 Expr.setPattern(
"\\bport\\b");
328 i = s.find(Expr, j+1);
332 i = s.find(
'(', i+4) + 1;
340 j = s.find(
')', j+1);
343 p = s.find(
'(', p+1);
344 if(p >= 0 && p > j) p = -1;
353 QString types =
"",
t;
354 while((i=s.find(
':', i)) >= 0) {
355 j = s.find(
';', i+2);
359 t =
t.simplifyWhiteSpace();
364 t =
t.simplifyWhiteSpace();
367 if ((k =
t.find(
' ')) >= 0)
369 t =
t.simplifyWhiteSpace();
371 k = s.mid(l,k-l).contains(
',') + 1;
372 while (k-->0) types = types +
t +
",";
379 TypeNames=types=types.left(types.length()-1);
387 Expr.setCaseSensitive(
false);
390 Expr.setPattern(
"\\bgeneric\\b");
391 i = s.find(Expr, j+1);
395 i = s.find(
'(', i+4) + 1;
403 j = s.find(
')', j+1);
406 p = s.find(
'(', p+1);
407 if(p >= 0 && p > j) p = -1;
416 QString types =
"",
t, defs =
"", d;
417 while((i=s.find(
':', i)) >= 0) {
418 j = s.find(
';', i+2);
419 n = s.find(
":=", i+2);
421 if(n >= 0 && (n < j || j < 0) ) {
422 j = s.find(
';', n+2);
425 d = d.simplifyWhiteSpace();
428 d = s.mid(n+2, j-n-1);
430 d = d.simplifyWhiteSpace();
438 t =
t.simplifyWhiteSpace();
443 t =
t.simplifyWhiteSpace();
446 if ((k =
t.find(
' ')) >= 0)
448 t =
t.simplifyWhiteSpace();
450 k = s.mid(l,k-l).contains(
',') + 1;
452 types = types +
t +
",";
453 defs = defs + d +
",";
461 GenTypes=types=types.left(types.length()-1);
462 GenDefs=defs=defs.left(defs.length()-1);