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

Subversion Repositories sc2v

[/] [sc2v/] [trunk/] [src/] [sc2v_step2.y] - Blame information for rev 24

Go to most recent revision | 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 2 jcastillo
 *  Provided by OpenSoc Design
5
 *
6
 *  www.opensocdesign.com
7
 *
8
 * -----------------------------------------------------------------------------
9
 *  This program is free software; you can redistribute it and/or modify
10
 *  it under the terms of the GNU General Public License as published by
11
 *  the Free Software Foundation; either version 2 of the License, or
12
 *  (at your option) any later version.
13
 *
14
 *  This program is distributed in the hope that it will be useful,
15
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
16
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17
 *  GNU Library General Public License for more details.
18
 *
19
 *  You should have received a copy of the GNU General Public License
20
 *  along with this program; if not, write to the Free Software
21
 *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
22
 */
23
 
24
%{
25 12 jcastillo
 
26 2 jcastillo
#include 
27
#include 
28 4 jcastillo
#include 
29 2 jcastillo
 
30 14 jcastillo
#include "sc2v_step2.h"
31 2 jcastillo
 
32
 
33 12 jcastillo
  char *enumname;
34
 
35
  int reading_enumerates = 0;
36 16 jcastillo
  int lineno = 1;
37 12 jcastillo
 
38 4 jcastillo
/*Multiple Declarations*/
39 12 jcastillo
  int multipledec;
40
  char *storedtype;
41
 
42
 
43 2 jcastillo
/* Global var to store process module name*/
44 12 jcastillo
  char *module_name;
45
  int module_name_found = 0;
46
 
47
 
48 2 jcastillo
/* Global var to store last port type*/
49 12 jcastillo
  char *lastportkind;
50
  int lastportsize;
51
  int activeport = 0;           // 1 -> reading port list
52
 
53 2 jcastillo
/* Global var to store last signal type*/
54 12 jcastillo
  int lastsignalsize;
55
  int signalactive = 0;
56
 
57
 
58 2 jcastillo
/* Global var to store last SC_METHOD found*/
59 12 jcastillo
  char *active_method;
60
  char *active_method_type;
61
  int method_found;
62
 
63
 
64 2 jcastillo
/* Global var to store last sensitivity found*/
65 12 jcastillo
  char *last_sensibility;
66
  int sensibility_active = 0;
67 2 jcastillo
 
68 16 jcastillo
/* Global var to store last function found*/
69
  char *functionname;
70
  int outputlenght = 0;
71 2 jcastillo
 
72 12 jcastillo
  int translate;
73 4 jcastillo
 
74 2 jcastillo
 
75 12 jcastillo
  void yyerror (const char *str)
76
  {
77 15 jcastillo
    fprintf (stderr, "line: %d error: %s\n", lineno, str);
78 12 jcastillo
  }
79
 
80
  int yywrap ()
81
  {
82
    return 1;
83
  }
84
 
85
 
86
  main ()
87
  {
88
 
89
    /*Initialize lists */
90 14 jcastillo
    writeslist = NULL;
91
    portlist = NULL;;
92
    signalslist = NULL;
93 16 jcastillo
    sensibilitylist = NULL;
94
    processlist = NULL;
95 14 jcastillo
    instanceslist = NULL;
96
    enumlistlist = NULL;
97 16 jcastillo
    funcinputslist = NULL;
98
    functionslist = NULL;
99 12 jcastillo
 
100
    translate = 1;
101
 
102 18 jcastillo
    fprintf (stderr, "\nSystemC to Verilog Translator v0.4\n\n");
103 16 jcastillo
    fprintf (stderr, "Parsing header file.......\n\n");
104 15 jcastillo
 
105 16 jcastillo
    FILE *yyin = stdin;
106
    FILE *yyout = stdout;
107
 
108 12 jcastillo
    yyparse ();
109
 
110
    printf ("module %s(", module_name);
111
    EnumeratePorts (portlist);
112
    printf (");\n");
113
 
114
    ShowPortList (portlist);
115
    printf ("\n");
116 22 jcastillo
    RegOutputs (portlist,instanceslist);
117 12 jcastillo
    printf ("\n");
118
 
119
    ShowEnumListList (enumlistlist);
120
 
121 16 jcastillo
    writeslist = ReadWritesFile (writeslist, (char *) "file_writes.sc2v");
122 12 jcastillo
 
123 15 jcastillo
    ShowSignalsList (signalslist, writeslist);
124
 
125 12 jcastillo
    printf ("\n");
126
 
127
    ShowInstancedModules (instanceslist);
128
    printf ("\n");
129
 
130
    ShowDefines ((char *) "file_defines.sc2v");
131
 
132 16 jcastillo
    ShowFunctionCode (functionslist);
133
 
134 12 jcastillo
    ShowProcessCode (processlist);
135
    printf ("\n");
136
 
137
    printf ("endmodule\n");
138
 
139 16 jcastillo
    fprintf (stderr, "\nDone\n");
140 12 jcastillo
  }
141
 
142 2 jcastillo
%}
143
 
