Add support for synthesis translate meta-comments.
This commit is contained in:
parent
b991a991a7
commit
14f597acdd
|
|
@ -134,9 +134,12 @@ TU [munpf]
|
|||
\n { yylloc.first_line += 1; }
|
||||
|
||||
/* C++ style comments start with / / and run to the end of the
|
||||
current line. These are very easy to handle. */
|
||||
current line. These are very easy to handle. The meta-comments
|
||||
format is a little more tricky to handle, but do what we can. */
|
||||
|
||||
"//".* { comment_enter = YY_START; BEGIN(LCOMMENT); }
|
||||
"//"{W}*"synthesis"{W}*"translate_on"{W}*\n { return K_MC_TRANSLATE_ON; }
|
||||
"//"{W}*"synthesis"{W}*"translate_off"{W}*\n { return K_MC_TRANSLATE_OFF; }
|
||||
"//" { comment_enter = YY_START; BEGIN(LCOMMENT); }
|
||||
<LCOMMENT>. { yymore(); }
|
||||
<LCOMMENT>\n { yylloc.first_line += 1; BEGIN(comment_enter); }
|
||||
|
||||
|
|
|
|||
9
parse.y
9
parse.y
|
|
@ -532,6 +532,8 @@ static void current_function_set_statement(const YYLTYPE&loc, vector<Statement*>
|
|||
%token K_resolveto K_sin K_sinh K_slew K_split K_sqrt K_tan K_tanh
|
||||
%token K_timer K_transition K_units K_white_noise K_wreal
|
||||
%token K_zi_nd K_zi_np K_zi_zd K_zi_zp
|
||||
/* Support some meta-comments as pragmas. */
|
||||
%token K_MC_TRANSLATE_ON K_MC_TRANSLATE_OFF
|
||||
|
||||
%type <flag> from_exclude
|
||||
%type <number> number pos_neg_number
|
||||
|
|
@ -4246,6 +4248,13 @@ module_item
|
|||
/* Modules can contain further sub-module definitions. */
|
||||
: module
|
||||
|
||||
/* The lexor detects "// synthesis translate_on/off" meta-comments,
|
||||
we handle them here by turning on/off a flag. The pform uses
|
||||
that flag to attach implicit attributes to "initial" and
|
||||
"always" statements. */
|
||||
| K_MC_TRANSLATE_OFF { pform_mc_translate_on(false); }
|
||||
| K_MC_TRANSLATE_ON { pform_mc_translate_on(true); }
|
||||
|
||||
| attribute_list_opt net_type data_type_or_implicit delay3_opt net_variable_list ';'
|
||||
|
||||
{ data_type_t*data_type = $3;
|
||||
|
|
|
|||
21
pform.cc
21
pform.cc
|
|
@ -43,6 +43,15 @@
|
|||
# include "ivl_assert.h"
|
||||
# include "ivl_alloc.h"
|
||||
|
||||
/*
|
||||
* The "// synthesis translate_on/off" meta-comments cause this flag
|
||||
* to be turned off or on. The pform_make_behavior and similar
|
||||
* functions look at this flag and may choose to add implicit ivl
|
||||
* synthesis flags.
|
||||
*/
|
||||
static bool pform_mc_translate_flag = true;
|
||||
void pform_mc_translate_on(bool flag) { pform_mc_translate_flag = flag; }
|
||||
|
||||
/*
|
||||
* The pform_modules is a map of the modules that have been defined in
|
||||
* the top level. This should not contain nested modules/programs.
|
||||
|
|
@ -3197,6 +3206,18 @@ PProcess* pform_make_behavior(ivl_process_type_t type, Statement*st,
|
|||
{
|
||||
PProcess*pp = new PProcess(type, st);
|
||||
|
||||
// If we are in a part of the code where the meta-comment
|
||||
// synthesis translate_off is in effect, then implicitly add
|
||||
// the ivl_synthesis_off attribute to any behavioral code that
|
||||
// we run into.
|
||||
if (pform_mc_translate_flag == false) {
|
||||
if (attr == 0) attr = new list<named_pexpr_t>;
|
||||
named_pexpr_t tmp;
|
||||
tmp.name = perm_string::literal("ivl_synthesis_off");
|
||||
tmp.parm = 0;
|
||||
attr->push_back(tmp);
|
||||
}
|
||||
|
||||
pform_bind_attributes(pp->attributes, attr);
|
||||
|
||||
pform_put_behavior_in_scope(pp);
|
||||
|
|
|
|||
1
pform.h
1
pform.h
|
|
@ -406,6 +406,7 @@ extern void pform_module_specify_path(PSpecPath*obj);
|
|||
*/
|
||||
extern PProcess* pform_make_behavior(ivl_process_type_t, Statement*,
|
||||
list<named_pexpr_t>*attr);
|
||||
extern void pform_mc_translate_on(bool flag);
|
||||
|
||||
extern std::vector<PWire*>* pform_make_udp_input_ports(list<perm_string>*);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue