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

Subversion Repositories sc2v

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

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

powered by: WebSVN 2.1.0

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