144 12 jcastillo
%token NUMBER SC_MODULE WORD OPENPAR CLOSEPAR SC_IN SC_OUT SEMICOLON BOOL ENUM
145 16 jcastillo
%token MENOR MAYOR SC_REG SC_METHOD SENSITIVE_POS SENSITIVE_NEG SENSITIVE
146 12 jcastillo
%token SENSIBLE CLOSEKEY OPENKEY SEMICOLON COLON SC_SIGNAL ARROW EQUALS NEW QUOTE
147 20 jcastillo
%token SC_CTOR VOID ASTERISCO TRANSLATEON TRANSLATEOFF OPENCORCH CLOSECORCH
148 2 jcastillo
 
149 12 jcastillo
%% commands:    /* empty */
150
|commands command;
151 2 jcastillo
 
152
command:
153 12 jcastillo
module
154
  |
155
  in_bool
156
  |
157 16 jcastillo
  in_sc_reg
158 12 jcastillo
  |
159
  out_bool
160
  |
161 16 jcastillo
  out_sc_reg
162 12 jcastillo
  |
163
  sc_method
164
  |
165
  sensitive_pos
166
  |
167
  sensitive_neg
168
  |
169
  sensitive
170
  |
171
  sensible_word_colon
172
  |
173
  sensible_word_semicolon
174
  |
175
  sensible_par_colon
176
  |
177
  sensible_par_pos
178
  |
179
  sensible_par_neg
180
  |
181
  closekey
182
  |
183
  word_semicolon
184
  |
185
  word_colon
186
  |
187
  word_closekey
188
  |
189
  word_closekey_word
190
  |
191
  signal_bool
192
  |
193 16 jcastillo
  signal_reg
194 12 jcastillo
  |
195
  instantation
196
  |
197
  port_binding
198
  |
199
  sc_ctor
200
  |
201
  void
202
  |
203 24 jcastillo
  inst_decl
204
  |
205 12 jcastillo
  closekey_semicolon
206
  |
207
  enumerates
208
  |
209
  enumerates_type
210
  |
211
  declaration
212
  |
213
  declaration_sc_signal
214
  |
215
  multiple_declaration
216 16 jcastillo
  |
217
  multiple_sc_signal_declaration
218
  |
219
  translateoff
220
  |
221
  translateon
222
  |
223
  function
224
  |
225
  functioninputs
226
  |
227
  finishfunctioninputs
228 20 jcastillo
  |
229
  boolfunction
230
  |
231
  boolfunctioninputs
232
  |
233
  arraycolon
234
  |
235
  arraysemicolon
236
  |
237
  boolfinishfunctioninputs;
238 2 jcastillo
 
239
module:
240 12 jcastillo
SC_MODULE OPENPAR WORD CLOSEPAR OPENKEY
241
{
242 2 jcastillo
 
243 12 jcastillo
  if (translate == 1)
244
    {
245
 
246
      if (module_name_found)
247 2 jcastillo
        {
248 16 jcastillo
          fprintf (stderr,
249
                   "line: %d error: two or more modules found in the file\n",
250
                   lineno);
251 12 jcastillo
          exit (1);
252 2 jcastillo
        }
253 12 jcastillo
      else
254 2 jcastillo
        {
255 12 jcastillo
          module_name = (char *) malloc (256 * sizeof (char));
256
          strcpy (module_name, (char *) $3);
257
          module_name_found = 1;
258 2 jcastillo
        }
259 12 jcastillo
    }
260 2 jcastillo
 
261 12 jcastillo
};
262
 
263
 
264 16 jcastillo
in_sc_reg:
265
SC_IN MENOR SC_REG MENOR NUMBER MAYOR MAYOR
266 12 jcastillo
{
267
  if (translate == 1)
268
    {
269
      activeport = 1;
270
      lastportsize = $5;
271
      lastportkind = (char *) "input";
272
    }
273
};
274
 
275
 
276 2 jcastillo
in_bool:
277 12 jcastillo
SC_IN MENOR BOOL MAYOR
278
{
279
  if (translate == 1)
280
    {
281
      activeport = 1;
282
      lastportsize = 0;
283
      lastportkind = (char *) "input";
284
    }
285
};
286
 
287
 
288 2 jcastillo
signal_bool:
289 12 jcastillo
SC_SIGNAL MENOR BOOL MAYOR
290
{
291
  if (translate == 1)
292
    {
293
      signalactive = 1;
294
      lastsignalsize = 0;
295
    }
296
};
297
 
298
 
299 16 jcastillo
signal_reg:
300
SC_SIGNAL MENOR SC_REG MENOR NUMBER MAYOR MAYOR
301 12 jcastillo
{
302
  if (translate == 1)
303
    {
304
      signalactive = 1;
305
      lastsignalsize = $5;
306
    }
307
};
308
 
309 2 jcastillo
out_bool:
310 12 jcastillo
SC_OUT MENOR BOOL MAYOR
311
{
312
  if (translate == 1)
313
    {
314
      activeport = 1;
315
      lastportsize = 0;
316
      lastportkind = (char *) "output";
317
    }
318
};
319
 
320 16 jcastillo
out_sc_reg:
321
SC_OUT MENOR SC_REG MENOR NUMBER MAYOR MAYOR
322 12 jcastillo
{
323
  if (translate == 1)
324
    {
325
      activeport = 1;
326
      lastportsize = $5;
327
      lastportkind = (char *) "output";
328
    }
329
 
330
};
331
 
332
 
333 2 jcastillo
sc_method:
334 12 jcastillo
SC_METHOD OPENPAR WORD CLOSEPAR SEMICOLON
335
{
336
 
337
  if (translate == 1)
338
    {
339
      if (method_found)
340 2 jcastillo
        {
341 16 jcastillo
          processlist =
342
            InsertProcess (processlist, active_method, sensibilitylist,
343
                           active_method_type);
344 12 jcastillo
        }
345
      active_method = (char *) $3;
346
      method_found = 1;
347
      /* New sensitivity list */
348 14 jcastillo
      sensibilitylist = NULL;
349 12 jcastillo
    }
350
};
351
 
352
 
353
 
354 4 jcastillo
sensible_par_neg:
355 12 jcastillo
SENSITIVE_NEG OPENPAR WORD CLOSEPAR SEMICOLON
356
{
357
  if (translate == 1)
358
    {
359
      active_method_type = (char *) "seq";      //comb
360 16 jcastillo
      sensibilitylist =
361
        InsertSensibility (sensibilitylist, (char *) $3, "negedge");
362 12 jcastillo
    }
363
};
364
 
365
 
366
 
