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

Subversion Repositories sc2v

[/] [sc2v/] [trunk/] [src/] [sc2v_step1.y] - Blame information for rev 39

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 jcastillo
/* -----------------------------------------------------------------------------
2
 *
3 16 jcastillo
 *  SystemC to Verilog Translator v0.4
4 31 jcastillo
 *  Provided by Universidad Rey Juan Carlos
5 2 jcastillo
 *
6
 * -----------------------------------------------------------------------------
7
 *  This program is free software; you can redistribute it and/or modify
8
 *  it under the terms of the GNU General Public License as published by
9
 *  the Free Software Foundation; either version 2 of the License, or
10
 *  (at your option) any later version.
11
 *
12
 *  This program is distributed in the hope that it will be useful,
13
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
14
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
 *  GNU Library General Public License for more details.
16
 *
17
 *  You should have received a copy of the GNU General Public License
18
 *  along with this program; if not, write to the Free Software
19
 *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20
 */
21
 
22
 
23
%{
24
#include 
25
#include 
26 33 jcastillo
#include "sglib.h"
27 14 jcastillo
#include "sc2v_step1.h"
28 2 jcastillo
 
29 16 jcastillo
  int lineno = 1;
30 12 jcastillo
  int processfound = 0;
31
  int switchfound = 0;
32 23 jcastillo
  int lastswitch=0;
33 12 jcastillo
  int switchparenthesis[256];
34
  int ifdeffound = 0;
35
  char *processname, *processname2;
36
  char *fileregs;
37
  char *filename;
38
  int openedkeys = 0;
39
  int newline = 0;
40
  int reg_found = 0;
41 35 jcastillo
  int sigreg_found = 0;
42 25 jcastillo
  int reglenght = 0;
43
  int writelenght = 0;
44 20 jcastillo
  int array_size=0;
45 19 jcastillo
  int integer_found=0;
46 12 jcastillo
  int regs_end;
47
  int i = 0;                    //for loops counter
48
  FILE *file;
49
  FILE *regs_file;
50
  char *regname, *regname2;
51
  char *lastword;               // Stores last WORD for use it in WRITE
52
  char *file_defines;
53
  FILE *FILE_DEFINES;
54
  char *file_writes;
55
  FILE *FILE_WRITES;            //FILE to store .write to know if it is a wire or reg
56
  int definefound = 0;
57
  int defineinvocationfound = 0;
58
  int opencorchfound = 0;
59
  int defineparenthesis = 0;
60
  int openedcase = 0;
61 28 jcastillo
  int writingvar=0;
62 2 jcastillo
 
63 12 jcastillo
  int default_break_found = 0;
64
  int default_found;
65 2 jcastillo
 
66 33 jcastillo
  int struct_found=0;
67
  int end_struct=0;
68
  int ignore_semicolon=0;
69
  char *structname;
70
 
71 4 jcastillo
//Directives variables
72 12 jcastillo
  int translate;
73
  int verilog;
74
  int writemethod;
75 4 jcastillo
 
76 12 jcastillo
  void yyerror (const char *str)
77
  {
78 15 jcastillo
    fprintf (stderr, "line: %d error: %s\n", lineno, str);
79 12 jcastillo
  }
80 2 jcastillo
 
81 12 jcastillo
  int yywrap ()
82
  {
83
    return 1;
84
  }
85 2 jcastillo
 
86 12 jcastillo
  main ()
87
  {
88
    int i;
89 10 jcastillo
 
90 16 jcastillo
    defineslist = NULL;
91
    regslist = NULL;
92 33 jcastillo
    structslist = NULL;
93
    structsreglist = NULL;
94 2 jcastillo
 
95 35 jcastillo
    fprintf (stderr, "\nSystemC to Verilog Translator v0.6");
96 16 jcastillo
    fprintf (stderr,
97 35 jcastillo
             "\nProvided by URJC(Universidad Rey Juan Carlos)\nhttp://gdhwsw.escet.urjc.es\n\n");
98 16 jcastillo
    fprintf (stderr, "Parsing implementation file.......\n\n");
99
 
100 14 jcastillo
    processname = (char *) malloc (256 * sizeof (char));
101
    processname2 = (char *) malloc (256 * sizeof (char));
102
    fileregs = (char *) malloc (256 * sizeof (char));
103 12 jcastillo
 
104 14 jcastillo
    file_defines = (char *) malloc (256 * sizeof (char));
105 12 jcastillo
    strcpy (file_defines, (char *) "file_defines.sc2v");
106
    FILE_DEFINES = fopen (file_defines, (char *) "w");
107 16 jcastillo
 
108 14 jcastillo
    file_writes = (char *) malloc (256 * sizeof (char));
109 12 jcastillo
    strcpy (file_writes, (char *) "file_writes.sc2v");
110
    FILE_WRITES = fopen (file_writes, (char *) "w");
111
 
112 16 jcastillo
    lastword = (char *) malloc (sizeof (char) * 256);
113 33 jcastillo
    structname = (char *) malloc (sizeof (char) * 256);
114 12 jcastillo
 
115
    for (i = 0; i < 256; i++)
116
      switchparenthesis[i] = 0;
117
 
118
    translate = 1;
119
    verilog = 0;
120
    writemethod = 0;
121 16 jcastillo
 
122
    FILE *yyin = stdin;
123
    FILE *yyout = stdout;
124 12 jcastillo
    yyparse ();
125
    fclose (FILE_WRITES);
126
    fclose (FILE_DEFINES);
127 16 jcastillo
 
128
    fprintf (stderr, "\nDone\n\n");
129 12 jcastillo
  }
130
 
131 2 jcastillo
%}
132
 
133 35 jcastillo
%token NUMBER WORD SC_REG SC_SIGREG BOOL BIGGER LOWER OPENKEY CLOSEKEY WRITE SYMBOL NEWLINE ENUM INCLUDE
134 16 jcastillo
%token COLON SEMICOLON RANGE OPENPAR CLOSEPAR TWODOUBLEPOINTS OPENCORCH CLOSECORCH SWITCH CASE DEFAULT BREAK
135 19 jcastillo
%token HEXA DEFINE READ TRANSLATEOFF TRANSLATEON VERILOGBEGIN VERILOGEND TAB DOLLAR MINEQ
136
%token VOID TTRUE TFALSE ENDFUNC INC DEC INTEGER EQUALS
137 33 jcastillo
%token PIFDEF PIFNDEF PENDDEF PELSE COMMENT STRUCT DOT
138 2 jcastillo
 
