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

Subversion Repositories sc2v

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

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

powered by: WebSVN 2.1.0

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