367
sensible_par_pos:
368
SENSITIVE_POS OPENPAR WORD CLOSEPAR SEMICOLON
369
{
370
  if (translate == 1)
371
    {
372
      active_method_type = (char *) "seq";      //comb
373 16 jcastillo
      sensibilitylist =
374
        InsertSensibility (sensibilitylist, (char *) $3, "posedge");
375 12 jcastillo
    }
376
};
377
 
378
 
379
 
380
sensitive_pos:
381
SENSITIVE_POS
382
{
383
  if (translate == 1)
384
    {
385
      last_sensibility = (char *) "posedge";
386
      active_method_type = (char *) "seq";      //seq
387
      sensibility_active = 1;
388
    }
389
};
390
 
391
sensitive_neg:
392
SENSITIVE_NEG
393
{
394
  if (translate == 1)
395
    {
396
      last_sensibility = (char *) "negedge";
397
      active_method_type = (char *) "seq";      //seq
398
      sensibility_active = 1;
399
    }
400
};
401
 
402
sensitive:
403
SENSITIVE
404
{
405
 
406
  if (translate == 1)
407
    {
408
      last_sensibility = (char *) " ";
409
      active_method_type = (char *) "comb";     //comb
410
      sensibility_active = 1;
411
    }
412
};
413
 
414
 
415
 
416
sensible_par_colon:
417
SENSITIVE OPENPAR WORD CLOSEPAR SEMICOLON
418
{
419
  if (translate == 1)
420
    {
421
      active_method_type = (char *) "comb";     //comb
422 16 jcastillo
      sensibilitylist = InsertSensibility (sensibilitylist, (char *) $3, " ");
423 12 jcastillo
    }
424
};
425
 
426
 
427
 
428
 
429
sensible_word_colon:
430
SENSIBLE WORD
431
{
432
  if (translate == 1)
433
    {
434 16 jcastillo
      sensibilitylist =
435
        InsertSensibility (sensibilitylist, (char *) $2,
436
                           (char *) last_sensibility);
437 12 jcastillo
    }
438
};
439
 
440
 
441
 
442
sensible_word_semicolon:
443
SENSIBLE WORD SEMICOLON
444
{
445
  if (translate == 1)
446
    {
447 16 jcastillo
      sensibilitylist =
448
        InsertSensibility (sensibilitylist, (char *) $2,
449
                           (char *) last_sensibility);
450 12 jcastillo
      if (sensibility_active)
451 4 jcastillo
        {
452 12 jcastillo
          sensibility_active = 0;
453 4 jcastillo
        }
454 12 jcastillo
    }
455
};
456
 
457
closekey:
458
CLOSEKEY
459
{
460
  if (translate == 1)
461
    {
462
      if (method_found)
463 4 jcastillo
        {
464 12 jcastillo
          method_found = 0;
465 16 jcastillo
          processlist =
466
            InsertProcess (processlist, active_method, sensibilitylist,
467
                           active_method_type);
468 4 jcastillo
        }
469 12 jcastillo
    }
470
};
471
 
472 20 jcastillo
arraysemicolon:
473
WORD OPENCORCH NUMBER CLOSECORCH SEMICOLON
474
{
475
if (signalactive)
476
        {
477
          signalslist = InsertSignal (signalslist, (char *) $1, lastsignalsize,$3);
478
          signalactive = 0;
479
        }
480
}
481 12 jcastillo
 
482 20 jcastillo
arraycolon:
483
WORD OPENCORCH NUMBER CLOSECORCH COLON
484
{
485
if (signalactive)
486
        {
487
          signalslist = InsertSignal (signalslist, (char *) $1, lastsignalsize,$3);
488
          signalactive = 0;
489
        }
490
}
491 12 jcastillo
 