139 16 jcastillo
%% commands:    /* empty */
140 12 jcastillo
|commands command;
141 2 jcastillo
 
142
command:
143 33 jcastillo
  struct_dec
144 16 jcastillo
  |
145 33 jcastillo
  endfunc
146
  |
147 12 jcastillo
  voidword
148
  |
149
  include
150
  |
151
  dollar
152
  |
153
  tab
154
  |
155
  read
156
  |
157 16 jcastillo
  sc_reg
158 12 jcastillo
  |
159 35 jcastillo
  sc_sigreg
160
  |
161 19 jcastillo
  integer
162
  |
163 12 jcastillo
  number
164
  |
165
  bool
166
  |
167
  word
168
  |
169
  symbol
170
  |
171
  write
172
  |
173
  newline
174
  |
175
  openkey
176
  |
177
  closekey
178
  |
179
  colon
180
  |
181
  semicolon
182
  |
183
  range
184
  |
185
  openpar
186
  |
187 19 jcastillo
  closepar
188
  |
189
  void
190
  |
191
  opencorch
192
  |
193
  closecorch
194
  |
195
  bigger
196
  |
197
  lower
198
  |
199
  switch
200
  |
201
  case_only
202
  |
203
  case_number
204
  |
205
  case_hexnumber
206
  |
207 24 jcastillo
  case_hexword
208
  |
209
  case_hexnumberword
210
  |
211 19 jcastillo
  case_word
212
  |
213
  case_default
214
  |
215
  break
216
  |
217
  hexa
218
  |
219
  definemacro
220
  |
221
  defineword
222
  |
223 39 vasiliev
  definewordsimple
224
  |
225 19 jcastillo
  definenumber
226
  |
227
  translateoff
228
  |
229
  translateon
230
  |
231
  verilogbegin
232
  |
233
  verilogend
234
  |
235
  ifdef
236 27 jcastillo
  |
237
  ifndef
238 19 jcastillo
  |
239
  endif
240
  |
241
  pelse
242
  |
243
  ttrue
244
  |
245
  tfalse
246
  |
247
  increment
248
  |
249
  decrement
250
  |
251
  equal
252
  |
253 28 jcastillo
  minorequal
254
  |
255 33 jcastillo
  comment
256
  |
257
  struct_access
258
  ;
259
 
260
struct_access:
261
WORD DOT WORD
262
{
263 35 jcastillo
 
264 33 jcastillo
/*Struct access
265
 Check if it is a var acess or a reg*/
266
 if (newline){
267
   for (i = 0; i < openedkeys; i++)
268
      fprintf (file, "   ");
269
 }
270 35 jcastillo
 
271 33 jcastillo
 strcpy(structname,(char *)$3);
272
 strcat(structname,(char *)$1);
273
 regname2 = IsReg (regslist, structname);
274 35 jcastillo
 
275
 if (regname2 == NULL){
276 33 jcastillo
  fprintf (file, "%s ", structname);
277 35 jcastillo
 }else{
278 33 jcastillo
  fprintf (file, "%s", regname2);
279 35 jcastillo
}
280 33 jcastillo
  newline = 0;
281
 
282 35 jcastillo
 
283
 /*printf("Access to struct %s.%s\n",(char *)$1,(char *)$3);*/
284 33 jcastillo
}
285
 
286 19 jcastillo
minorequal:
287
MINEQ
288
{
289
 //This rule is needed because <= in the step two could be confused with a non-blocking assignment
290
 defineparenthesis = 0;
291
  if (translate == 1 && verilog == 0)
292
    {
293
      if (processfound)
294
        {
295
          fprintf (file, "<1+");
296
        }
297
    }
298
  else if (verilog == 1)
299
    fprintf (file, "<=");
300
};
301 4 jcastillo
 
302 16 jcastillo
endfunc:
303
ENDFUNC
304
{
305
  defineparenthesis = 0;
306
  if (translate == 1 && verilog == 0)
307
    {
308
      if (processfound)
309
        {
310
          for (i = 0; i < openedkeys; i++)
311
            fprintf (file, "   ");
312
          fprintf (file, "%s = ", processname);
313
        }
314
    }
315
  else if (verilog == 1)
316
    fprintf (file, "return ");
317
};
318 12 jcastillo
 
319 16 jcastillo
 
320 4 jcastillo
voidword:
321 12 jcastillo
VOID
322
{
323
  defineparenthesis = 0;
324
  if (verilog == 1)
325
    fprintf (file, " void");
326
};
327 4 jcastillo
 
328 12 jcastillo
 
329 4 jcastillo
include:
330 12 jcastillo
INCLUDE
331
{
332
  defineparenthesis = 0;
333
  if (verilog == 1)
334
    fprintf (file, " #include");
335
};
336 4 jcastillo
 
337
 
338
dollar:
339 12 jcastillo
DOLLAR
340
{
341
  defineparenthesis = 0;
342
  if (verilog == 1)
343
    fprintf (file, " $");
344
};
345 4 jcastillo
 
346
 
347
tab:
348 12 jcastillo
TAB
349
{
350
  defineparenthesis = 0;
351
  if (verilog == 1)
352
    fprintf (file, " \t");
353
};
354
 
355 2 jcastillo
read:
356 12 jcastillo
READ OPENPAR CLOSEPAR
357
{
358
  defineparenthesis = 0;
359
  if (verilog == 1)
360
    fprintf (file, ".read()");
361 4 jcastillo
 
362 12 jcastillo
}
363
 
364 39 vasiliev
definewordsimple:
365
DEFINE WORD
366
{
367
 
368
  defineparenthesis = 0;
369
  if (translate == 1 && verilog == 0)
370
    {
371
      if (processfound)
372
        {
373
          fprintf (file, "`define %s\n", (char *) $2);
374
        }
375
      else
376
        {
377
          fprintf (FILE_DEFINES, "`define %s\n", (char *) $2);
378
        }
379
    }
380
  else if (verilog == 1)
381
    fprintf (file, "#define %s\n", (char *) $2);
382
 
383
};
384
 
