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

Subversion Repositories sc2v

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

Details | Compare with Previous | View Log

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

powered by: WebSVN 2.1.0

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