492
word_semicolon:
493
WORD SEMICOLON
494
{
495
  if (translate == 1)
496
    {
497
      if (activeport)
498 2 jcastillo
        {
499 16 jcastillo
          portlist =
500
            InsertPort (portlist, (char *) $1, lastportkind, lastportsize);
501 12 jcastillo
          activeport = 0;
502 2 jcastillo
        }
503 12 jcastillo
      else if (signalactive)
504 2 jcastillo
        {
505 20 jcastillo
          signalslist = InsertSignal (signalslist, (char *) $1, lastsignalsize,0);
506 12 jcastillo
          signalactive = 0;
507 2 jcastillo
        }
508 12 jcastillo
      else if (multipledec)
509 2 jcastillo
        {
510 12 jcastillo
          int length, list_pos;
511
          length = 0;
512
          list_pos = 0;
513
          //Look in the enumerated list if it was declared e.j state_t state;
514
          list_pos = findEnumList (enumlistlist, storedtype);
515
 
516
          if (list_pos > -1)
517
            {
518
              //Calculate the number of bits needed to represent the enumerate
519
              length = findEnumerateLength (enumlistlist, list_pos);
520 20 jcastillo
              signalslist = InsertSignal (signalslist, (char *) $1, length, 0);
521 16 jcastillo
              writeslist = InsertWrite (writeslist, (char *) $1);
522 12 jcastillo
              free (storedtype);
523
              multipledec = 0;
524
            }
525
          else
526
            {
527 16 jcastillo
              fprintf (stderr, "\nline: %d Type %s unknow\n", lineno,
528
                       (char *) $1);
529 12 jcastillo
              return (1);
530
            }
531 2 jcastillo
        }
532 12 jcastillo
    }
533
 
534
};
535
 
536
 
537
word_colon:
538
WORD COLON
539
{
540
 
541
  if (translate == 1)
542
    {
543
      if (activeport)
544 4 jcastillo
        {
545 20 jcastillo
          portlist = InsertPort (portlist, (char *) $1, lastportkind, lastportsize);
546 4 jcastillo
        }
547 12 jcastillo
      else if (signalactive)
548 2 jcastillo
        {
549 20 jcastillo
          signalslist = InsertSignal (signalslist, (char *) $1, lastsignalsize, 0);
550 2 jcastillo
        }
551 12 jcastillo
      else if (reading_enumerates)
552 2 jcastillo
        {
553 16 jcastillo
          enumerateslist = InsertEnumerates (enumerateslist, (char *) $1);
554 2 jcastillo
        }
555 12 jcastillo
      else if (multipledec)
556
        {
557 2 jcastillo
 
558 12 jcastillo
          int length, list_pos;
559
          length = 0;
560
          list_pos = 0;
561
 
562
          //Look in the enumerated list if it was declared e.j state_t state;
563
          list_pos = findEnumList (enumlistlist, storedtype);
564
 
565
          if (list_pos > -1)
566
            {
567
              //Calculate the number of bits needed to represent the enumerate
568
              length = findEnumerateLength (enumlistlist, list_pos);
569 20 jcastillo
              signalslist = InsertSignal (signalslist, (char *) $1, length, 0);
570 16 jcastillo
              writeslist = InsertWrite (writeslist, (char *) $1);
571 12 jcastillo
              multipledec = 1;
572
            }
573
          else
574
            {
575 16 jcastillo
              fprintf (stderr, "\nline: %d Type %s unknow\n", lineno,
576
                       (char *) $1);
577 12 jcastillo
              return (1);
578
            }
579 2 jcastillo
        }
580 12 jcastillo
    }
581 2 jcastillo
 
582 12 jcastillo
};
583
 
584
 
585
 
586 4 jcastillo
word_closekey_word:
587 12 jcastillo
WORD CLOSEKEY WORD SEMICOLON
588
{
589
  if (translate == 1)
590
    {
591
 
592
      //Finish enumerate var declaration
593
      if (reading_enumerates)
594
        {
595 16 jcastillo
          enumerateslist = InsertEnumerates (enumerateslist, (char *) $1);
596
          enumlistlist = InsertEnumList (enumlistlist, enumerateslist, (char *) $4, 0); //Insert also the variable name
597 12 jcastillo
          reading_enumerates = 0;
598
        }
599
    }
600
};
601
 