385 12 jcastillo
defineword:
386
DEFINE WORD WORD
387
{
388 16 jcastillo
 
389 12 jcastillo
  defineparenthesis = 0;
390
  if (translate == 1 && verilog == 0)
391
    {
392
      if (processfound)
393
        {
394
          fprintf (file, "`define %s %s\n", (char *) $2, (char *) $3);
395 16 jcastillo
          defineslist = InsertDefine (defineslist, (char *) $2);
396 12 jcastillo
        }
397
      else
398
        {
399
          fprintf (FILE_DEFINES, "`define %s %s\n", (char *) $2, (char *) $3);
400 16 jcastillo
          defineslist = InsertDefine (defineslist, (char *) $2);
401 12 jcastillo
        }
402
    }
403
  else if (verilog == 1)
404
    fprintf (file, "#define %s %s\n", (char *) $2, (char *) $3);
405
 
406
};
407
 
408
definenumber:
409
DEFINE WORD NUMBER
410
{
411 16 jcastillo
 
412 12 jcastillo
  defineparenthesis = 0;
413
  if (translate == 1 && verilog == 0)
414
    {
415
      if (processfound)
416
        {
417
          fprintf (file, "`define %s %d\n", (char *) $2, (int) $3);
418 16 jcastillo
          defineslist = InsertDefine (defineslist, (char *) $2);
419 12 jcastillo
        }
420
      else
421
        {
422
          fprintf (FILE_DEFINES, "`define %s %d\n", (char *) $2, (int) $3);
423 16 jcastillo
          defineslist = InsertDefine (defineslist, (char *) $2);
424 12 jcastillo
        }
425
    }
426
  else if (verilog == 1)
427
    fprintf (file, "#define %s %d\n", (char *) $2, (int) $3);
428
 
429
};
430
 
431
 
432
definemacro:
433
DEFINE WORD OPENPAR CLOSEPAR
434
{
435
  defineparenthesis = 0;
436
  //Macro found
437
  if (translate == 1 && verilog == 0)
438
    {
439 16 jcastillo
      defineslist = InsertDefine (defineslist, (char *) $2);
440
 
441 12 jcastillo
      definefound = 1;
442
      if (processfound)
443
        fprintf (file, "`define %s ", (char *) $2);
444
      else
445
        fprintf (FILE_DEFINES, "`define %s ", (char *) $2);
446
    }
447
  else if (verilog == 1)
448
    fprintf (file, "#define %s ()", (char *) $2);
449
}
450
 
451 19 jcastillo
void:
452
WORD TWODOUBLEPOINTS WORD OPENPAR
453 12 jcastillo
{
454
  defineparenthesis = 0;
455
  if (translate == 1 && verilog == 0)
456
    {
457
      strcpy (processname, (char *) $4);
458
      strcpy (processname2, (char *) $4);
459
      strcat (processname2, (char *) ".sc2v");
460
      strcpy (fileregs, (char *) $4);
461
      strcat (fileregs, (char *) "_regs.sc2v");
462
    }
463
  else if (verilog == 1)
464
    fprintf (file, " %s::%s()", (char *) $1, (char *) $3);
465
 
466
}
467
 
468 16 jcastillo
sc_reg:
469
SC_REG LOWER NUMBER BIGGER
470 12 jcastillo
{
471
  defineparenthesis = 0;
472
  if (translate == 1 && verilog == 0)
473
    {
474
      if (processfound)
475
        {
476 25 jcastillo
          writelenght=1;
477
          reglenght = $3;
478 12 jcastillo
          reg_found = 1;
479
        }
480
    }
481 16 jcastillo
};
482 2 jcastillo
 
483 35 jcastillo
sc_sigreg:
484
SC_SIGREG LOWER NUMBER BIGGER
485
{
486
  defineparenthesis = 0;
487
  if (translate == 1 && verilog == 0)
488
    {
489
      if (processfound)
490
        {
491
          writelenght=1;
492
          reglenght = $3;
493
          sigreg_found = 1;
494
        }
495
    }
496
};
497
 
498 19 jcastillo
integer:
499
INTEGER
500
{
501
  defineparenthesis = 0;
502
  if (translate == 1 && verilog == 0)
503
    {
504
      if (processfound)
505
        {
506
          fprintf (regs_file, "integer ");
507
          integer_found = 1;
508
        }
509
    }
510
};
511
 
512
 
513 2 jcastillo
bool:
514 12 jcastillo
BOOL
515
{
516
  defineparenthesis = 0;
517
  if (translate == 1 && verilog == 0)
518
    {
519
      if (processfound)
520
        {
521 25 jcastillo
          writelenght=1;
522
          reglenght=0;
523 12 jcastillo
          reg_found = 1;
524
        }
525
    }
526
  else if (verilog == 1)
527
    fprintf (file, "bool");
528
}
529 2 jcastillo
 
530 12 jcastillo
;
531
 
532 2 jcastillo
range:
533 12 jcastillo
RANGE OPENPAR NUMBER COLON NUMBER CLOSEPAR
534
{
535
  defineparenthesis = 0;
536
  if (translate == 1 && verilog == 0)
537
    {
538
      if (processfound)
539
        fprintf (file, "[%d:%d]", $3, $5);
540
      else if (definefound)
541
        fprintf (FILE_DEFINES, "[%d:%d]", $3, $5);
542
    }
543
  else if (verilog == 1)
544
    fprintf (file, ".range(%d,%d)", $3, $5);
545
}
546
 
547
;
548
 
549
number:
550
NUMBER
551
{
552
  defineparenthesis = 0;
553
  if (translate == 1 && verilog == 0)
554
    {
555
      if (processfound)
556 35 jcastillo
       if(opencorchfound && (reg_found || sigreg_found))
557 25 jcastillo
        fprintf (regs_file, "%d:0",$1-1);
558
       else
559
        fprintf (file, "%d", $1);
560 12 jcastillo
      else if (definefound)
561
        fprintf (FILE_DEFINES, "%d", $1);
562
    }
563
  else if (verilog == 1)
564
    fprintf (file, "%d", $1);
565 19 jcastillo
};
566 12 jcastillo
 
567 19 jcastillo
increment:
568
WORD INC
569
{
570
  defineparenthesis = 0;
571
  if (translate == 1 && verilog == 0)
572
       if (processfound){
573
        regname2 = IsReg (regslist, (char *) $1);
574
        if (regname2 == NULL){
575
            fprintf (file, "%s=%s+1", (char *) $1,(char *)$1);
576
        }else
577
            fprintf (file, "%s=%s+1", regname2,regname2);
578
       }
579
  else if (verilog == 1)
580
    fprintf (file, "%s++ ", (char *) $1);
581
};
582
 
