systemc-clang 2.0.0
Parsing SystemC constructs
Loading...
Searching...
No Matches
HDLHnode.h
Go to the documentation of this file.
1#ifndef _HDLHnode_H_
2#define _HDLHnode_H_
3
4// clang-format off
5
6#include "SystemCClang.h"
7#include "hNode.h"
8
9using namespace clang;
10using namespace systemc_clang;
11
12using namespace hnode;
13
14namespace systemc_hdl {
15
16 static const string fielddelim{"##"};
17 static const string tokendelim{"_"};
18 static const string qualnamedelim(":");
19 static const string pbstring{"()"};
20 static const string arrsub{"ARRAYSUBSCRIPT"};
21 static const string noname{"NONAME"};
22 static const string sensop{"<<"};
23 static const string localstr{"_local_"};
24 static const string strsccore("sc_core__sc");
25
26 static const int reset_async = 1;
27 static const int reset_sync = 2;
28
29 static inline bool isInitPB(hNodep hp) {
30 return (hp->getopc() == hNode::hdlopsEnum::hBinop) &&
31 (hp->h_name == pbstring);
32 }
33
34 static inline bool isInitSensitem(hNodep hp) {
35 return (hp->getopc() == hNode::hdlopsEnum::hBinop) &&
36 (hp->h_name == sensop);
37 }
38
39 static inline bool isMorF(hNode::hdlopsEnum hop) {
40 return (hop == hNode::hdlopsEnum::hMethodCall) ||
41 (hop == hNode::hdlopsEnum::hBuiltinFunction);
42 }
43
44 static inline int isThreadSensitem(hNodep hp) {
45 if (isMorF(hp->getopc()))
46 if (hp->getname().find( "sc_core__sc_module__async_reset_signal_is")!=std::string::npos)
47 return reset_async;
48 else if (hp->getname().find( "sc_core__sc_module__sync_reset_signal_is")!=std::string::npos)
49 return reset_sync;
50 else return 0;
51 else return 0;
52 }
53
54 static inline bool isMethodCall(hNodep hp) {
55 return ((hp->getopc() == hNode::hdlopsEnum::hVarAssign) &&
56 (hp->child_list.size() == 2) &&
57 isMorF(hp->child_list[1]->h_op) );
58 }
59
60 static inline bool isEdge(string &s) {
61 return (s=="pos" ||
62 s=="posedge" ||
63 s=="posedge_event" ||
64 s=="neg" ||
65 s=="negedge" ||
66 s=="negedge_event");
67 }
68
69 static inline bool isSimEvent(string &s) {
70 return (s=="value_changed_event");
71 }
72
74 public:
76
77 typedef struct {
78 string name;
79 int lo, hi, step;
80 int curix;
81 } for_info_t;
82
84 void GetSensLists(std::vector<hNodep> &hsens) {
85 hsens = hnewsens;
86 }
87 private:
88 void HDLLoop(hNodep &hp, std::vector<for_info_t> &for_info);
89
90 void PushRange(hNodep &hp, std::vector<for_info_t> &for_info);
91 void PopRange(std::vector<for_info_t> &for_info);
92 void UnrollBinding(hNodep &hp_orig, std::vector<for_info_t> &for_info);
93 bool SetupSenslist(hNodep hp);
94 void UnrollSensitem(hNodep &hp_orig, std::vector<for_info_t> &for_info);
95 void SubstituteIndex(hNodep &hp, std::vector<for_info_t> &for_info);
97 void RemoveSCMethod(hNodep &hp);
98 void CleanupInitHcode(hNodep &hp);
99
100 string ExtractModuleName(hNodep hp);
101 private:
102 hNodep hnewpb; // port binding list
103 std::vector<hNodep> hnewsens; // sensitivity lists
104 };
105}
106#endif
hdlopsEnum getopc()
Definition hNode.h:173
string getname()
Definition hNode.h:169
string h_name
Definition hNode.h:106
std::vector< hNodep > child_list
Definition hNode.h:109
void UnrollSensitem(hNodep &hp_orig, std::vector< for_info_t > &for_info)
Definition HDLHnode.cpp:422
void UnrollBinding(hNodep &hp_orig, std::vector< for_info_t > &for_info)
Definition HDLHnode.cpp:218
void SubstituteIndex(hNodep &hp, std::vector< for_info_t > &for_info)
Definition HDLHnode.cpp:132
hNodep ProcessCXXConstructorHcode(hNodep xconstructor)
Definition HDLHnode.cpp:541
void PushRange(hNodep &hp, std::vector< for_info_t > &for_info)
Definition HDLHnode.cpp:98
void CleanupInitHcode(hNodep &hp)
Definition HDLHnode.cpp:46
string ExtractModuleName(hNodep hp)
Definition HDLHnode.cpp:152
void GetSensLists(std::vector< hNodep > &hsens)
Definition HDLHnode.h:84
void PopRange(std::vector< for_info_t > &for_info)
Definition HDLHnode.cpp:128
void RemoveSCMethod(hNodep &hp)
Definition HDLHnode.cpp:30
hNodep HnodeDeepCopy(hNodep hp)
Definition HDLHnode.cpp:144
void HDLLoop(hNodep &hp, std::vector< for_info_t > &for_info)
Definition HDLHnode.cpp:483
std::vector< hNodep > hnewsens
Definition HDLHnode.h:103
Clang forward declarations.
Definition FindArgument.h:6
Definition hNode.h:24