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

Subversion Repositories cpu8080

[/] [cpu8080/] [trunk/] [project/] [cpu8080_html/] [fit/] [eqns.js] - Blame information for rev 2

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

Line No. Rev Author Line
1 2 samiam9512
var eqnType = 0;
2
var spcStr = " ";
3
var nlStr = "<br>";
4
var tabStr = spcStr + spcStr + spcStr + spcStr + spcStr;
5
var nlTabStr = nlStr + tabStr;
6
var rClrS = "<font color='blue'>";
7
var rClrE = "</font>";
8
var cClrS = "<font color='green'>";
9
var cClrE = "</font>";
10
 
11
var abelOper = new Array();
12
abelOper["GND"] = new Array("Gnd");
13
abelOper["VCC"] = new Array("Vcc");
14
abelOper["NOT"] = new Array(rClrS + "!" + rClrE);
15
abelOper["AND"] = new Array(rClrS + "&" + rClrE);
16
abelOper["OR"]  = new Array(rClrS + "#" + rClrE);
17
abelOper["XOR"] = new Array(rClrS + "$" + rClrE);
18
abelOper["EQUAL_COLON"] = new Array(":= ");
19
abelOper["EQUAL"] = new Array("= ");
20
abelOper["ASSIGN"] = new Array("");
21
abelOper["OPEN_NEGATE"] = new Array("(");
22
abelOper["CLOSE_NEGATE"] = new Array(")");
23
abelOper["OPEN_PTERM"] = new Array("");
24
abelOper["CLOSE_PTERM"] = new Array("");
25
abelOper["OPEN_BRACE"] = new Array("<");
26
abelOper["CLOSE_BRACE"] = new Array(">");
27
abelOper["INVALID_OPEN_BRACE"] = new Array("<");
28
abelOper["INVALID_CLOSE_BRACE"] = new Array(">");
29
 
30
abelOper["ENDLN"] = new Array(";");
31
abelOper["COMMENT"] = new Array("//");
32
abelOper["IMPORT"] = new Array(";Imported pterms ");
33
abelOper["GCK_COM"] = new Array("GCK");
34
abelOper["GTS_COM"] = new Array("GTS");
35
abelOper["GSR_COM"] = new Array("GSR");
36
abelOper["START_EQN"] = new Array("");
37
abelOper["END_EQN"] = new Array("");
38
 
39
abelOper["_I"] = new Array(".I");
40
abelOper["_T"] = new Array(".T");
41
abelOper["_D"] = new Array(".D");
42
abelOper["_C"] = new Array(".CLK");
43
abelOper["_DEC"] = new Array(".DEC");
44
abelOper["_LH"] = new Array(".LH");
45
abelOper["_CLR"] = new Array(".AR");
46
abelOper["_PRE"] = new Array(".AP");
47
abelOper["_CE"] = new Array(".CE");
48
abelOper["_OE"] = new Array(".OE");
49
 
50
abelOper["OE_START"] = new Array(" <= ");
51
abelOper["OE_WHEN"] = new Array(" when ");
52
abelOper["OE_EQUAL"] = new Array(" = ");
53
abelOper["OE_ELSE"] = new Array(" else ");
54
abelOper["B0"] = new Array("'0'");
55
abelOper["B1"] = new Array("'1'");
56
abelOper["BZ"] = new Array("'Z'");
57
 
58
abelOper["FD"] = new Array(".D");
59
abelOper["FT"] = new Array(".T");
60
abelOper["FDD"] = new Array(".DEC");
61
abelOper["FTD"] = new Array(".T");
62
abelOper["LD"] = new Array(".LH");
63
abelOper["Q"] = new Array(".Q");
64
 
65
var vhdlOper = new Array();
66
vhdlOper["GND"] = new Array("'0'");
67
vhdlOper["VCC"] = new Array("'1'");
68
vhdlOper["NOT"] = new Array(rClrS + "NOT " + rClrE);
69
vhdlOper["AND"] = new Array(rClrS + "AND" + rClrE);
70
vhdlOper["OR"]  = new Array(rClrS + "OR" + rClrE);
71
vhdlOper["XOR"] = new Array(rClrS + "XOR" + rClrE);
72
vhdlOper["EQUAL_COLON"] = new Array("<= ");
73
vhdlOper["EQUAL"] = new Array("<= ");
74
vhdlOper["ASSIGN"] = new Array("");
75
vhdlOper["OPEN_NEGATE"] = new Array("(");
76
vhdlOper["CLOSE_NEGATE"] = new Array(")");
77
vhdlOper["OPEN_PTERM"] = new Array("(");
78
vhdlOper["CLOSE_PTERM"] = new Array(")");
79
vhdlOper["OPEN_BRACE"] = new Array("(");
80
vhdlOper["CLOSE_BRACE"] = new Array(")");
81
vhdlOper["INVALID_OPEN_BRACE"] = new Array("<");
82
vhdlOper["INVALID_CLOSE_BRACE"] = new Array(">");
83
 
84
vhdlOper["ENDLN"] = new Array(";");
85
vhdlOper["COMMENT"] = new Array("--");
86
vhdlOper["IMPORT"] = new Array("");
87
vhdlOper["GCK_COM"] = new Array("GCK");
88
vhdlOper["GTS_COM"] = new Array("GTS");
89
vhdlOper["GSR_COM"] = new Array("GSR");
90
vhdlOper["START_EQN"] = new Array(rClrS + "port map" + rClrE + " (");
91
vhdlOper["END_EQN"] = new Array(")");
92
 
93
vhdlOper["_I"] = new Array("_I");
94
vhdlOper["_T"] = new Array("_T");
95
vhdlOper["_D"] = new Array("_D");
96
vhdlOper["_C"] = new Array("_C");
97
vhdlOper["_DEC"] = new Array("_C");
98
vhdlOper["_LH"] = new Array("_C");
99
vhdlOper["_CLR"] = new Array("_CLR");
100
vhdlOper["_PRE"] = new Array("_PRE");
101
vhdlOper["_CE"] = new Array("_CE");
102
vhdlOper["_OE"] = new Array("_OE");
103
 
104
vhdlOper["OE_START"] = new Array(" <= ");
105
vhdlOper["OE_WHEN"] = new Array(" when ");
106
vhdlOper["OE_EQUAL"] = new Array(" = ");
107
vhdlOper["OE_ELSE"] = new Array(" else ");
108
vhdlOper["B0"] = new Array("'0'");
109
vhdlOper["B1"] = new Array("'1'");
110
vhdlOper["BZ"] = new Array("'Z'");
111
 
112
vhdlOper["FD"] = new Array("FDCPE");
113
vhdlOper["FT"] = new Array("FTCPE");
114
vhdlOper["FDD"] = new Array("FDDCPE");
115
vhdlOper["FTD"] = new Array("FTDCPE");
116
vhdlOper["LD"] = new Array("LDCP");
117
vhdlOper["Q"] = new Array("");
118
 
119
var verOper = new Array();
120
verOper["GND"] = new Array("1'b0");
121
verOper["VCC"] = new Array("1'b1");
122
verOper["NOT"] = new Array(rClrS + "!" + rClrE);
123
verOper["AND"] = new Array(rClrS + "&&" + rClrE);
124
verOper["OR"]  = new Array(rClrS + "||" + rClrE);
125
verOper["XOR"] = new Array(rClrS + "XOR" + rClrE);
126
verOper["EQUAL_COLON"] = new Array("= ");
127
verOper["EQUAL"] = new Array("= ");
128
verOper["ASSIGN"] = new Array("assign ");
129
verOper["OPEN_NEGATE"] = new Array("(");
130
verOper["CLOSE_NEGATE"] = new Array(")");
131
verOper["OPEN_PTERM"] = new Array("(");
132
verOper["CLOSE_PTERM"] = new Array(")");
133
verOper["OPEN_BRACE"] = new Array("[");
134
verOper["CLOSE_BRACE"] = new Array("]");
135
verOper["INVALID_OPEN_BRACE"] = new Array("<");
136
verOper["INVALID_CLOSE_BRACE"] = new Array(">");
137
 
138
verOper["ENDLN"] = new Array(";");
139
verOper["COMMENT"] = new Array("//");
140
verOper["IMPORT"] = new Array("");
141
verOper["GCK_COM"] = new Array("GCK");
142
verOper["GTS_COM"] = new Array("GTS");
143
verOper["GSR_COM"] = new Array("GSR");
144
verOper["START_EQN"] = new Array(" (");
145
verOper["END_EQN"] = new Array(")");
146
 
147
verOper["_I"] = new Array("_I");
148
verOper["_T"] = new Array("_T");
149
verOper["_D"] = new Array("_D");
150
verOper["_C"] = new Array("_C");
151
verOper["_DEC"] = new Array("_C");
152
verOper["_LH"] = new Array("_C");
153
verOper["_CLR"] = new Array("_CLR");
154
verOper["_PRE"] = new Array("_PRE");
155
verOper["_CE"] = new Array("_CE");
156
verOper["_OE"] = new Array("_OE");
157
 
158
verOper["OE_START"] = new Array(" = ");
159
verOper["OE_WHEN"] = new Array(" ? ");
160
verOper["OE_EQUAL"] = new Array("");
161
verOper["OE_ELSE"] = new Array(" : ");
162
verOper["B0"] = new Array("1'b0");
163
verOper["B1"] = new Array("1'b1");
164
verOper["BZ"] = new Array("1'bz");
165
 
166
verOper["FD"] = new Array("FDCPE");
167
verOper["FT"] = new Array("FTCPE");
168
verOper["FDD"] = new Array("FDDCPE");
169
verOper["FTD"] = new Array("FTDCPE");
170
verOper["LD"] = new Array("LDCP");
171
verOper["Q"] = new Array("");
172
 
173
var operator = abelOper;
174
 
175
var pterms = new Array();
176
var d1 = new Array();
177
var d2 = new Array();
178
var clk = new Array();
179
var set = new Array();
180
var rst = new Array();
181
var trst = new Array();
182
var d1imp = new Array();
183
var d2imp = new Array();
184
var clkimp = new Array();
185
var setimp = new Array();
186
var rstimp = new Array();
187
var trstimp = new Array();
188
var gblclk = new Array();
189
var gblset = new Array();
190
var gblrst = new Array();
191
var gbltrst = new Array();
192
var ce = new Array();
193
var ceimp = new Array();
194
var prld = new Array();
195
var specSig = new Array();
196
var clkNegs = new Array();
197
var setNegs = new Array();
198
var rstNegs = new Array();
199
var trstNegs = new Array();
200
var ceNegs = new Array();
201
var fbnand = new Array();
202
var inreg = new Array();
203
 
