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

Subversion Repositories sc2v

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

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

powered by: WebSVN 2.1.0

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