21 #include <QTextStream>
36 QObject::tr(
"Name of VHDL file")));
49 p->
Props.getFirst()->Value =
Props.getFirst()->Value;
57 Name = QObject::tr(
"VHDL file");
58 BitmapFile = (
char *)
"vhdlfile";
79 s +=
" generic map (";
81 for(pr =
Props.next(); pr != 0; pr =
Props.next())
82 s +=
", " + pr->
Value;
89 for(pp =
Ports.next(); pp != 0; pp =
Ports.next())
101 QString File(
Props.getFirst()->Value);
102 QFileInfo Info(File);
103 if(Info.isRelative())
107 if(!f.open(QIODevice::ReadOnly))
110 QTextStream stream(&f);
111 File = stream.read();
128 int fHeight = metrics.lineSpacing();
132 QString tmp, PortNames =
loadFile();
133 if(!PortNames.isEmpty())
134 No = PortNames.count(
',') + 1;
137 int h = 30*((No-1)/2) + 15;
143 tmp = QObject::tr(
"vhdl");
144 int w = metrics.width(tmp);
145 Texts.append(
new Text(w/-2, fHeight/-2, tmp));
151 pp =
new Port(-30, y);
154 tmp = PortNames.section(
',', i, i);
155 w = metrics.width(tmp);
156 Texts.append(
new Text(-19-w, y-fHeight-2, tmp));
161 pp =
new Port( 30, y);
164 tmp = PortNames.section(
',', i, i);
165 Texts.append(
new Text( 20, y-fHeight-2, tmp));
180 for(i=0; i<No; i++) {
183 GenDefs.section(
',', i, i),
true,
184 QObject::tr(
"generic variable")+
185 " "+QString::number(i+1));
191 QObject::tr(
"generic variable")+
" "+QString::number(i+1);
198 for(i=No; i<y; i++) {
207 QString FileName =
Props.getFirst()->Value;
217 QString FileName =
Props.getFirst()->Value;
218 if(FileName.isEmpty()) {
219 ErrText += QObject::tr(
"ERROR: No file name in %1 component \"%2\".").
229 if(!f.open(QIODevice::ReadOnly)) {
230 ErrText += QObject::tr(
"ERROR: Cannot open %1 file \"%2\".").
231 arg(
Model).arg(FileName);
236 QByteArray FileContent = f.readAll();
240 (*stream) << FileContent.data();
261 if(!f.open(QIODevice::ReadOnly))
264 QByteArray FileContent = f.readAll();
265 File = QString(FileContent);
273 while((i=File.find(
"--", i)) >= 0) {
274 j = File.find(
'\n', i+2);
282 Expr.setCaseSensitive(
false);
285 Expr.setPattern(
"\\bentity\\b");
286 k = File.findRev(Expr, k);
290 Expr.setPattern(
"\\bend\\b");
291 i = File.find(Expr, k+7);
294 s = File.mid(k+7, i-k-7);
296 Expr.setPattern(
"\\b");
300 j = s.find(Expr, i+1);
305 i = s.find(Expr, j+1);
308 j = s.find(Expr, i+1);
311 if(s.mid(i, j-i).lower() ==
"is")
327 Expr.setCaseSensitive(
false);
330 Expr.setPattern(
"\\bport\\b");
331 i = s.find(Expr, j+1);
335 i = s.find(
'(', i+4) + 1;
343 j = s.find(
')', j+1);
346 p = s.find(
'(', p+1);
347 if(p >= 0 && p > j) p = -1;
356 QString types =
"", t;
357 while((i=s.find(
':', i)) >= 0) {
358 j = s.find(
';', i+2);
362 t = t.simplifyWhiteSpace();
367 t = t.simplifyWhiteSpace();
370 if ((k = t.find(
' ')) >= 0)
372 t = t.simplifyWhiteSpace();
374 k = (s.mid(l,k-l).count(
',')) + 1;
375 while (k-->0) types = types + t +
",";
382 TypeNames=types=types.left(types.length()-1);
390 Expr.setCaseSensitive(
false);
393 Expr.setPattern(
"\\bgeneric\\b");
394 i = s.find(Expr, j+1);
398 i = s.find(
'(', i+4) + 1;
406 j = s.find(
')', j+1);
409 p = s.find(
'(', p+1);
410 if(p >= 0 && p > j) p = -1;
419 QString types =
"", t, defs =
"", d;
420 while((i=s.find(
':', i)) >= 0) {
421 j = s.find(
';', i+2);
422 n = s.find(
":=", i+2);
424 if(n >= 0 && (n < j || j < 0) ) {
425 j = s.find(
';', n+2);
428 d = d.simplifyWhiteSpace();
431 d = s.mid(n+2, j-n-1);
433 d = d.simplifyWhiteSpace();
441 t = t.simplifyWhiteSpace();
446 t = t.simplifyWhiteSpace();
449 if ((k = t.find(
' ')) >= 0)
451 t = t.simplifyWhiteSpace();
453 k = (s.mid(l,k-l).count(
',')) + 1;
455 types = types + t +
",";
456 defs = defs + d +
",";
464 GenTypes=types=types.left(types.length()-1);
465 GenDefs=defs=defs.left(defs.length()-1);
tQucsSettings QucsSettings
#define isDigitalComponent
Definitions and declarations for the main application.
QString properAbsFileName(const QString &Name)
Q3PtrList< Property > Props
bool createSubNetlist(QTextStream *)
static Element * info(QString &, char *&, bool getNewOne=false)
QString parsePorts(QString, int)
Superclass of all schematic drawing elements.
void recreate(Schematic *)
QString getSubcircuitFile()
QString parseGenerics(QString, int)