204
var dOneLit = true;
205
 
206
function setOper(type) {
207
  if      (type == "1") { operator = vhdlOper; eqnType = 1; }
208
  else if (type == "2") { operator = verOper;  eqnType = 2; }
209
  else                  { operator = abelOper; eqnType = 0; }
210
}
211
 
212
function isXC95() {
213
  if (device.indexOf("95") != -1) return true;
214
  return false;
215
}
216
 
217
function is9500() {
218
  if ((device.indexOf("95") != -1) &&
219
      (device.indexOf("XL") == -1) &&
220
      (device.indexOf("XV") == -1)) return true;
221
  return false;
222
}
223
 
224
function retSigType(s) {
225
  var sigType = sigTypes[s];
226
  var str = operator["Q"];
227
  if (sigType == "D") str = operator["FD"];
228
  else if (sigType == "T") str = operator["FT"];
229
  else if (sigType.indexOf("LATCH") != -1) str = operator["LD"];
230
  else if (sigType.indexOf("DDEFF") != -1) str = operator["FDD"];
231
  else if (sigType.indexOf("DEFF") != -1) str =  operator["FD"];
232
  else if (sigType.indexOf("DDFF") != -1) str =  operator["FDD"];
233
  else if (sigType.indexOf("TDFF") != -1) str =  operator["FTD"];
234
  else if (sigType.indexOf("DFF") != -1) str =   operator["FD"];
235
  else if (sigType.indexOf("TFF") != -1) str =   operator["FT"];
236
  return str;
237
}
238
 
239
function retSigIndex(signal) {
240
  for (s=0; s<signals.length; s++) { if (signals[s] == signal) return s; }
241
  return -1;
242
}
243
 
244
function retSigName(signal) {
245
  var str = "";
246
  if (specSig[signal]) str += specSig[signal];
247
  else str += signal;
248
 
249
  var idx1 = str.indexOf(operator["INVALID_OPEN_BRACE"]);
250
  var idx2 = str.indexOf(operator["INVALID_CLOSE_BRACE"]);
251
  if ((idx1 != -1) && (idx2 != -1))
252
    str = str.substring(0,idx1) + operator["OPEN_BRACE"] +
253
          str.substring(idx1+1,idx2) + operator["CLOSE_BRACE"] +
254
          str.substring(idx2+1,str.length);
255
  return str;
256
}
257
 
258
function removePar(signal) {
259
  var str = signal;
260
 
261
  var idx = str.indexOf(operator["OPEN_BRACE"]);
262
  if (idx != -1)
263
    str = str.substring(0,idx) +
264
          str.substring(idx+1,str.indexOf(operator["CLOSE_BRACE"]));
265
 
266
  return str;
267
}
268
 
269
 
270
function isOneLiteral(str) {
271
  if ((str.indexOf(operator["AND"]) != -1) ||
272
      (str.indexOf(operator["OR"]) != -1) ||
273
      (str.indexOf(operator["XOR"]) != -1)) return false;
274
  return true;
275
}
276
 
277
function updateName(signal, index) {
278
  var str;
279
 
280
  var idx = signal.indexOf(operator["OPEN_BRACE"]);
281
  if (idx != -1)
282
    str = signal.substring(0,idx) +
283
          index + signal.substring(idx);
284
  else str = signal + index;
285
 
286
  return str;
287
}
288
 
289
function retPterm(pt) {
290
  var str = "";
291
  if (!pterms[pt]) {
292
    if (specSig[pt]) pt = specSig[pt];
293
    return pt;
294
  }
295
 
296
  if (pterms[pt].length > 1) str += operator["OPEN_PTERM"];
297
  for (p=0; p<pterms[pt].length; p++) {
298
    var sig = pterms[pt][p];
299
    if (sig.indexOf("xPUP_0") != -1) continue;
300
    if (p>0) str += " " + operator["AND"] + " ";
301
    var neg = 0;
302
    if (sig.indexOf("/") != -1) {
303
      sig = sig.substring(1, sig.length);
304
      str += operator["NOT"];
305
      neg = 1;
306
    }
307
 
308
    str += retSigName(sig);
309
  }
310
  if (pterms[pt].length > 1) str += operator["CLOSE_PTERM"];
311
 
312
  return str;
313
}
314
 
315
function retFBMC(str) {
316
  return str.substring(0,str.length-2);
317
}
318
 