583
decrement:
584
WORD DEC
585
{
586
  defineparenthesis = 0;
587
  if (translate == 1 && verilog == 0)
588
      if (processfound){
589
        regname2 = IsReg (regslist, (char *) $1);
590
        if (regname2 == NULL){
591
            fprintf (file, "%s=%s+1", (char *) $1,(char *)$1);
592
        }else
593
            fprintf (file, "%s=%s+1", regname2,regname2);
594
      }
595
  else if (verilog == 1)
596
    fprintf (file, "%s-- ", (char *) $1);
597
};
598 20 jcastillo
 
599 12 jcastillo
word:
600
WORD
601
{
602 16 jcastillo
 
603 12 jcastillo
  defineparenthesis = 0;
604
  if (translate == 1 && verilog == 0)
605
    {
606 28 jcastillo
          if(opencorchfound==0){
607
                strcpy (lastword, (char *) $1);
608
          }
609
 
610 12 jcastillo
      if (processfound)
611
        {
612 23 jcastillo
          if(lastswitch){
613
            openedcase=0;
614 33 jcastillo
          }else if (openedcase){
615 12 jcastillo
              fprintf (file, " :\n");
616
 
617
              for (i = 0; i < openedkeys; i++)
618
                fprintf (file, "   ");
619
 
620 23 jcastillo
              fprintf(file,"begin\n");
621
              openedcase=0;
622 33 jcastillo
          }
623
          if (end_struct){
624
             end_struct=0;
625
             struct_found=0;
626
             ignore_semicolon=1;
627
             structslist=InsertStruct(structslist,(char *)$1,structsreglist);
628 12 jcastillo
 
629 33 jcastillo
             //ShowStructs(structslist);
630
 
631
             /*Now we should convert all the elements of the struct into regs*/
632
             StructRegNode *srll;
633
             SGLIB_LIST_MAP_ON_ELEMENTS (StructRegNode,structsreglist, srll,next,
634
             {
635
               if(srll->length==0)
636
                 fprintf (regs_file, "reg ");
637
               else
638
                 fprintf (regs_file, "reg[%d:0] ", (-1 +srll->length));
639
 
640
               regname =(char *) malloc (sizeof (char) * (strlen (srll->name) + 1));
641
               regname2 = (char *) malloc (sizeof (char) * (strlen (srll->name) + strlen (processname)+strlen((char *)$1)) + 1);
642
               strcpy (regname, srll->name);
643
               strcpy (regname2, srll->name);
644
               strcat (regname, (char *)$1);
645
               strcat (regname2, (char *)$1);
646
               strcat (regname2, processname);
647
               fprintf (regs_file, "%s;\n", regname2); /*By the moment no arrays inside the struct supported*/
648
 
649
               regslist = InsertReg (regslist, regname, regname2);
650
               free (regname);
651
               free (regname2);
652
               structsreglist=NULL;
653
               reg_found=0; /*To avoid arrays in sructs the interpretation finish here*/
654 35 jcastillo
          sigreg_found = 0;
655 33 jcastillo
             );}
656
 
657 35 jcastillo
          }else if(struct_found && (reg_found || sigreg_found)){
658 33 jcastillo
              structsreglist=InsertStructReg(structsreglist,(char *)$1,reglenght);
659
 
660 35 jcastillo
          }else if (reg_found || sigreg_found){
661 25 jcastillo
              if(writelenght){
662
               writelenght=0;
663
               if(reglenght==0)
664 35 jcastillo
            if(sigreg_found)
665
                    fprintf (regs_file, "reg signed");
666
            else
667
               fprintf (regs_file, "reg ");
668 25 jcastillo
               else
669 35 jcastillo
            if(sigreg_found)
670
               fprintf (regs_file, "reg signed [%d:0] ", (-1 +reglenght));
671
            else
672
                fprintf (regs_file, "reg [%d:0] ", (-1 +reglenght));
673
              }
674
 
675 19 jcastillo
              regname = (char *) malloc (sizeof (char) * (strlen ((char *) $1) + 1));
676
              regname2 = (char *) malloc (sizeof (char) * (strlen ((char *) $1) + strlen (processname)) + 1);
677
              strcpy (regname, (char *) $1);
678
              strcpy (regname2, (char *) $1);
679
              strcat (regname2, processname);
680
              fprintf (regs_file, "%s", regname2);
681 12 jcastillo
 
682 19 jcastillo
              regslist = InsertReg (regslist, regname, regname2);
683
              free (regname);
684
              free (regname2);
685 33 jcastillo
          }else if(integer_found){
686 19 jcastillo
              regname = (char *) malloc (sizeof (char) * (strlen ((char *) $1) + 1));
687
              regname2 = (char *) malloc (sizeof (char) * (strlen ((char *) $1) + strlen (processname)) + 1);
688 12 jcastillo
              strcpy (regname, (char *) $1);
689
              strcpy (regname2, (char *) $1);
690
              strcat (regname2, processname);
691 19 jcastillo
              fprintf (regs_file, "%s;\n", regname2);
692 16 jcastillo
 
693
              regslist = InsertReg (regslist, regname, regname2);
694
 
695 19 jcastillo
              //After adding to list print it
696
              fprintf (file, "%s ", regname2);
697
              integer_found=0;
698 16 jcastillo
              free (regname);
699 12 jcastillo
              free (regname2);
700 19 jcastillo
 
701 33 jcastillo
          }else{
702
 
703
              if (newline){
704
                for (i = 0; i < openedkeys; i++)
705
                  fprintf (file, "   ");
706
              }
707
 
708 16 jcastillo
              regname2 = IsReg (regslist, (char *) $1);
709 33 jcastillo
              if (regname2 == NULL){
710
                if (IsDefine (defineslist, (char *) $1)){
711
                   if (ifdeffound == 0){
712
                      fprintf (file, "`%s", (char *) $1);
713
                      defineinvocationfound = 1;
714
                   }else{
715
                      fprintf (file, "%s", (char *) $1);
716
                      ifdeffound = 0;
717
                   }
718
                }else{
719
                   fprintf (file, "%s ", (char *) $1);
720
                }
721
             }else
722 12 jcastillo
                fprintf (file, "%s", regname2);
723 2 jcastillo
 
724 33 jcastillo
             newline = 0;
725
          }
726 12 jcastillo
 
727 33 jcastillo
        }else if (definefound)
728 12 jcastillo
        {
729 16 jcastillo
 
730
          if (IsDefine (defineslist, (char *) $1))
731 12 jcastillo
            {
732
 
733
              fprintf (FILE_DEFINES, "`%s", (char *) $1);
734
            }
735
          else
736
            {
737
              fprintf (FILE_DEFINES, "%s ", (char *) $1);
738
            }
739
        }
740
    }
741
  else if (verilog == 1)
742 19 jcastillo
    fprintf (file, "%s ", (char *) $1);
743 23 jcastillo
  lastswitch=0;
744 12 jcastillo
};
745
 
