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

Subversion Repositories sc2v

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

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

powered by: WebSVN 2.1.0

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