319
function retD1D2(signal) {
320
  var str = "";
321
 
322
  dOneLit = true;
323
  if (d1[signal]) {
324
    var currImp = "";
325
    for (i=0; i<d1[signal].length; i++) {
326
      if (!eqnType && d1imp[signal] && (d1imp[signal][i] == "1")) {
327
        if (currImp != retFBMC(d1[signal][i]))  {
328
          currImp = retFBMC(d1[signal][i]);
329
          str += nlStr + operator["IMPORT"] + currImp;
330
        }
331
      }
332
      if (i>0) str += nlTabStr + operator["OR"] + spcStr;
333
      str += retPterm(d1[signal][i]);
334
    }
335
 
336
    if (d2[signal]) str += nlTabStr + operator["XOR"]+ spcStr;
337
  }
338
 
339
  if (d2[signal]) {
340
    var currImp = "";
341
    for (i=0; i<d2[signal].length; i++) {
342
      if (!eqnType && d2imp[signal] && (d2imp[signal][i] == "1")) {
343
        if (currImp != retFBMC(d2[signal][i]))  {
344
          currImp = retFBMC(d2[signal][i]);
345
          str += nlStr + operator["IMPORT"] + currImp;
346
        }
347
      }
348
      if (i>0) str += nlTabStr + operator["OR"] + spcStr;
349
      str += retPterm(d2[signal][i]);
350
    }
351
  }
352
 
353
  if (str == "GND") str = operator["GND"];
354
  else if (str == "VCC") str = operator["VCC"];
355
  else if (!isOneLiteral(str)) {
356
    dOneLit = false;
357
 
358
    var type = retSigType(retSigIndex(signal));
359
    if ((type == operator["FD"]) ||
360
        (type == operator["FDD"])) type = operator["_D"];
361
    else if ((type == operator["FT"]) ||
362
             (type == operator["FTD"])) type = operator["_T"];
363
    else if (type == operator["LD"] && eqnType) type = "_D";
364
 
365
    var tmpStr = updateName(retSigName(signal), type);
366
    tmpStr += spcStr + operator["EQUAL_COLON"];
367
    var idx = retSigIndex(signal);
368
    if (eqnType && sigNegs[idx] == "ON") tmpStr += operator["NOT"] + operator["OPEN_NEGATE"];
369
    str = tmpStr + str;
370
    if (eqnType && sigNegs[idx] == "ON") str += operator["CLOSE_NEGATE"];
371
    str += operator["ENDLN"];
372
 
373
  }
374
 
375
  return str;
376
}
377
 
378
function retClk(signal) {
379
  var str = "";
380
 
381
  if (clk[signal]) {
382
    if (clk[signal].length == 1) {
383
      var pterm = retPterm(clk[signal][0]);
384
      if (clkNegs[signal]) {
385
        str += operator["NOT"];
386
        if (!isOneLiteral(pterm)) str += operator["OPEN_NEGATE"];
387
      }
388
      str += pterm;
389
      if (clkNegs[signal] && !isOneLiteral(pterm)) str += operator["CLOSE_NEGATE"];
390
    }
391
    else {
392
      if (clkNegs[signal]) str += operator["NOT"] + operator["OPEN_NEGATE"];
393
      var currImp = "";
394
      for (i=0; i<clk[signal].length; i++) {
395
        if (!eqnType && clkimp[signal] && (clkimp[signal][i] == "1")) {
396
          if (currImp != retFBMC(clk[signal][i]))  {
397
            currImp = retFBMC(clk[signal][i]);
398
            str += nlStr + operator["IMPORT"] + currImp;
399
          }
400
        }
401
        if (i>0) str += nlTabStr + operator["OR"] + spcStr;
402
        str += retPterm(clk[signal][i]);
403
      }
404
      if (clkNegs[signal]) str += operator["CLOSE_NEGATE"];
405
      str += operator["ENDLN"];
406
    }
407
  }
408
  else if (gblclk[signal]) {
409
    if (gblclk[signal].length == 1) {
410
      var pterm = retPterm(gblclk[signal][0]);
411
      if (clkNegs[signal]) {
412
        str += operator["NOT"];
413
        if (!isOneLiteral(pterm)) str += operator["OPEN_NEGATE"];
414
      }
415
      str += pterm;
416
      if (clkNegs[signal] && !isOneLiteral(pterm)) str += operator["CLOSE_NEGATE"];
417
    }
418
    else {
419
      if (clkNegs[signal]) str += operator["NOT"] + operator["OPEN_NEGATE"];
420
      for (i=0; i<gblclk[signal].length; i++) {
421
        if (i>0) str += nlTabStr + operator["OR"] + spcStr;
422
        str += retPterm(gblclk[signal][i]);
423
      }
424
      if (clkNegs[signal]) str += operator["CLOSE_NEGATE"];
425
      str += operator["ENDLN"] + tabStr + cClrS +
426
             operator["COMMENT"] + spcStr + operator["GCK_COM"] + cClrE;
427
    }
428
  }
429
  else if (eqnType) str += operator["B0"];
430
 
431
  return str;
432
}
433
 