602
 
603
 
604 4 jcastillo
word_closekey:
605 12 jcastillo
WORD CLOSEKEY SEMICOLON
606
{
607 4 jcastillo
 
608 12 jcastillo
  if (translate == 1)
609
    {
610 4 jcastillo
 
611 12 jcastillo
      //Finish enumerate type declaration
612
      if (reading_enumerates)
613
 
614
        {
615
 
616 16 jcastillo
          enumerateslist = InsertEnumerates (enumerateslist, (char *) $1);
617 12 jcastillo
 
618 16 jcastillo
          enumlistlist = InsertEnumList (enumlistlist, enumerateslist, enumname, 1);    //Insert also the variable name
619 12 jcastillo
          reading_enumerates = 0;
620
 
621
        }
622
 
623
    }
624
 
625
};
626
 
627
 
628 2 jcastillo
instantation:
629 12 jcastillo
WORD EQUALS NEW WORD OPENPAR QUOTE WORD QUOTE CLOSEPAR SEMICOLON
630
{
631
  if (translate == 1)
632
    {
633 16 jcastillo
      instanceslist =
634
        InsertInstance (instanceslist, (char *) $1, (char *) $4);
635 12 jcastillo
    }
636
};
637
 
638
 
639
 
640
port_binding:
641
WORD ARROW WORD OPENPAR WORD CLOSEPAR SEMICOLON
642
{
643
 
644
  if (translate == 1)
645
    {
646
 
647 16 jcastillo
      if (instanceslist == NULL)
648
        {
649
          fprintf (stderr, "line: %d error: no instances found\n", lineno);
650
        }
651
      else
652
        {
653
 
654
          InstanceNode *ill;
655
          SGLIB_LIST_MAP_ON_ELEMENTS (InstanceNode, instanceslist, ill, next,
656
                                      {
657
                                      if (strcmp
658
                                          (ill->nameinstance,
659
                                           (char *) $1) == 0)
660
                                      {
661
                                      ill->bindslist =
662
                                      InsertBind (ill->bindslist, (char *) $3,
663
                                                  (char *) $5); break;}
664
                                      }
665
          );
666
        }
667
 
668 12 jcastillo
    }
669
};
670
 
671
 
672 2 jcastillo
sc_ctor:
673 12 jcastillo
SC_CTOR OPENPAR WORD CLOSEPAR OPENKEY
674
{
675
 
676
 
677
};
678
 
679
 
680
void:VOID WORD OPENPAR CLOSEPAR SEMICOLON
681
{
682
 
683
 
684
};
685
 
686
 
687 2 jcastillo
inst_decl:
688 12 jcastillo
WORD ASTERISCO WORD SEMICOLON
689
{
690 4 jcastillo
 
691 12 jcastillo
 
692
};
693
 
694
 
695
 
696
closekey_semicolon:CLOSEKEY SEMICOLON
697
{
698
 
699
 
700
};
701
 
702
 
703
 
704 4 jcastillo
enumerates:
705 12 jcastillo
ENUM OPENKEY
706
{
707
 
708
  if (translate == 1)
709
    {
710
 
711
      //New enumerate list
712 14 jcastillo
      enumerateslist = NULL;
713 12 jcastillo
 
714
      reading_enumerates = 1;
715
 
716
    }
717
 
718
};
719
 
720
 
721
 
722 4 jcastillo
enumerates_type:
723 12 jcastillo
ENUM WORD OPENKEY
724
{
725
 
726
  if (translate == 1)
727
    {
728
 
729
      //In this case we define type e.g. enum state_t {S0,S1,S2};
730 14 jcastillo
      enumerateslist = NULL;
731 12 jcastillo
 
732 16 jcastillo
      enumname = (char *) malloc (sizeof (char) * strlen ((char *) $2));
733 12 jcastillo
 
734
      strcpy (enumname, (char *) $2);
735
 
736
      reading_enumerates = 1;
737
 
738
    }
739
 
740
};
741
 
