Skip to content

Commit

Permalink
Basic support for program blocks.
Browse files Browse the repository at this point in the history
  • Loading branch information
steveicarus committed May 28, 2012
1 parent 3426462 commit 0833d9e
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 10 deletions.
1 change: 1 addition & 0 deletions Module.cc
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ Module::Module(perm_string n)
{
library_flag = false;
is_cell = false;
program_block = false;
uc_drive = UCD_NONE;
timescale_warn_done = false;
time_unit = 0;
Expand Down
5 changes: 5 additions & 0 deletions Module.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,11 @@ class Module : public PScopeExtra, public LineInfo {

bool is_cell;

/* This is true if the module represents a program block
instead of a module/cell. Program blocks have content
restrictions and slightly modify scheduling semantics. */
bool program_block;

enum UCDriveType { UCD_NONE, UCD_PULL0, UCD_PULL1 };
UCDriveType uc_drive;

Expand Down
5 changes: 1 addition & 4 deletions parse.y
Original file line number Diff line number Diff line change
Expand Up @@ -3754,7 +3754,7 @@ local_timeunit_prec_decl

module
: attribute_list_opt module_start IDENTIFIER
{ pform_startmodule($3, @2.text, @2.first_line, $1); }
{ pform_startmodule(@2, $3, $2==K_program, $1); }
module_parameter_port_list_opt
module_port_list_opt
module_attribute_foreign ';'
Expand Down Expand Up @@ -3796,9 +3796,6 @@ module
break;
}
}
if ($2 == K_program) {
yyerror(@2, "sorry: Program blocks not supported yet.");
}
pform_endmodule($3, in_celldefine, ucd);
delete[]$3;
have_timeunit_decl = false; // We will allow decls again.
Expand Down
9 changes: 5 additions & 4 deletions pform.cc
Original file line number Diff line number Diff line change
Expand Up @@ -796,13 +796,14 @@ verinum* pform_verinum_with_size(verinum*siz, verinum*val,
return res;
}

void pform_startmodule(const char*name, const char*file, unsigned lineno,
list<named_pexpr_t>*attr)
void pform_startmodule(const struct vlltype&loc, const char*name,
bool program_block, list<named_pexpr_t>*attr)
{
assert( pform_cur_module == 0 );

perm_string lex_name = lex_strings.make(name);
pform_cur_module = new Module(lex_name);
pform_cur_module->program_block = program_block;
/* Set the local time unit/precision to the global value. */
pform_cur_module->time_unit = pform_time_unit;
pform_cur_module->time_precision = pform_time_prec;
Expand All @@ -813,7 +814,7 @@ void pform_startmodule(const char*name, const char*file, unsigned lineno,
* a timescale directive. */
pform_cur_module->time_from_timescale = pform_timescale_file != 0;

FILE_NAME(pform_cur_module, file, lineno);
FILE_NAME(pform_cur_module, loc);
pform_cur_module->library_flag = pform_library_flag;

ivl_assert(*pform_cur_module, lexical_scope == 0);
Expand All @@ -824,7 +825,7 @@ void pform_startmodule(const char*name, const char*file, unsigned lineno,
scope_generate_counter = 1;

if (warn_timescale && pform_timescale_file
&& (strcmp(pform_timescale_file,file) != 0)) {
&& (strcmp(pform_timescale_file,loc.text) != 0)) {

cerr << pform_cur_module->get_fileline() << ": warning: "
<< "timescale for " << name
Expand Down
8 changes: 6 additions & 2 deletions pform.h
Original file line number Diff line number Diff line change
Expand Up @@ -145,9 +145,13 @@ extern PWire* pform_get_make_wire_in_scope(perm_string name, NetNet::Type net_ty
* module has been noticed in the source file and the following events
* are to apply to the scope of that module. The endmodule causes the
* pform to close up and finish the named module.
*
* The program_flag indicates that the module is actually a program
* block. This has implications during parse and during
* elaboration/code generation.
*/
extern void pform_startmodule(const char*, const char*file, unsigned lineno,
list<named_pexpr_t>*attr);
extern void pform_startmodule(const struct vlltype&loc, const char*name,
bool program_block, list<named_pexpr_t>*attr);
extern void pform_check_timeunit_prec();
extern void pform_module_set_ports(vector<Module::port_t*>*);

Expand Down

0 comments on commit 0833d9e

Please sign in to comment.