434
function retRst(signal) {
435
  var str = "";
436
 
437
  if (rst[signal]) {
438
    if (rst[signal].length == 1) {
439
      var currImp;
440
      if (!eqnType && rstimp[signal] && (rstimp[signal][0] == "1")) {
441
        if (currImp != retFBMC(rst[signal][0]))  {
442
          currImp = retFBMC(rst[signal][0]);
443
          str += nlStr + operator["IMPORT"] + currImp;
444
        }
445
      }
446
      if (rstNegs[signal]) str += operator["NOT"];
447
      str += retPterm(rst[signal][0]);
448
    }
449
    else {
450
      var currImp = "";
451
      if (rstNegs[signal]) str += operator["NOT"] + operator["OPEN_NEGATE"];
452
      for (i=0; i<rst[signal].length; i++) {
453
        if (!eqnType && rstimp[signal] && (rstimp[signal][i] == "1")) {
454
          if (currImp != retFBMC(rst[signal][i]))  {
455
            currImp = retFBMC(rst[signal][i]);
456
            str += nlStr + operator["IMPORT"] + currImp;
457
          }
458
        }
459
        if (i>0) str += nlTabStr + operator["OR"] + spcStr;
460
        str += retPterm(rst[signal][i]);
461
      }
462
      if (rstNegs[signal]) str += operator["CLOSE_NEGATE"];
463
      str += operator["ENDLN"];
464
    }
465
  }
466
  else if (gblrst[signal]) {
467
    if (gblrst[signal].length == 1) {
468
      if (rstNegs[signal]) str += operator["NOT"];
469
      str += retPterm(gblrst[signal][0]);
470
    }
471
    else {
472
      if (rstNegs[signal]) str += operator["NOT"] + operator["OPEN_NEGATE"];
473
      for (i=0; i<gblrst[signal].length; i++) {
474
        if (i>0) str += nlTabStr + operator["OR"] + spcStr;
475
        str += retPterm(gblrst[signal][i]);
476
      }
477
      if (rstNegs[signal]) str += operator["CLOSE_NEGATE"];
478
      str += operator["ENDLN"] + tabStr + cClrS +
479
             operator["COMMENT"] + spcStr + operator["GSR_COM"] + cClrE;
480
    }
481
  }
482
  else if (eqnType) str += operator["B0"];
483
 
484
  return str;
485
}
486
 
487
function retSet(signal) {
488
  var str = "";
489
 
490
  if (set[signal]) {
491
    if (set[signal].length == 1) {
492
      var currImp = "";
493
      if (!eqnType && setimp[signal] && (setimp[signal][0] == "1")) {
494
        if (currImp != retFBMC(set[signal][0]))  {
495
          currImp = retFBMC(set[signal][0]);
496
          str += nlStr + operator["IMPORT"] + currImp;
497
        }
498
      }
499
      if (setNegs[signal]) str += operator["NOT"];
500
      str += retPterm(set[signal][0]);
501
    }
502
    else {
503
      var currImp = "";
504
      if (setNegs[signal]) str += operator["NOT"] + operator["OPEN_NEGATE"];
505
      for (i=0; i<set[signal].length; i++) {
506
        if (!eqnType && setimp[signal] && (setimp[signal][i] == "1")) {
507
          if (currImp != retFBMC(set[signal][i]))  {
508
            currImp = retFBMC(set[signal][i]);
509
            str += nlStr + operator["IMPORT"] + currImp;
510
          }
511
        }
512
        if (i>0) str += nlTabStr + operator["OR"] + spcStr;
513
        str += retPterm(set[signal][i]);
514
      }
515
      if (setNegs[signal]) str += operator["CLOSE_NEGATE"];
516
      str += operator["ENDLN"];
517
    }
518
  }
519
  else if (gblset[signal]) {
520
    if (gblset[signal].length == 1) {
521
      if (setNegs[signal]) str += operator["NOT"];
522
      str += retPterm(gblset[signal][0]);
523
    }
524
    else {
525
      if (setNegs[signal]) str += operator["NOT"] + operator["OPEN_NEGATE"];
526
      for (i=0; i<gblset[signal].length; i++) {
527
        if (i>0) str += nlTabStr + operator["OR"] + spcStr;
528
        str += retPterm(gblset[signal][i]);
529
      }
530
      if (setNegs[signal]) str += operator["CLOSE_NEGATE"];
531
      str += operator["ENDLN"] + tabStr + cClrS +
532
             operator["COMMENT"] + spcStr + operator["GSR_COM"] + cClrE;
533
    }
534
  }
535
  else if (eqnType) str += operator["B0"];
536
 
537
  return str;
538
}
539
 
540
function retCE(signal) {
541
  var str = "";
542
 
543
  if (ce[signal]) {
544
    if (ce[signal].length == 1) {
545
      var currImp = "";
546
      if (!eqnType && ceimp[signal] && (ceimp[signal][0] == "1")) {
547
        if (currImp != retFBMC(ce[signal][0]))  {
548
          currImp = retFBMC(ce[signal][0]);
549
          str += nlStr + operator["IMPORT"] + currImp;
550
        }
551
      }
552
      if (ceNegs[signal]) str += operator["NOT"];
553
      str += retPterm(ce[signal][0]);
554
    }
555
    else {
556
      var currImp = "";
557
      if (ceNegs[signal]) str += operator["NOT"] + operator["OPEN_NEGATE"];
558
      for (i=0; i<ce[signal].length; i++) {
559
        if (!eqnType && ceimp[signal] && (ceimp[signal][i] == "1")) {
560
          if (currImp != retFBMC(ce[signal][i]))  {
561
            currImp = retFBMC(ce[signal][i]);
562
            str += nlStr + operator["IMPORT"] + currImp;
563
          }
564
        }
565
        if (i>0) str += nlTabStr + operator["OR"] + spcStr;
566
        str += retPterm(ce[signal][i]);
567
      }
568
      if (ceNegs[signal]) str += operator["CLOSE_NEGATE"];
569
      str += operator["ENDLN"];
570
    }
571
  }
572
  else if (eqnType) str += operator["B1"];
573
 
574
  return str;
575
}
576
 