746 2 jcastillo
symbol:
747 12 jcastillo
SYMBOL
748
{
749
  defineparenthesis = 0;
750
  if (translate == 1 && verilog == 0)
751
    {
752
      if (processfound)
753
        {
754 35 jcastillo
          if (reg_found || sigreg_found)
755 12 jcastillo
            fprintf (regs_file, "%s", (char *) $1);
756
          else
757
            fprintf (file, "%s", (char *) $1);
758
        }
759
      else if (definefound)
760
        {
761
          fprintf (FILE_DEFINES, "%s", (char *) $1);
762
        }
763
    }
764
  else if (verilog == 1)
765
    fprintf (file, "%s", (char *) $1);
766
};
767 2 jcastillo
 
768 19 jcastillo
equal:
769
EQUALS
770
{
771
  defineparenthesis = 0;
772
  reg_found=0;
773 35 jcastillo
  sigreg_found=0;
774 19 jcastillo
  if (translate == 1 && verilog == 0)
775
  {
776 28 jcastillo
   if (processfound)
777 19 jcastillo
        fprintf (file, "=");
778 28 jcastillo
        writingvar=1;
779 19 jcastillo
  }
780
  else if (definefound)
781
    fprintf (FILE_DEFINES, "=");
782
  else if (verilog == 1)
783
    fprintf (file, "=");
784
 
785
}
786 12 jcastillo
 
787 2 jcastillo
write:
788 12 jcastillo
WRITE
789
{
790
  defineparenthesis = 0;
791
  if (translate == 1 && verilog == 0)
792
    {
793
      writemethod = 1;
794
      if (processfound)
795
        {
796
          fprintf (file, " <= ");
797
          fprintf (FILE_WRITES, "%s\n", lastword);
798
        }
799
      else if (definefound)
800
        {
801
          fprintf (FILE_DEFINES, " <= ");
802
        }
803 2 jcastillo
 
804 12 jcastillo
    }
805
  else if (verilog == 1)
806
    {
807
      fprintf (file, ".write");
808
    }
809
};
810
 
811 2 jcastillo
newline:
812 12 jcastillo
NEWLINE
813
{
814
  defineparenthesis = 0;
815 28 jcastillo
  writingvar=0;
816 12 jcastillo
  if (translate == 1 && verilog == 0)
817
    {
818 35 jcastillo
      if (processfound & !reg_found & !openedcase & !sigreg_found)
819 12 jcastillo
        {
820
          fprintf (file, "\n");
821
          newline = 1;
822
        }
823
      else if (definefound)
824
        {
825
          fprintf (FILE_DEFINES, "\n");
826
        }
827 2 jcastillo
 
828 12 jcastillo
    }
829
  else if (verilog == 1)
830
    fprintf (file, "\n");
831
};
832
 
833 2 jcastillo
colon:
834 12 jcastillo
COLON
835
{
836
  defineparenthesis = 0;
837
  if (translate == 1 && verilog == 0)
838
    {
839
      if (processfound)
840
        {
841 35 jcastillo
          if (reg_found || sigreg_found)
842 12 jcastillo
            {
843
              fprintf (regs_file, ",");
844
            }
845
          else
846
            fprintf (file, ",");
847
        }
848
      else if (definefound)
849
        {
850
          fprintf (FILE_DEFINES, ",");
851
        }
852
    }
853
  else if (verilog == 1)
854
    fprintf (file, ",");
855
};
856 2 jcastillo
 
857
semicolon:
858 12 jcastillo
SEMICOLON
859
{
860
  defineparenthesis = 0;
861
  if (translate == 1 && verilog == 0)
862
    {
863 33 jcastillo
      if (processfound && !struct_found && !ignore_semicolon)
864 12 jcastillo
        {
865 35 jcastillo
          if (reg_found || sigreg_found)
866 12 jcastillo
            {
867
              fprintf (regs_file, ";\n");
868
              reg_found = 0;
869 35 jcastillo
         sigreg_found = 0;
870 12 jcastillo
            }
871
          else
872
            {
873 28 jcastillo
            if (defineinvocationfound == 0 || writingvar)
874
                  fprintf (file, ";");
875 12 jcastillo
            }
876
        }
877
      else if (definefound)
878
        {
879
          fprintf (FILE_DEFINES, ";");
880
        }
881
    }
882
  else if (verilog == 1)
883
    fprintf (file, ";");
884 28 jcastillo
 
885
  writingvar=0;
886 12 jcastillo
  defineinvocationfound = 0;
887 33 jcastillo
  ignore_semicolon=0;
888 12 jcastillo
};
889
 
890
 
891 2 jcastillo
openpar:
892 12 jcastillo
OPENPAR
893
{
894
  defineparenthesis = 1;
895
  if (translate == 1 && verilog == 0 && defineinvocationfound == 0)
896
    {
897
      if (processfound)
898
        {
899
          fprintf (file, "(");
900
        }
901
      else if (definefound)
902
        {
903
          fprintf (FILE_DEFINES, "(");
904
        }
905
 
906
    }
907
  else if (verilog == 1)
908
    {
909
      fprintf (file, "(");
910
    }
911 24 jcastillo
  //If par after a sc_reg declaration the declaration is a type cast
912
  reg_found=0;
913 35 jcastillo
  sigreg_found=0;
914 12 jcastillo
}
915
 
916 2 jcastillo
closepar:
917 12 jcastillo
CLOSEPAR
918
{
919
  if (translate == 1 && verilog == 0)
920
    {
921 2 jcastillo
 
922 12 jcastillo
      if (processfound)
923
        {
924
          if (defineparenthesis == 0)
925
            {
926
              fprintf (file, ")");
927
              defineinvocationfound = 0;
928
            }
929
        }
930
      else if (definefound)
931
        {
932
          fprintf (FILE_DEFINES, ")");
933
        }
934
    }
935
  else if (verilog == 1)
936
    fprintf (file, ")");
937
 
938
};
939
 
940
 
