ACT Library
Loading...
Searching...
No Matches
body.h
Go to the documentation of this file.
1/*************************************************************************
2 *
3 * This file is part of the ACT library
4 *
5 * Copyright (c) 2018-2019 Rajit Manohar
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 2
10 * of the License, or (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 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., 51 Franklin Street, Fifth Floor,
20 * Boston, MA 02110-1301, USA.
21 *
22 **************************************************************************
23 */
24#ifndef __ACT_BODY_H__
25#define __ACT_BODY_H__
26
27#include <act/act_id.h>
28
29/*------------------------------------------------------------------------
30 *
31 *
32 * Act body types
33 *
34 *
35 *------------------------------------------------------------------------
36 */
37
52class ActBody {
53 public:
54 ActBody (int line);
56
57 virtual ~ActBody();
58
63 void Append (ActBody *b);
64
72
78
81 ActBody *Next () { return next; }
82
86 virtual ActBody *Clone() { return NULL; }
87
92 virtual void Expand (ActNamespace *, Scope *) { fatal_error ("Need to define Expand() method!"); }
93
98
102 virtual void Print (FILE */*fp*/) { }
103
111 void updateInstType (list_t *namelist, InstType *it);
112
116 int getLine () { return _line; }
117
118protected:
119 int _line;
120
121private:
123};
124
125
132class ActBody_Inst : public ActBody {
133 public:
139 ActBody_Inst(int line, InstType *, const char *);
140
145
151
156 void Print (FILE *fp);
157
161 InstType *getType () { return t; }
162
166 const char *getName() { return id; }
167
174
179
180 private:
182 const char *id;
183};
184
185
193public:
204 const char *_inst, act_attr *_a, Array *_arr = NULL)
205 : ActBody (line)
206 {
207 inst = _inst; a = _a; arr = _arr;
208 }
209
214 //void Print (FILE *fp);
215
220
221private:
222 const char *inst;
225};
226
227
234class ActBody_Conn : public ActBody {
235 public:
236
243 ActBody_Conn(int line, ActId *id1, AExpr *ae) : ActBody (line) {
244 type = 0;
245 u.basic.lhs = id1;
246 u.basic.rhs = ae;
247 }
248
255 ActBody_Conn(int line, AExpr *id1, AExpr *id2) : ActBody (line) {
256 type = 1;
257 u.general.lhs = id1;
258 u.general.rhs = id2;
259 }
260
261 void Print (FILE *fp);
263
265
266 private:
267 union {
268 struct {
272 struct {
275 } u;
276 unsigned int type:1;
277};
278
285class ActBody_Loop : public ActBody {
286 public:
287
296 ActBody_Loop (int line,
297 const char *_id,
298 Expr *_lo, /* NULL if this is a 0..hi-1 loop */
299 Expr *_hi,
300 ActBody *_b) : ActBody (line) {
301 id = _id;
302 lo = _lo;
303 hi = _hi;
304 b = _b;
305 }
306
308
309 void Print (FILE *fp);
310
312
316 ActBody *getBody() { return b; }
317
318 private:
319 const char *id;
320 Expr *lo, *hi;
322};
323
324
332 public:
339 id = NULL;
340 lo = NULL;
341 hi = NULL;
342 g = _g;
343 s = _s;
344 next = NULL;
345 }
346
360 ActBody_Select_gc (const char *_id, Expr *_lo, Expr *_hi,
361 Expr *_g, ActBody *_s) {
362 id = _id;
363 lo = _lo;
364 hi = _hi;
365 g = _g;
366 s = _s;
367 next = NULL;
368 }
369
375 next = s;
376 }
377
381 int isElse() { return g == NULL ? 1 : 0; }
382
386 ActBody *getBody() { return s; }
387
392
397
398private:
399 const char *id;
403 Expr *lo, *hi;
408 friend class ActBody_Select;
409 friend class ActBody_Genloop;
410};
411
412
413
420class ActBody_Select : public ActBody {
421 public:
426 ActBody_Select (int line, ActBody_Select_gc *_gc) : ActBody (line) {
427 gc = _gc;
428 }
429
431
433
438
439private:
441};
442
443
449class ActBody_Genloop : public ActBody {
450public:
455 ActBody_Genloop (int line, ActBody_Select_gc *_gc) : ActBody (line) {
456 gc = _gc;
457 }
460
462
463private:
465};
466
467
477public:
483 ActBody_Assertion (int line, Expr *_e, const char *_msg = NULL)
484 : ActBody (line) {
485 type = 0;
486 u.t0.e = _e;
487 u.t0.msg = _msg;
488 }
489
497 ActBody_Assertion (int line, ActId *_id1, ActId *_id2, int op,
498 const char *_msg = NULL) : ActBody (line) {
499 type = 1;
500 u.t1.id1 = _id1;
501 u.t1.id2 = _id2;
502 u.t1.msg = _msg;
503 u.t1.op = op;
504 }
505
507 if (type == 0) {
508 if (u.t0.e) {
509 expr_free (u.t0.e);
510 }
511 }
512 }
515private:
516 union {
517 struct {
519 const char *msg;
520 } t0;
521 struct {
522 int op;
524 const char *msg;
525 } t1;
526 } u;
527 int type;
528};
529
530
541public:
550 const char *name_check,
551 InstType *it, InstType *chk)
552 : ActBody (line) {
553 _name_check = name_check;
554 _orig_type = it;
555 _new_type = chk;
556 }
558
561private:
563 const char *_name_check;
564};
565
566
572class ActBody_Print : public ActBody {
573public:
579 ActBody_Print (int line, list_t *_l) : ActBody (line) {
580 l = _l;
581 }
583 list_free (l);
584 }
587private:
588 list_t *l;
589};
590
591
592
600public:
605 ns = _ns;
606 }
607
610 ActNamespace *getNS () { return ns; }
611
612private:
614};
615
616
617struct act_prs;
618struct act_chp;
619struct act_refine;
620struct act_spec;
621struct act_sizing;
622struct act_initialize;
623struct act_dataflow;
624
625
631class ActBody_Lang : public ActBody {
632 public:
633
634 enum langtype {
643 };
644
645 ActBody_Lang (int line, act_prs *p) : ActBody (line) {
646 t = LANG_PRS;
647 lang = p;
648 }
649 ActBody_Lang (int line, act_chp *c, int ishse = 0) : ActBody (line) {
650 if (ishse) {
651 t = LANG_HSE;
652 }
653 else {
654 t = LANG_CHP;
655 }
656 lang = c;
657 }
658
659 ActBody_Lang (int line, act_spec *s) : ActBody (line) {
660 t = LANG_SPEC;
661 lang = s;
662 }
663
664 ActBody_Lang (int line, enum langtype _t, void *l) : ActBody (line) {
665 t = _t;
666 lang = l;
667 }
668
669 ActBody_Lang (int line, act_refine *r) : ActBody (line) {
670 t = LANG_REFINE;
671 lang = r;
672 }
673
674 ActBody_Lang (int line, act_sizing *s) : ActBody (line) {
675 t = LANG_SIZE;
676 lang = s;
677 }
678
679 ActBody_Lang (int line, act_initialize *init) : ActBody (line) {
680 t = LANG_INIT;
681 lang = init;
682 }
683
684 ActBody_Lang (int line, act_dataflow *dflow) : ActBody (line) {
685 t = LANG_DFLOW;
686 lang = dflow;
687 }
688
690 void Print (FILE *fp);
692
693 void *getlang() { return lang; }
694 enum langtype gettype() { return t; }
695
696 private:
698 void *lang;
699};
700
701
714 const char *id, Expr *lo, Expr *hi,
715
716 /* outputs */
717 ValueIdx **vx, int *ilo, int *ihi);
718
727 const char *id, ValueIdx *vx);
728
729
730#endif /* __ACT_BODY_H__ */
void act_syn_loop_setup(ActNamespace *ns, Scope *s, const char *id, Expr *lo, Expr *hi, ValueIdx **vx, int *ilo, int *ihi)
void act_syn_loop_teardown(ActNamespace *ns, Scope *s, const char *id, ValueIdx *vx)
Array expressions.
Definition: act_array.h:529
This is used to store assertions in the body. There are two types of assertions:
Definition: body.h:476
ActId * id1
Definition: body.h:523
int type
Definition: body.h:527
Expr * e
Definition: body.h:518
ActBody_Assertion(int line, Expr *_e, const char *_msg=NULL)
Definition: body.h:483
~ActBody_Assertion()
Definition: body.h:506
union ActBody_Assertion::@9 u
const char * msg
Definition: body.h:519
int op
Definition: body.h:522
struct ActBody_Assertion::@9::@10 t0
ActId * id2
Definition: body.h:523
ActBody_Assertion(int line, ActId *_id1, ActId *_id2, int op, const char *_msg=NULL)
Definition: body.h:497
ActBody * Clone()
void Expand(ActNamespace *, Scope *)
struct ActBody_Assertion::@9::@11 t1
This is used to record attributes associated with an instance name.
Definition: body.h:192
const char * inst
Definition: body.h:222
ActBody * Clone()
Array * arr
Definition: body.h:224
ActBody_Attribute(int line, const char *_inst, act_attr *_a, Array *_arr=NULL)
Definition: body.h:203
void Expand(ActNamespace *, Scope *)
act_attr * a
Definition: body.h:223
This is used to record a connection in the input design file.
Definition: body.h:234
void Expand(ActNamespace *, Scope *)
AExpr * rhs
Definition: body.h:270
unsigned int type
Definition: body.h:276
void Print(FILE *fp)
AExpr * lhs
Definition: body.h:273
ActBody * Clone()
struct ActBody_Conn::@6::@8 general
union ActBody_Conn::@6 u
struct ActBody_Conn::@6::@7 basic
ActBody_Conn(int line, ActId *id1, AExpr *ae)
Definition: body.h:243
ActBody_Conn(int line, AExpr *id1, AExpr *id2)
Definition: body.h:255
ActId * lhs
Definition: body.h:269
This is used to contain a generalized loop in the ACT body.
Definition: body.h:449
void Expand(ActNamespace *, Scope *)
ActBody_Select_gc * gc
Definition: body.h:464
ActBody * Clone()
ActBody_Genloop(int line, ActBody_Select_gc *_gc)
Definition: body.h:455
ActBody_Select_gc * getGC()
Definition: body.h:461
This class is used to hold information about an instance in the body of a namespace and/or user-defin...
Definition: body.h:132
InstType * t
the type
Definition: body.h:181
const char * getName()
Definition: body.h:166
ActBody_Inst(int line, InstType *, const char *)
const char * id
the name of the identifier to be instantiated
Definition: body.h:182
Type * BaseType()
void updateInstType(InstType *u)
InstType * getType()
Definition: body.h:161
ActBody * Clone()
void Expand(ActNamespace *, Scope *)
void Print(FILE *fp)
This is a language body.
Definition: body.h:631
void Expand(ActNamespace *, Scope *)
ActBody_Lang(int line, enum langtype _t, void *l)
Definition: body.h:664
ActBody_Lang(int line, act_spec *s)
Definition: body.h:659
ActBody_Lang(int line, act_sizing *s)
Definition: body.h:674
langtype
Definition: body.h:634
@ LANG_CHP
Definition: body.h:636
@ LANG_REFINE
Definition: body.h:639
@ LANG_HSE
Definition: body.h:637
@ LANG_PRS
Definition: body.h:635
@ LANG_INIT
Definition: body.h:641
@ LANG_SPEC
Definition: body.h:638
@ LANG_DFLOW
Definition: body.h:642
@ LANG_SIZE
Definition: body.h:640
ActBody_Lang(int line, act_initialize *init)
Definition: body.h:679
ActBody_Lang(int line, act_prs *p)
Definition: body.h:645
void * getlang()
Definition: body.h:693
ActBody_Lang(int line, act_refine *r)
Definition: body.h:669
ActBody_Lang(int line, act_dataflow *dflow)
Definition: body.h:684
ActBody_Lang(int line, act_chp *c, int ishse=0)
Definition: body.h:649
void Print(FILE *fp)
void * lang
Definition: body.h:698
enum langtype gettype()
Definition: body.h:694
ActBody * Clone()
enum langtype t
Definition: body.h:697
This holds information about loops that has to be unrolled. Loops can be of different types.
Definition: body.h:285
const char * id
Definition: body.h:319
ActBody_Loop(int line, const char *_id, Expr *_lo, Expr *_hi, ActBody *_b)
Definition: body.h:296
Expr * lo
Definition: body.h:320
ActBody * Clone()
Expr * hi
Definition: body.h:320
ActBody * getBody()
Definition: body.h:316
void Expand(ActNamespace *, Scope *)
void Print(FILE *fp)
ActBody * b
Definition: body.h:321
This is used to switch namespaces during the expansion phase.
Definition: body.h:599
ActBody * Clone()
ActBody_Namespace(ActNamespace *_ns)
Definition: body.h:604
ActNamespace * ns
Definition: body.h:613
void Expand(ActNamespace *, Scope *)
ActNamespace * getNS()
Definition: body.h:610
This is added for override checks that can be completed only during the expansion phase....
Definition: body.h:540
~ActBody_OverrideAssertion()
Definition: body.h:557
InstType * _new_type
Definition: body.h:562
ActBody_OverrideAssertion * Clone()
void Expand(ActNamespace *, Scope *)
ActBody_OverrideAssertion(int line, const char *name_check, InstType *it, InstType *chk)
Definition: body.h:549
InstType * _orig_type
Definition: body.h:562
const char * _name_check
Definition: body.h:563
This is used to display messages during expansion.
Definition: body.h:572
void Expand(ActNamespace *, Scope *)
list_t * l
Definition: body.h:588
ActBody * Clone()
ActBody_Print(int line, list_t *_l)
Definition: body.h:579
~ActBody_Print()
Definition: body.h:582
This is used to represent the list of guards and statements for conditional circuit construction.
Definition: body.h:331
ActBody_Select_gc * next
Definition: body.h:406
const char * id
Definition: body.h:399
ActBody_Select_gc * getNext()
Definition: body.h:391
Expr * lo
Definition: body.h:403
ActBody_Select_gc * Clone()
Expr * g
Definition: body.h:404
ActBody_Select_gc(const char *_id, Expr *_lo, Expr *_hi, Expr *_g, ActBody *_s)
Definition: body.h:360
void Append(ActBody_Select_gc *s)
Definition: body.h:374
ActBody * getBody()
Definition: body.h:386
ActBody_Select_gc(Expr *_g, ActBody *_s)
Definition: body.h:338
ActBody * s
Definition: body.h:405
int isElse()
Definition: body.h:381
Expr * hi
Definition: body.h:403
This is used to contain the complete selection statement in the core ACT language.
Definition: body.h:420
ActBody_Select_gc * gc
the guarded command list
Definition: body.h:440
void Expand(ActNamespace *, Scope *)
ActBody_Select_gc * getGC()
Definition: body.h:437
ActBody * Clone()
ActBody_Select(int line, ActBody_Select_gc *_gc)
Definition: body.h:426
This class is used to hold the contents of the body of any user-defined type or namespace....
Definition: body.h:52
ActBody * Next()
Definition: body.h:81
ActBody * next
next pointer for linked list of body items
Definition: body.h:122
virtual ActBody * Clone()
Definition: body.h:86
ActBody * Tail()
virtual void Expand(ActNamespace *, Scope *)
Definition: body.h:92
virtual void Print(FILE *)
Definition: body.h:102
void updateInstType(list_t *namelist, InstType *it)
int getLine()
Definition: body.h:116
void Append(ActBody *b)
virtual ~ActBody()
void insertNext(ActBody *b)
ActBody(int line)
void Expandlist(ActNamespace *, Scope *)
int _line
saved away line number information
Definition: body.h:119
This class is used to store Act identifiers that correspond to instances. Identifiers have an optiona...
Definition: act_id.h:56
The ActNamespace class holds all the information about a namespace.
Definition: namespaces.h:469
Dense arrays, sparse arrays, and array dereferences.
Definition: act_array.h:65
An instance type.
Definition: inst.h:92
This is the data structure that holds all instances and their associated types within a scope....
Definition: namespaces.h:77
The abstract base class for all types in the system.
Definition: basetype.h:45
This class is used to create an instance in a scope. The name comes from the fact that this is used t...
Definition: value.h:342
void expr_free(Expr *e)
Attribute list associated with an instance.
Definition: lang.h:44
Holds a CHP sub-language.
Definition: lang.h:367
The dataflow sub-language.
Definition: lang.h:592
The Initialize { ... } body. Only used in the global namespace.
Definition: lang.h:513
Structure that holds all the prs { } blocks in a particular scope. This is a linked-list of blocks,...
Definition: lang.h:194
The refinement sub-language just contains an ActBody.
Definition: lang.h:444
The sizing { ... } body data.
Definition: lang.h:482
The specification sub-language.
Definition: lang.h:397
Definition: expr.h:79