577
function retTrst(signal) {
578
  var str = "";
579
  if (trst[signal]) {
580
    if (trstNegs[signal])
581
      str += operator["NOT"] + operator["OPEN_NEGATE"];
582
    for (i=0; i<trst[signal].length; i++) {
583
      var currImp = "";
584
      if (!eqnType && trstimp[signal] && (trstimp[signal][0] == "1")) {
585
        if (currImp != retFBMC(trst[signal][0]))  {
586
          currImp = retFBMC(trst[signal][0]);
587
          str += nlStr + operator["IMPORT"] + currImp;
588
        }
589
      }
590
      if (i>0) str += nlTabStr + operator["OR"] + spcStr;
591
      str += retPterm(trst[signal][i]);
592
    }
593
    if (trstNegs[signal]) str += operator["CLOSE_NEGATE"];
594
  }
595
  else if (gbltrst[signal]) {
596
    if (trstNegs[signal])
597
      str += operator["NOT"] + operator["OPEN_NEGATE"];
598
    for (i=0; i<gbltrst[signal].length; i++) {
599
      if (i>0) str += nlTabStr + operator["OR"] + spcStr;
600
      str += retPterm(gbltrst[signal][i]);
601
    }
602
    if (trstNegs[signal]) str += operator["CLOSE_NEGATE"];
603
  }
604
 
605
  str += operator["ENDLN"];
606
  return str;
607
}
608
 