941 2 jcastillo
opencorch:
942 12 jcastillo
OPENCORCH
943
{
944
  defineparenthesis = 0;
945
  if (translate == 1 && verilog == 0)
946
    {
947
      if (processfound)
948
        {
949 28 jcastillo
          opencorchfound = 1;
950 35 jcastillo
          if (reg_found || sigreg_found)
951 12 jcastillo
            {
952
              fprintf (regs_file, "[");
953
            }
954
          else
955
            fprintf (file, "[");
956
        }
957
      else if (definefound)
958
        {
959
          fprintf (FILE_DEFINES, "[");
960
 
961
        }
962
    }
963
  else if (verilog == 1)
964
    fprintf (file, "[");
965
};
966
 
967 2 jcastillo
closecorch:
968 12 jcastillo
CLOSECORCH
969
{
970
  defineparenthesis = 0;
971
  if (translate == 1 && verilog == 0)
972
    {
973
      if (processfound)
974 28 jcastillo
          {
975
          opencorchfound = 0;
976 35 jcastillo
          if (reg_found || sigreg_found)
977 12 jcastillo
            {
978
              fprintf (regs_file, "]");
979
            }
980
          else
981
            fprintf (file, "]");
982
        }
983
      else if (definefound)
984
        {
985
          fprintf (FILE_DEFINES, "]");
986
        }
987
    }
988
  else if (verilog == 1)
989
    fprintf (file, "]");
990
};
991
 
992
 
993 2 jcastillo
openkey:
994 12 jcastillo
OPENKEY
995
{
996
  defineparenthesis = 0;
997
  if (translate == 1 && verilog == 0)
998
    {
999
      openedkeys++;
1000
      if (!definefound)
1001
        {
1002
          if (openedkeys == 1)
1003
            {
1004 14 jcastillo
              printf ("Found process %s\n", processname);
1005 12 jcastillo
              file = fopen (processname2, (char *) "w");
1006
              regs_file = fopen (fileregs, (char *) "w");
1007
              processfound = 1;
1008 16 jcastillo
            }
1009 12 jcastillo
          if (processfound)
1010
            if (openedkeys != switchparenthesis[switchfound])
1011
              {
1012
                fprintf (file, "\n");
1013
                for (i = 0; i < openedkeys; i++)
1014
                  fprintf (file, "   ");
1015
                fprintf (file, "begin\n");
1016
                newline = 1;
1017
              }
1018
        }
1019
    }
1020
  else if (verilog == 1)
1021
    fprintf (file, "{");
1022
};
1023 2 jcastillo
 
1024
closekey:
1025 12 jcastillo
CLOSEKEY
1026
{
1027
  defineparenthesis = 0;
1028 33 jcastillo
  if(struct_found){
1029
    end_struct=1;
1030
  }else if (translate == 1 && verilog == 0){
1031
      if (processfound && !definefound){
1032
          if (openedkeys == switchparenthesis[switchfound] && switchfound > 0){
1033 12 jcastillo
              fprintf (file, "\n");
1034 33 jcastillo
              if (default_found & !default_break_found){
1035 12 jcastillo
                  for (i = 0; i < openedkeys - 1; i++)
1036
                    fprintf (file, "   ");
1037
                  fprintf (file, "end\n");
1038
                  default_found = 0;
1039 33 jcastillo
              }
1040 12 jcastillo
              for (i = 0; i < openedkeys - 1; i++)
1041 33 jcastillo
                fprintf (file, "   ");
1042 2 jcastillo
 
1043 33 jcastillo
              fprintf (file, "endcase\n");
1044
              newline = 1;
1045
              switchparenthesis[switchfound] = 0;
1046
              switchfound--;
1047
          }else{
1048 12 jcastillo
              fprintf (file, "\n");
1049
              for (i = 0; i < openedkeys; i++)
1050 16 jcastillo
                fprintf (file, "   ");
1051 12 jcastillo
              fprintf (file, "end\n");
1052
              newline = 1;
1053 33 jcastillo
          }
1054
      }
1055 2 jcastillo
 
1056 12 jcastillo
      openedkeys--;
1057
      if (definefound)
1058
        {
1059
          definefound = 0;
1060
          if (processfound)
1061
            fprintf (file, "\n//Dummy Comment\n");
1062
          else
1063
            fprintf (FILE_DEFINES, "\n//Dummy Comment\n");
1064
        }
1065
      else if (openedkeys == 0)
1066
        {
1067
          fclose (file);
1068
          fclose (regs_file);
1069
          processfound = 0;
1070 33 jcastillo
          /*Clear process struct list*/
1071
          structslist=NULL;
1072 12 jcastillo
        }
1073
    }
1074
  else if (verilog == 1)
1075
    fprintf (file, "}");
1076
};
1077
 
1078
 
1079 4 jcastillo
bigger:
1080 12 jcastillo
BIGGER
1081
{
1082
  defineparenthesis = 0;
1083
  if (translate == 1 && verilog == 0)
1084
    {
1085
      if (processfound)
1086
        {
1087
          fprintf (file, ">");
1088
        }
1089
      else if (definefound)
1090
        {
1091
          fprintf (FILE_DEFINES, ">");
1092
        }
1093
    }
1094
  else if (verilog == 1)
1095
    fprintf (file, ">");
1096
};
1097 2 jcastillo
 
1098 4 jcastillo
lower:
1099 12 jcastillo
LOWER
1100
{
1101
  defineparenthesis = 0;
1102
  if (translate == 1 && verilog == 0)
1103
    {
1104
      if (processfound)
1105
        {
1106
          fprintf (file, "<");
1107
        }
1108
      else if (definefound)
1109
        {
1110
          fprintf (FILE_DEFINES, "<");
1111
        }
1112
    }
1113
  else if (verilog == 1)
1114
    fprintf (file, "<");
1115
};
1116 2 jcastillo
 
1117 12 jcastillo
 
1118 2 jcastillo
switch:
1119 12 jcastillo
SWITCH
1120
  {
1121
    defineparenthesis = 0;
1122 23 jcastillo
    lastswitch=1;
1123 12 jcastillo
    if (translate == 1 && verilog == 0)
1124
      {
1125 23 jcastillo
        if (processfound && !openedcase)
1126 12 jcastillo
          {
1127
            fprintf (file, "\n");
1128
            for (i = 0; i < openedkeys; i++)
1129
              fprintf (file, "   ");
1130
            fprintf (file, "case");
1131
            switchfound++;
1132
            switchparenthesis[switchfound] = openedkeys + 1;
1133 23 jcastillo
          }else if (processfound)
1134
          {
1135
            fprintf (file, ":\n");
1136
            for (i = 0; i < openedkeys; i++)
1137
              fprintf (file, "   ");
1138
            fprintf(file,"begin\n");
1139
            for (i = 0; i < openedkeys; i++)
1140
              fprintf (file, "   ");
1141
            fprintf (file, "case");
1142
            switchfound++;
1143
            switchparenthesis[switchfound] = openedkeys + 1;
1144 12 jcastillo
          }
1145
      }
1146
    else if (verilog == 1)
1147
      fprintf (file, "switch");
1148
  };
