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

Subversion Repositories sc2v

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

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

powered by: WebSVN 2.1.0

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