609
function retEqn(signal) {
610
  var str = inregStr = "";
611
  var iStr = qStr = "";
612
  var dStr = dEqn = "";
613
  var cStr = cEqn = "";
614
  var clrStr = clrEqn = "";
615
  var preStr = preEqn = "";
616
  var ceStr = ceEqn = "";
617
  var oeStr = oeEqn = "";
618
  var sigName = retSigName(signal);
619
 
620
  var type = retSigType(retSigIndex(signal));
621
 
622
  if (gbltrst[signal] || trst[signal]) iStr = operator["_I"];
623
  if (eqnType) qStr = updateName(sigName, iStr);
624
 
625
  if (inreg[signal]) {
626
    if (!eqnType)
627
      inregStr = operator["COMMENT"] + " Direct Input Register" + nlStr;
628
    dStr = retSigName(inreg[signal][0]);
629
  }
630
  else dStr = retD1D2(signal);
631
  if (eqnType && !dOneLit) {
632
    dEqn = dStr;
633
    dStr = dStr.substring(0,dStr.indexOf(operator["EQUAL_COLON"]));
634
  }
635
  else if (!eqnType) {
636
    if (!dOneLit) dStr = dStr.substring(dStr.indexOf(operator["EQUAL_COLON"])+2);
637
    if (sigNegs[retSigIndex(signal)] == "ON") dEqn += operator["NOT"];
638
    dEqn += sigName;
639
    if ((type == operator["FT"]) ||
640
        (type == operator["FTD"])) dEqn += operator["_T"];
641
    else if ((type == operator["FD"]) ||
642
             (type == operator["FTD"])||
643
             (type == operator["LD"])) dEqn += operator["_D"];
644
    dEqn += " ";
645
    if ((type != operator["Q"]) && (type != operator["LD"]))
646
      dEqn += operator["EQUAL_COLON"];
647
    else  dEqn += operator["EQUAL"];
648
    dEqn += dStr;
649
    if (dOneLit) dEqn += operator["ENDLN"];
650
  }
651
 
652
  cStr = retClk(signal);
653
  if (eqnType && !isOneLiteral(cStr)){
654
    cEqn = cStr;
655
    if (cEqn.indexOf(operator["ENDLN"]) == -1)
656
      cEqn += operator["ENDLN"];
657
    cStr = updateName(sigName, operator["_C"]);
658
  }
659
  else if (!eqnType && cStr) {
660
    cEqn += cStr;
661
    cStr = tabStr + sigName;
662
    if (type == operator["LD"]) cStr += operator["_LH"];
663
    else if (type == operator["FDD"]) cStr += operator["_DEC"];
664
    else                        cStr += operator["_C"];
665
    if (cEqn.indexOf(operator["ENDLN"]) == -1)
666
      cEqn += operator["ENDLN"];
667
    if (gblclk[signal]) cEqn += tabStr + operator["COMMENT"] + " " + operator["GCK_COM"];
668
  }
669
 
670
  clrStr = retRst(signal);
671
  if (eqnType && !isOneLiteral(clrStr)){
672
    clrEqn = clrStr;
673
    if (cEqn.indexOf(operator["ENDLN"]) == -1)
674
      clrEqn += operator["ENDLN"];
675
    clrStr = updateName(sigName, operator["_CLR"]);
676
  }
677
  else if (!eqnType && clrStr) {
678
    clrEqn += clrStr;
679
    clrStr = tabStr + sigName + operator["_CLR"];
680
    if (clrEqn.indexOf(operator["ENDLN"]) == -1)
681
      clrEqn += operator["ENDLN"];
682
    if (gblrst[signal]) clrEqn += tabStr + operator["COMMENT"] + " " + operator["GSR_COM"];
683
  }
684
 
685
  preStr = retSet(signal);
686
  if (eqnType && !isOneLiteral(preStr)){
687
    preEqn = preStr;
688
    if (cEqn.indexOf(operator["ENDLN"]) == -1)
689
      preEqn += operator["ENDLN"];
690
    preStr = updateName(sigName, operator["_PRE"]);
691
  }
692
  else if (!eqnType && preStr) {
693
    preEqn += preStr;
694
    preStr = tabStr + sigName + operator["_PRE"];
695
    if (preEqn.indexOf(operator["ENDLN"]) == -1)
696
      preEqn += operator["ENDLN"];
697
    if (gblset[signal]) preEqn += tabStr + operator["COMMENT"] + " " + operator["GSR_COM"];
698
  }
699
 
700
  if (!is9500()) {
701
    ceStr = retCE(signal);
702
    if (eqnType && !isOneLiteral(ceStr)){
703
      ceEqn = ceStr;
704
      if (cEqn.indexOf(operator["ENDLN"]) == -1)
705
        ceEqn += operator["ENDLN"];
706
      ceStr = updateName(sigName, operator["_CE"]);
707
    }
708
    else if (!eqnType && ceStr) {
709
      ceEqn += ceStr;
710
      ceStr = tabStr + sigName + operator["_CE"];
711
      if (ceEqn.indexOf(operator["ENDLN"]) == -1)
712
        ceEqn += operator["ENDLN"];
713
    }
714
  }
715
 
716
  if (eqnType && trst[signal]) oeEqn = retTrst(signal)
717
  else if (!eqnType && (trst[signal] || gbltrst[signal])) oeEqn = retTrst(signal);
718
 
719
 
720
  var newline = false;
721
  if (type == "") {
722
    str += operator["ASSIGN"] + qStr + " " + operator["EQUAL"];
723
    if (dOneLit) str += dStr;
724
    else         str += dEqn.substring(dEqn.indexOf(operator["EQUAL"])+2);
725
    if (oeEqn != "") {
726
      var oeStr = updateName(sigName, operator["_OE"]);
727
      if (eqnType == 1) {
728
        str += nlStr + sigName + operator["OE_START"] + qStr + operator["OE_WHEN"] + oeStr +
729
               operator["OE_EQUAL"] + operator["B1"] + operator["OE_ELSE"] +
730
               operator["OE_EQUAL"] + operator["BZ"] + operator["ENDLN"];
731
      }
732
      else if (eqnType == 2) {
733
        str += nlStr + operator["ASSIGN"] + sigName + operator["OE_START"] +
734
               oeStr + operator["OE_WHEN"] + qStr +
735
               operator["OE_ELSE"] + operator["BZ"] + operator["ENDLN"];
736
      }
737
      str += nlStr + operator["ASSIGN"] + oeStr + " " + operator["EQUAL"] + " " + oeEqn;
738
    }
739
  }
740
  else {
741
    if (eqnType == 1) {
742
      str += type + "_" + removePar(retSigName(signal)) +
743
             ": " + type + " " + operator["START_EQN"] +
744
             qStr + ", " + dStr + ", " + cStr + ", " +
745
             clrStr + ", " + preStr;
746
      if (!is9500() && (type != operator["LD"])) str += ", " + ceStr;
747
      str += operator["END_EQN"] + operator["ENDLN"];
748
      newline = true;
749
    }
750
    else if (eqnType == 2) {
751
      str += type + " " +
752
             type + "_" + removePar(retSigName(signal)) +
753
             operator["START_EQN"] +
754
             qStr + ", " + dStr + ", " + cStr + ", " +
755
             clrStr + ", " + preStr;
756
      if (!is9500() && (type != operator["LD"])) str += ", " + ceStr;
757
      str += operator["END_EQN"] + operator["ENDLN"];
758
      newline = true;
759
    }
760
 
761
    if (dEqn != "") {
762
      if (newline) str += nlStr;
763
      if (inregStr) str += inregStr;
764
      str += operator["ASSIGN"] + dEqn;
765
    }
766
 
767
    if (cEqn != "") {
768
      if (newline || !eqnType) str += nlStr;
769
      str += operator["ASSIGN"] + cStr + " " + operator["EQUAL"] + " " + cEqn;
770
    }
771
 
772
    if (clrEqn != "")  {
773
      if (newline || !eqnType) str += nlStr;
774
      str += operator["ASSIGN"] + clrStr + " " + operator["EQUAL"] + " " + clrEqn;
775
    }
776
 
777
 
778
    if (preEqn != "")  {
779
      if (newline || !eqnType) str += nlStr;
780
      str += operator["ASSIGN"] + preStr + " " + operator["EQUAL"] + " " + preEqn;
781
    }
782
 
783
    if (ceEqn != "")  {
784
      if (newline || !eqnType) str += nlStr;
785
      str += operator["ASSIGN"] + ceStr + " " + operator["EQUAL"] + " " + ceEqn;
786
    }
787
 
788
    if (oeEqn != "") {
789
      if (eqnType == 1) {
790
        var oeStr = updateName(sigName, operator["_OE"]);
791
        str += nlStr + sigName + operator["OE_START"] + qStr + operator["OE_WHEN"] + oeStr +
792
               operator["OE_EQUAL"] + operator["B1"] + operator["OE_ELSE"] +
793
               operator["OE_EQUAL"] + operator["BZ"] + operator["ENDLN"];
794
        str += nlStr + oeStr + " " + operator["EQUAL"] + " " + oeEqn;
795
      }
796
      else if (eqnType == 2) {
797
        var oeStr = updateName(sigName, operator["_OE"]);
798
        str += nlStr + operator["ASSIGN"] + sigName + operator["OE_START"] + oeStr + operator["OE_WHEN"] + qStr +
799
               operator["OE_ELSE"] + operator["BZ"] + operator["ENDLN"];
800
        str += nlStr + operator["ASSIGN"] + oeStr + " " + operator["EQUAL"] + " " + oeEqn;
801
      }
802
      else {
803
        var oeStr = sigName + operator["_OE"];
804
        if (gbltrst[signal])
805
          oeEqn += tabStr + operator["COMMENT"] + " " + operator["GTS_COM"];
806
        str += nlStr + tabStr + oeStr + " " + operator["EQUAL"] + " " + oeEqn;
807
      }
808
    }
809
  }
810
 
811
  return str;
812
}
813
 