1149
 
1150 2 jcastillo
case_number:
1151 12 jcastillo
CASE NUMBER SYMBOL
1152
{
1153
  defineparenthesis = 0;
1154
  if (translate == 1 && verilog == 0)
1155
    {
1156
      if (processfound)
1157
        {
1158 23 jcastillo
         if (!openedcase)
1159 12 jcastillo
          for (i = 0; i < openedkeys; i++)
1160
            fprintf (file, "   ");
1161
          if (openedcase)
1162
            fprintf (file, ", %d", $2);
1163
          else
1164
            fprintf (file, "%d", $2);
1165 4 jcastillo
 
1166 12 jcastillo
          newline = 1;
1167
          openedcase = 1;
1168
 
1169
        }
1170
    }
1171
  else if (verilog == 1)
1172
    fprintf (file, "case %d %s", $2, (char *) $3);
1173
};
1174
 
1175 19 jcastillo
case_hexnumber:
1176
CASE HEXA NUMBER SYMBOL
1177
{
1178 24 jcastillo
  //Is a dec number
1179 19 jcastillo
  defineparenthesis = 0;
1180
  if (translate == 1 && verilog == 0)
1181
    {
1182
      if (processfound)
1183
        {
1184 23 jcastillo
         if (!openedcase)
1185 19 jcastillo
          for (i = 0; i < openedkeys; i++)
1186
            fprintf (file, "   ");
1187
          if (openedcase)
1188
            fprintf (file, ", 'h%d", $3);
1189
          else
1190
            fprintf (file, "'h%d", $3);
1191
 
1192
          newline = 1;
1193
          openedcase = 1;
1194
 
1195
        }
1196
    }
1197
  else if (verilog == 1)
1198
    fprintf (file, "case %d %s", $3, (char *) $4);
1199
};
1200
 
1201 24 jcastillo
case_hexword:
1202
CASE HEXA WORD SYMBOL
1203
{
1204
  //Begin with a-F
1205
  defineparenthesis = 0;
1206
  if (translate == 1 && verilog == 0)
1207
    {
1208
      if (processfound)
1209
        {
1210
         if (!openedcase)
1211
          for (i = 0; i < openedkeys; i++)
1212
            fprintf (file, "   ");
1213
          if (openedcase)
1214
            fprintf (file, ", 'h%s", (char *)$3);
1215
          else
1216
            fprintf (file, "'h%s", (char *)$3);
1217
 
1218
          newline = 1;
1219
          openedcase = 1;
1220
 
1221
        }
1222
    }
1223
  else if (verilog == 1)
1224
    fprintf (file, "case 0x%s %s", (char *)$3, (char *) $4);
1225
};
1226
 
1227
case_hexnumberword:
1228
CASE HEXA NUMBER WORD SYMBOL
1229
{
1230
  //Hex number beginning with dec number
1231
  defineparenthesis = 0;
1232
  if (translate == 1 && verilog == 0)
1233
    {
1234
      if (processfound)
1235
        {
1236
         if (!openedcase)
1237
          for (i = 0; i < openedkeys; i++)
1238
            fprintf (file, "   ");
1239
          if (openedcase)
1240
            fprintf (file, ", 'h%d%s", $3,(char *)$4);
1241
          else
1242
            fprintf (file, "'h%d%s", $3,(char *)$4);
1243
 
1244
          newline = 1;
1245
          openedcase = 1;
1246
 
1247
        }
1248
    }
1249
  else if (verilog == 1)
1250
    fprintf (file, "case %d%s %s", $3, (char *) $4, (char *)$5);
1251
};
1252
 
1253 4 jcastillo
case_word:
1254 12 jcastillo
CASE WORD SYMBOL
1255
{
1256
  defineparenthesis = 0;
1257
  if (translate == 1 && verilog == 0)
1258
    {
1259
      if (processfound)
1260
        {
1261 23 jcastillo
         if (!openedcase)
1262 12 jcastillo
          for (i = 0; i < openedkeys; i++)
1263
            fprintf (file, "   ");
1264 28 jcastillo
          if (openedcase){
1265
            if (IsDefine (defineslist, (char *) $2))
1266
              fprintf (file, ", `%s", (char *) $2);
1267
                else
1268
                  fprintf (file, ", %s", (char *) $2);
1269
          }else{
1270
            if (IsDefine (defineslist, (char *) $2))
1271
              fprintf (file, "`%s", (char *) $2);
1272
                else
1273
                  fprintf (file, "%s", (char *) $2);
1274
      }
1275 12 jcastillo
          newline = 1;
1276
          openedcase = 1;
1277
 
1278
        }
1279
    }
1280
  else if (verilog == 1)
1281
    fprintf (file, "case %s %s", (char *) $2, (char *) $3);
1282
};
1283
 
1284 2 jcastillo
case_default:
1285 12 jcastillo
DEFAULT SYMBOL
1286
{
1287
  defineparenthesis = 0;
1288
  if (translate == 1 && verilog == 0)
1289
    {
1290
      if (processfound)
1291
        {
1292 23 jcastillo
         if (!openedcase)
1293 12 jcastillo
          for (i = 0; i < openedkeys; i++)
1294
            fprintf (file, "   ");
1295
          fprintf (file, "default:\n");
1296
          for (i = 0; i < openedkeys; i++)
1297
            fprintf (file, "   ");
1298
          fprintf (file, "begin\n");
1299
          newline = 1;
1300
          default_found = 1;
1301
        }
1302
    }
1303
  else if (verilog == 1)
1304
    fprintf (file, "default %s", (char *) $2);
1305
};
1306 2 jcastillo
 
1307 4 jcastillo
case_only:
1308 12 jcastillo
CASE OPENPAR
1309
{
1310
  defineparenthesis = 0;
1311
  //This rule occurs when in Verilog mode a case appears
1312
  if (verilog == 1)
1313
    fprintf (file, "case(");
1314
};
1315 4 jcastillo
 