742
 
743
 
744 4 jcastillo
declaration:
745 12 jcastillo
WORD WORD SEMICOLON
746
{
747 4 jcastillo
 
748 12 jcastillo
  if (translate == 1)
749
    {
750
      int length, list_pos;
751
      length = 0;
752
 
753
      list_pos = 0;
754
 
755
      //Look in the enumerated list if it was declared e.j state_t state;
756
      list_pos = findEnumList (enumlistlist, (char *) $1);
757
 
758
      if (list_pos > -1)
759
        {
760
          //Calculate the number of bits needed to represent the enumerate
761
          length = findEnumerateLength (enumlistlist, list_pos);
762 20 jcastillo
          signalslist = InsertSignal (signalslist, (char *) $2, length, 0);
763 16 jcastillo
          writeslist = InsertWrite (writeslist, (char *) $2);
764 12 jcastillo
        }
765
      else
766
        {
767 16 jcastillo
          fprintf (stderr, "\nline: %d Type %s unknow\n", lineno,
768
                   (char *) $1);
769 12 jcastillo
          return (1);
770
        }
771
    }
772
};
773
 
774
 
775
 
776 4 jcastillo
declaration_sc_signal:
777 12 jcastillo
SC_SIGNAL MENOR WORD MAYOR WORD SEMICOLON
778
{
779 4 jcastillo
 
780 12 jcastillo
  if (translate == 1)
781
    {
782
 
783
      int length, list_pos;
784
 
785
      length = 0;
786
 
787
      list_pos = 0;
788
 
789
      //Look in the enumerated list if it was declared e.j state_t state;
790
      list_pos = findEnumList (enumlistlist, (char *) $3);
791
 
792
      if (list_pos > -1)
793
        {
794
 
795
          //Calculate the number of bits needed to represent the enumerate
796
          length = findEnumerateLength (enumlistlist, list_pos);
797
 
798
 
799 20 jcastillo
          signalslist = InsertSignal (signalslist, (char *) $5, length, 0);
800 12 jcastillo
 
801 16 jcastillo
          writeslist = InsertWrite (writeslist, (char *) $5);
802 12 jcastillo
 
803
        }
804
      else
805
        {
806
 
807 16 jcastillo
          fprintf (stderr, "\nline: %d Type %s unknow\n", lineno,
808
                   (char *) $3);
809 12 jcastillo
 
810
          return (1);
811
 
812
        }
813
 
814
    }
815
 
816
};
817
 
818
 
819
 
820 4 jcastillo
multiple_declaration:
821 12 jcastillo
WORD WORD COLON
822
{
823 4 jcastillo
 
824 12 jcastillo
  if (translate == 1)
825
    {
826
 
827
      int length, list_pos;
828
 
829
      length = 0;
830
 
831
      list_pos = 0;
832
 
833
      //Look in the enumerated list if it was declared e.j state_t state;
834
      list_pos = findEnumList (enumlistlist, (char *) $1);
835
 
836
      if (list_pos > -1)
837
        {
838
 
839
          //Calculate the number of bits needed to represent the enumerate
840
          length = findEnumerateLength (enumlistlist, list_pos);
841
 
842 16 jcastillo
          storedtype = (char *) malloc (sizeof (char) * strlen ((char *) $1));
843 12 jcastillo
 
844
          strcpy (storedtype, (char *) $1);
845
 
846 20 jcastillo
          signalslist = InsertSignal (signalslist, (char *) $2, length,0);
847 12 jcastillo
 
848 16 jcastillo
          writeslist = InsertWrite (writeslist, (char *) $2);
849 12 jcastillo
 
850
          multipledec = 1;
851
 
852
        }
853
      else
854
        {
855
 
856 16 jcastillo
          fprintf (stderr, "\nline: %d Type %s unknow\n", lineno,
857
                   (char *) $1);
858 12 jcastillo
 
859
          return (1);
860
 
861
        }
862
 
863
    }
864
 
865
};
866
 
