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

Subversion Repositories sc2v

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

Go to most recent revision | Details | Compare with Previous | View Log

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

powered by: WebSVN 2.1.0

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