814
function retFamily() {
815
  var family = "xc9500";
816
  if (device.indexOf("XC2C") != -1) {
817
    if (device.indexOf("S") != -1)  family = "cr2s";
818
    else                            family = "xbr";
819
  }
820
  else if (device.indexOf("XCR3") != -1) family = "xpla3";
821
  else {
822
    if (device.indexOf("XL") != -1)  family = "xc9500xl";
823
    if (device.indexOf("XV") != -1)  family = "xc9500xv";
824
  }
825
 
826
  return family;
827
}
828
 
829
function retDesign() { return design; }
830
 
831
function getPterm(pt, type) {
832
  if (type) return type + " = " + retPterm(pt);
833
  return "PT" + pt.substring(pt.indexOf('_')+1,pt.length) + " = " + retPterm(pt);
834
}
835
 
836
function getPRLDName(prld) {
837
  if (eqnType != 0) return prld;
838
  else if (prld == "VCC") return "S";
839
  return "R";
840
}
841
 
842
function retFbnand(signal) {
843
  var str = operator["COMMENT"] + spcStr + "Foldback NAND";
844
  str += nlStr + retSigName(signal) + spcStr + operator["EQUAL"] + spcStr;
845
  for (i=0; i<fbnand[signal].length; i++) {
846
    if (i>0) str += nlTabStr + operator["OR"] + spcStr;
847
    str += retPterm(fbnand[signal][i]);
848
  }
849
 
850
  return str;
851
}
852
 
853
function getEqn(signal) { return retEqn(signal); }
854
 
855
function retUimPterm(pt) {
856
  var str = "";
857
  if (!uimPterms[pt]) return pt;
858
  for (p=0; p<uimPterms[pt].length; p++) {
859
    if (p>0) str += spcStr + operator["AND"] + spcStr;
860
    var sig = uimPterms[pt][p];
861
    if (sig.indexOf("/") != -1) sig = sig.substring(1, sig.length);
862
 
863
    str += retSigName(sig);
864
  }
865
  return str;
866
}
867
 
868
function retUimEqn(signal) {
869
  var str = operator["COMMENT"] + spcStr + "FC Node" + nlStr;
870
  var neg = 0;
871
  if (uimSigNegs[s] == "ON") str += operator["NOT"];
872
  str += retSigName(signal) + spcStr + operator["EQUAL"];
873
  str += retUimPterm(signal) + ";";
874
 
875
  return str;
876
}
877
 
878
function retLegend(url) {
879
  var str = "";
880
  if (!eqnType && !isXC95()) {
881
    str = "Legend: " + "&lt;" + "signame" + "&gt;" + ".COMB = combinational node mapped to ";
882
    str += "the same physical macrocell as the FastInput \"signal\" (not logically related)";
883
  }
884
  else if (eqnType) {
885
    str = "Register Legend:";
886
    if (is9500()) {
887
      str += nlTabStr + "FDCPE (Q,D,C,CLR,PRE);";
888
      str += nlTabStr + "FTCPE (Q,D,C,CLR,PRE);";
889
      str += nlTabStr + "LDCP  (Q,D,G,CLR,PRE);";
890
    }
891
    else if (retFamily() == "xbr") {
892
      str += nlTabStr + "FDCPE (Q,D,C,CLR,PRE,CE);";
893
      str += nlTabStr + "FDDCPE (Q,D,C,CLR,PRE,CE);";
894
      str += nlTabStr + "FTCPE (Q,D,C,CLR,PRE,CE);";
895
      str += nlTabStr + "FTDCPE (Q,D,C,CLR,PRE,CE);";
896
      str += nlTabStr + "LDCP  (Q,D,G,CLR,PRE);";
897
    }
898
    else {
899
      str += nlTabStr + "FDCPE (Q,D,C,CLR,PRE,CE);";
900
      str += nlTabStr + "FTCPE (Q,D,C,CLR,PRE,CE);";
901
      str += nlTabStr + "LDCP  (Q,D,G,CLR,PRE);";
902
    }
903
  }
904
  return str;
905
}
906
 

powered by: WebSVN 2.1.0

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