1316 2 jcastillo
break:
1317 12 jcastillo
BREAK SEMICOLON
1318
{
1319
  defineparenthesis = 0;
1320
  if (translate == 1 && verilog == 0)
1321
    {
1322
      if (processfound)
1323
        {
1324
          if (newline == 0)
1325
            fprintf (file, "\n");
1326
          for (i = 0; i < openedkeys; i++)
1327
            fprintf (file, "   ");
1328
          fprintf (file, "end\n");
1329
          if (default_found)
1330
            {
1331
              default_break_found = 1;
1332
            }
1333
        }
1334
    }
1335
  else if (verilog == 1)
1336
    fprintf (file, "break;");
1337
};
1338 2 jcastillo
 
1339
hexa:
1340 12 jcastillo
HEXA
1341
{
1342
  defineparenthesis = 0;
1343
  if (translate == 1 && verilog == 0)
1344
    {
1345
      if (processfound)
1346
        {
1347
          fprintf (file, "'h");
1348
        }
1349
      else if (definefound)
1350
        {
1351
          fprintf (FILE_DEFINES, "'h");
1352
        }
1353
    }
1354
  else if (verilog == 1)
1355
    fprintf (file, "0x");
1356
};
1357
 
1358 4 jcastillo
translateoff:
1359 12 jcastillo
TRANSLATEOFF
1360
{
1361
  defineparenthesis = 0;
1362
  translate = 0;
1363 15 jcastillo
  fprintf (stderr, "line: %d Found Translate off directive \n", lineno);
1364 12 jcastillo
};
1365 4 jcastillo
 
1366
translateon:
1367 12 jcastillo
TRANSLATEON
1368
{
1369
  defineparenthesis = 0;
1370
  translate = 1;
1371 15 jcastillo
  fprintf (stderr, "line: %d Found Translate on directive \n", lineno);
1372 12 jcastillo
};
1373
 
1374 4 jcastillo
verilogbegin:
1375 12 jcastillo
VERILOGBEGIN
1376
{
1377
  defineparenthesis = 0;
1378
  verilog = 1;
1379 15 jcastillo
  fprintf (stderr, "line: %d Found Verilog Begin directive \n", lineno);
1380 12 jcastillo
};
1381 4 jcastillo
 
1382
verilogend:
1383 12 jcastillo
VERILOGEND
1384
{
1385
  defineparenthesis = 0;
1386
  verilog = 0;
1387 15 jcastillo
  fprintf (stderr, "line: %d Found Verilog End directive \n", lineno);
1388 12 jcastillo
};
1389 4 jcastillo
 
1390
ifdef:
1391 12 jcastillo
PIFDEF
1392
{
1393
  defineparenthesis = 0;
1394
  if (translate == 1 && verilog == 0)
1395
    {
1396
      if (processfound)
1397
        {
1398
          ifdeffound = 1;
1399
          fprintf (file, "`ifdef");
1400
        }
1401
      else if (definefound)
1402
        {
1403
          fprintf (FILE_DEFINES, "`ifdef");
1404
        }
1405
    }
1406
  else if (verilog == 1)
1407
    fprintf (file, "#ifdef");
1408
};
1409
 
1410 27 jcastillo
ifndef:
1411
PIFNDEF
1412
{
1413
  defineparenthesis = 0;
1414
  if (translate == 1 && verilog == 0)
1415
    {
1416
      if (processfound)
1417
        {
1418
          ifdeffound = 1;
1419
          fprintf (file, "`ifndef");
1420
        }
1421
      else if (definefound)
1422
        {
1423
          fprintf (FILE_DEFINES, "`ifndef");
1424
        }
1425
    }
1426
  else if (verilog == 1)
1427
    fprintf (file, "#ifndef");
1428
};
1429
 
1430 4 jcastillo
endif:
1431 12 jcastillo
PENDDEF
1432
{
1433
  defineparenthesis = 0;
1434
  if (translate == 1 && verilog == 0)
1435
    {
1436
      if (processfound)
1437
        {
1438
          fprintf (file, "`endif");
1439
        }
1440
      else if (definefound)
1441
        {
1442
          fprintf (FILE_DEFINES, "`endif");
1443
        }
1444
    }
1445
  else if (verilog == 1)
1446
    fprintf (file, "#endif");
1447
};
1448
 
1449 6 jcastillo
pelse:
1450 12 jcastillo
PELSE
1451
{
1452
  defineparenthesis = 0;
1453
  if (translate == 1 && verilog == 0)
1454
    {
1455
      if (processfound)
1456
        {
1457
          fprintf (file, "`else");
1458
        }
1459
      else if (definefound)
1460
        {
1461
          fprintf (FILE_DEFINES, "`else");
1462
        }
1463
    }
1464
  else if (verilog == 1)
1465
    fprintf (file, "#else");
1466
};
1467
 
1468 6 jcastillo
ttrue:
1469 12 jcastillo
TTRUE
1470
{
1471
  defineparenthesis = 0;
1472
  if (translate == 1 && verilog == 0)
1473
    {
1474
      if (processfound)
1475
        {
1476
          fprintf (file, "1");
1477
        }
1478
    }
1479
  else if (verilog == 1)
1480
    fprintf (file, "1");
1481
};
1482 6 jcastillo
 
1483
 
1484
tfalse:
1485 12 jcastillo
TFALSE
1486
{
1487
  defineparenthesis = 0;
1488
  if (translate == 1 && verilog == 0)
1489
    {
1490
      if (processfound)
1491
        {
1492
          fprintf (file, "0");
1493
        }
1494
    }
1495
  else if (verilog == 1)
1496
    fprintf (file, "0");
1497
};
1498 28 jcastillo
 
1499
comment:
1500
COMMENT
1501
{
1502
if(processfound){
1503
  //To manage comments inside switch statements
1504
  if(lastswitch){
1505
        openedcase=0;
1506
  }else if (openedcase){
1507
        fprintf (file, " :\n");
1508
      for (i = 0; i < openedkeys; i++)
1509
                fprintf (file, "   ");
1510
        fprintf(file,"begin\n");
1511
        openedcase=0;
1512
  }
1513
  //indent
1514
  if(newline){
1515
    for (i = 0; i < openedkeys; i++)
1516
          fprintf (file, "   ");
1517
        newline=0;
1518
  }
1519
  fprintf (file, " %s", (char *)$1);
1520
 }
1521 33 jcastillo
}
1522
 
1523
struct_dec:
1524
STRUCT OPENKEY
1525
{
1526
  struct_found=1;
1527
}
1528
 

powered by: WebSVN 2.1.0

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