867 4 jcastillo
multiple_sc_signal_declaration:
868 12 jcastillo
SC_SIGNAL MENOR WORD MAYOR WORD COLON
869
{
870
  if (translate == 1)
871
    {
872
      int length, list_pos;
873
      length = 0;
874
      list_pos = 0;
875
 
876
      //Look in the enumerated list if it was declared e.j state_t state;
877
      list_pos = findEnumList (enumlistlist, (char *) $3);
878
      if (list_pos > -1)
879 16 jcastillo
        {
880 12 jcastillo
          //Calculate the number of bits needed to represent the enumerate
881
          length = findEnumerateLength (enumlistlist, list_pos);
882 16 jcastillo
          storedtype = (char *) malloc (sizeof (char) * strlen ((char *) $3));
883 12 jcastillo
          strcpy (storedtype, (char *) $3);
884 20 jcastillo
          signalslist = InsertSignal (signalslist, (char *) $5, length, 0);
885 16 jcastillo
          writeslist = InsertWrite (writeslist, (char *) $5);
886 12 jcastillo
          multipledec = 1;
887
        }
888
      else
889
        {
890 16 jcastillo
          fprintf (stderr, "\nline: %d Type %s unknow\n", lineno,
891
                   (char *) $3);
892 12 jcastillo
          return (1);
893
        }
894
    }
895
};
896
 
897
 
898
 
899 4 jcastillo
translateoff:
900 12 jcastillo
TRANSLATEOFF
901
{
902
  translate = 0;
903 16 jcastillo
  fprintf (stderr, "line: %d Found Translate off directive \n", lineno);
904 12 jcastillo
};
905
 
906
 
907
 
908 4 jcastillo
translateon:
909 12 jcastillo
TRANSLATEON
910
{
911
  translate = 1;
912 16 jcastillo
  fprintf (stderr, "line: %d Found Translate on directive \n", lineno);
913
};
914 12 jcastillo
 
915 16 jcastillo
function:
916
SC_REG MENOR NUMBER MAYOR WORD OPENPAR
917
{
918
  fprintf (stderr, "line: %d Found Function Declaration \n", lineno);
919
  /* New inputs list */
920
  functionname = (char *) $5;
921
  outputlenght = $3;
922
  funcinputslist = NULL;
923
};
924 12 jcastillo
 
925 16 jcastillo
functioninputs:
926
SC_REG MENOR NUMBER MAYOR WORD COLON
927
{
928
  funcinputslist = InsertFunctionInput (funcinputslist, (char *) $5, $3);
929 12 jcastillo
};
930 16 jcastillo
 
931
finishfunctioninputs:
932
SC_REG MENOR NUMBER MAYOR WORD CLOSEPAR SEMICOLON
933
{
934
  funcinputslist = InsertFunctionInput (funcinputslist, (char *) $5, $3);
935
  functionslist =
936
    InsertFunction (functionslist, functionname, funcinputslist,
937
                    outputlenght);
938
};
939
 
940
boolfunction:
941
BOOL WORD OPENPAR
942
{
943
  fprintf (stderr, "line: %d Found Function Declaration \n", lineno);
944
  /* New inputs list */
945
  functionname = (char *) $2;
946
  outputlenght = 1;
947
  funcinputslist = NULL;
948
};
949
 
950
boolfunctioninputs:
951
BOOL WORD COLON
952
{
953
  funcinputslist = InsertFunctionInput (funcinputslist, (char *) $2, 1);
954
};
955
 
956
boolfinishfunctioninputs:
957
BOOL WORD CLOSEPAR SEMICOLON
958
{
959
  funcinputslist = InsertFunctionInput (funcinputslist, (char *) $2, 1);
960
  functionslist =
961
    InsertFunction (functionslist, functionname, funcinputslist,
962
                    outputlenght);
963
};

powered by: WebSVN 2.1.0

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