Skip to content

ODIN_II: Add basic task support #933

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 28, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
136 changes: 136 additions & 0 deletions ODIN_II/SRC/ast_elaborate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -682,6 +682,8 @@ ast_node_t *build_hierarchy(ast_node_t *node, ast_node_t * parent, int index, sc
fold_expressions = true;
break;
}
case TASK: //fallthrough
case STATEMENT: //fallthough
case FUNCTION: // fallthrough
case INITIAL: // fallthrough
case ALWAYS:
Expand Down Expand Up @@ -863,6 +865,59 @@ ast_node_t *build_hierarchy(ast_node_t *node, ast_node_t * parent, int index, sc
vtr::free(temp_instance_name);
}

for (i = 0; i < node->types.task.size_task_instantiations; i++)
{

/* make the stringed up module instance name - instance name is
* MODULE_INSTANCE->MODULE_NAMED_INSTANCE(child[1])->IDENTIFIER(child[0]).
* module name is MODULE_INSTANCE->IDENTIFIER(child[0])
*/
ast_node_t *temp_instance = node->types.task.task_instantiations_instance[i];
char *instance_name_prefix = local_ref->instance_name_prefix;

char *temp_instance_name = make_full_ref_name(instance_name_prefix,
temp_instance->children[0]->types.identifier,
temp_instance->children[1]->children[0]->types.identifier,
NULL, -1);

long sc_spot;
/* lookup the name of the task associated with this instantiated point */
if ((sc_spot = sc_lookup_string(module_names_to_idx, temp_instance->children[0]->types.identifier)) == -1)
{
error_message(NETLIST_ERROR, node->line_number, node->file_number,
"Can't find task name %s\n", temp_instance->children[0]->types.identifier);
}

/* make a unique copy of this task */
ast_node_t *instance = ast_node_deep_copy((ast_node_t *)module_names_to_idx->data[sc_spot]);

long sc_spot_2 = sc_add_string(module_names_to_idx, temp_instance_name);
oassert(sc_spot_2 > -1 && module_names_to_idx->data[sc_spot_2] == NULL);
module_names_to_idx->data[sc_spot_2] = (void *)instance;

ast_modules = (ast_node_t **)vtr::realloc(ast_modules, sizeof(ast_node_t*)*(sc_spot_2 + 1));
ast_modules[sc_spot_2] = instance;

/* create the string cache list for the instantiated module */
sc_hierarchy *original_sc_hierarchy = ((ast_node_t *)module_names_to_idx->data[sc_spot])->types.hierarchy;
sc_hierarchy *task_sc_hierarchy = copy_sc_hierarchy(original_sc_hierarchy);
task_sc_hierarchy->parent = local_ref;
task_sc_hierarchy->instance_name_prefix = vtr::strdup(temp_instance_name);
task_sc_hierarchy->scope_id = vtr::strdup(temp_instance->children[1]->children[0]->types.identifier);

/* update parent string cache list */
int num_task_children = local_ref->num_task_children;
local_ref->task_children = (sc_hierarchy **)vtr::realloc(local_ref->task_children, sizeof(sc_hierarchy *)*(num_task_children + 1));
local_ref->task_children[i] = task_sc_hierarchy;
local_ref->num_task_children++;

/* elaboration */
instance = build_hierarchy(instance, NULL, -1, task_sc_hierarchy, false, true, data);

/* clean up */
vtr::free(temp_instance_name);
}

break;
}
case MODULE_INSTANCE:
Expand Down Expand Up @@ -1098,6 +1153,8 @@ ast_node_t *build_hierarchy(ast_node_t *node, ast_node_t * parent, int index, sc

break;
}
case STATEMENT: //fallthrough
case TASK: //fallthrough
case FUNCTION: // fallthrough
case INITIAL: // fallthrough
case ALWAYS:
Expand Down Expand Up @@ -1192,6 +1249,44 @@ ast_node_t *finalize_ast(ast_node_t *node, ast_node_t *parent, sc_hierarchy *loc

break;
}
case TASK:
{
if(parent != NULL)
{
skip_children = true;
}
break;
}
case TASK_INSTANCE:
{
// check ports
ast_node_t *connect_list = node->children[1]->children[1];
bool is_ordered_list;
if (connect_list->children[1]->children[0]) // skip first connection
{
is_ordered_list = false; // name was specified
}
else
{
is_ordered_list = true;
}

for (int i = 1; i < connect_list->num_children; i++)
{
if ((connect_list->children[i]
&& connect_list->children[i]->children)
&& (( connect_list->children[i]->children[0] && is_ordered_list)
|| (!connect_list->children[i]->children[0] && !is_ordered_list)))
{
error_message(PARSE_ERROR, node->line_number, node->file_number,
"%s", "Cannot mix port connections by name and port connections by ordered list\n");
}
}

skip_children = true;

break;
}
case MODULE_ITEMS:
{
/* look in the string cache for in-line continuous assignments */
Expand Down Expand Up @@ -1299,6 +1394,7 @@ ast_node_t *finalize_ast(ast_node_t *node, ast_node_t *parent, sc_hierarchy *loc
node = unroll_for_loop(node, parent, &num_unrolled, local_ref, is_generate_region);
break;
}
case STATEMENT: //fallthrough
case ALWAYS: // fallthrough
case INITIAL:
{
Expand Down Expand Up @@ -1547,6 +1643,40 @@ ast_node_t *finalize_ast(ast_node_t *node, ast_node_t *parent, sc_hierarchy *loc
vtr::free(temp_instance_name);
}

for (i = 0; i < node->types.task.size_task_instantiations; i++)
{

/* make the stringed up module instance name - instance name is
* MODULE_INSTANCE->MODULE_NAMED_INSTANCE(child[1])->IDENTIFIER(child[0]).
* module name is MODULE_INSTANCE->IDENTIFIER(child[0])
*/
ast_node_t *temp_instance = node->types.task.task_instantiations_instance[i];
char *instance_name_prefix = local_ref->instance_name_prefix;

char *temp_instance_name = make_full_ref_name(instance_name_prefix,
temp_instance->children[0]->types.identifier,
temp_instance->children[1]->children[0]->types.identifier,
NULL, -1);

/* lookup the name of the task associated with this instantiated point */
long sc_spot = sc_lookup_string(module_names_to_idx, temp_instance->children[0]->types.identifier);
oassert(sc_spot > -1 && module_names_to_idx->data[sc_spot] != NULL);
ast_node_t *instance = (ast_node_t *)module_names_to_idx->data[sc_spot];

sc_hierarchy *task_sc_hierarchy = local_ref->task_children[i];

/* update the parameter table for the instantiated module */
STRING_CACHE *instance_param_table_sc = task_sc_hierarchy->local_param_table_sc;
update_instance_parameter_table(temp_instance, instance_param_table_sc);

/* elaboration */
update_string_caches(task_sc_hierarchy);
instance = finalize_ast(instance, NULL, task_sc_hierarchy, false, true);

/* clean up */
vtr::free(temp_instance_name);
}

break;
}
case MODULE_INSTANCE:
Expand Down Expand Up @@ -1777,6 +1907,7 @@ ast_node_t *finalize_ast(ast_node_t *node, ast_node_t *parent, sc_hierarchy *loc
if (node->num_children == 3) convert_2D_to_1D_array_ref(&node, local_ref);
break;
}
case STATEMENT: //fallthrough
case ALWAYS: // fallthrough
case INITIAL:
{
Expand Down Expand Up @@ -1834,6 +1965,11 @@ ast_node_t *reduce_expressions(ast_node_t *node, sc_hierarchy *local_ref, long *
skip_children = true;
break;
}
case TASK:
{
skip_children = true;
break;
}
case MODULE_INSTANCE:
{
skip_children = true;
Expand Down
3 changes: 2 additions & 1 deletion ODIN_II/SRC/ast_util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -659,7 +659,7 @@ char **get_name_of_pins_number(ast_node_t *var_node, int /*start*/, int width)

return_string = (char**)vtr::malloc(sizeof(char*)*width);
int i;
for (i = 0; i < width; i++)//
for (i = 0; i < width; i++)
{
return_string[i] = get_name_of_pin_number(var_node, i);
}
Expand All @@ -680,6 +680,7 @@ char *get_name_of_pin_number(ast_node_t *var_node, int bit)
case BitSpace::_1: return_string = vtr::strdup(ONE_VCC_CNS); break;
case BitSpace::_0: return_string = vtr::strdup(ZERO_GND_ZERO); break;
case BitSpace::_x: return_string = vtr::strdup(ZERO_GND_ZERO); break;
case BitSpace::_z: return_string = vtr::strdup(ZERO_PAD_ZERO); break;
default:
error_message(NETLIST_ERROR, var_node->line_number, var_node->file_number, "Unrecognised character %c in binary string \"%s\"!\n", c, var_node->types.vnumber->to_bit_string().c_str());
break;
Expand Down
6 changes: 6 additions & 0 deletions ODIN_II/SRC/enum_str.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,8 @@ const char *ids_STR []=
"FUNCTION",
/* OTHER FUNCTION ITEMS */
"FUNCTION_ITEMS",
"TASK",
"TASK_ITEMS",
/* primitives */
"GATE",
"GATE_INSTANCE",
Expand All @@ -140,12 +142,16 @@ const char *ids_STR []=
/* Function instances*/
"FUNCTION_NAMED_INSTANCE",
"FUNCTION_INSTANCE",

"TASK_NAMED_INSTANCE",
"TASK_INSTANCE",
/* Specify Items */
"SPECIFY_ITEMS",
"SPECIFY_PARAMETER",
"SPECIFY_PAL_CONNECTION_STATEMENT",
"SPECIFY_PAL_CONNECT_LIST",
/* statements */
"STATEMENT",
"BLOCK",
"NON_BLOCKING_STATEMENT",
"BLOCKING_STATEMENT",
Expand Down
23 changes: 23 additions & 0 deletions ODIN_II/SRC/hierarchy_util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,12 @@ void free_sc_hierarchy(sc_hierarchy *to_free)
}
to_free->function_children = (sc_hierarchy **)vtr::free(to_free->function_children);

for (i = 0; i < to_free->num_task_children; i++)
{
free_sc_hierarchy(to_free->task_children[i]);
}
to_free->task_children = (sc_hierarchy **)vtr::free(to_free->task_children);

for (i = 0; i < to_free->num_block_children; i++)
{
free_sc_hierarchy(to_free->block_children[i]);
Expand Down Expand Up @@ -138,6 +144,7 @@ void free_sc_hierarchy(sc_hierarchy *to_free)

to_free->num_module_children = 0;
to_free->num_function_children = 0;
to_free->num_task_children = 0;
to_free->num_unnamed_genblks = 0;

vtr::free(to_free);
Expand Down Expand Up @@ -195,6 +202,14 @@ ast_node_t *resolve_hierarchical_name_reference(sc_hierarchy *local_ref, char *i
found = true;
}
}
for (int i = 0; !found && i < this_ref->num_task_children; i++)
{
if (this_ref->task_children[i]->scope_id == scope_id)
{
this_ref = this_ref->task_children[i];
found = true;
}
}
for (int i = 0; !found && i < this_ref->num_block_children; i++)
{
if (this_ref->block_children[i]->scope_id == scope_id)
Expand Down Expand Up @@ -285,6 +300,14 @@ ast_node_t *resolve_hierarchical_name_reference_by_path_search(sc_hierarchy *loc
}
}

for (int i = 0; !var_declare && i < local_ref->num_task_children; i++)
{
if (local_ref->task_children[i]->scope_id == scope_id)
{
var_declare = resolve_hierarchical_name_reference_by_path_search(local_ref->task_children[i], identifier);
}
}

for (int i = 0; !var_declare && i < local_ref->num_block_children; i++)
{
if (local_ref->block_children[i]->scope_id == scope_id)
Expand Down
15 changes: 15 additions & 0 deletions ODIN_II/SRC/include/odin_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,8 @@ enum ids
FUNCTION,
/* OTHER FUNCTION ITEMS */
FUNCTION_ITEMS,
TASK,
TASK_ITEMS,
/* primitives */
GATE,
GATE_INSTANCE,
Expand All @@ -288,12 +290,16 @@ enum ids
/* Function instances*/
FUNCTION_NAMED_INSTANCE,
FUNCTION_INSTANCE,

TASK_NAMED_INSTANCE,
TASK_INSTANCE,
/* Specify Items */
SPECIFY_ITEMS,
SPECIFY_PARAMETER,
SPECIFY_PAL_CONNECTION_STATEMENT,
SPECIFY_PAL_CONNECT_LIST,
/* statements */
STATEMENT,
BLOCK,
NON_BLOCKING_STATEMENT,
BLOCKING_STATEMENT,
Expand Down Expand Up @@ -378,6 +384,15 @@ struct typ
STRING_CACHE *parameter_list;
} function;
struct
{
short is_instantiated;
ast_node_t **task_instantiations_instance;
int size_task_instantiations;
int index;
STRING_CACHE *parameter_list;
sc_hierarchy *string_cache_list;
}task;
struct
{
int num_bit_strings;
char **bit_strings;
Expand Down
7 changes: 6 additions & 1 deletion ODIN_II/SRC/include/parse_making_ast.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,16 @@ ast_node_t *newIf(ast_node_t *compare_expression, ast_node_t *true_expression, a
ast_node_t *newIfQuestion(ast_node_t *compare_expression, ast_node_t *true_expression, ast_node_t *false_expression, int line_number);
ast_node_t *newCase(ast_node_t *compare_expression, ast_node_t *case_list, int line_number);
ast_node_t *newAlways(ast_node_t *delay_control, ast_node_t *statements, int line_number);
ast_node_t *newStatement(ast_node_t *statement, int line_number);
ast_node_t *newFor(ast_node_t *initial, ast_node_t *compare_expression, ast_node_t *terminal, ast_node_t *statement, int line_number);
ast_node_t *newWhile(ast_node_t *compare_expression, ast_node_t *statement, int line_number);

/* MODULE INSTANCES FUNCTIONS */
ast_node_t *newModuleConnection(char* id, ast_node_t *expression, int line_number);
ast_node_t *newModuleNamedInstance(char* unique_name, ast_node_t *module_connect_list, ast_node_t *module_parameter_list, int line_number);
ast_node_t *newFunctionNamedInstance(ast_node_t *module_connect_list, ast_node_t *module_parameter_list, int line_number);
ast_node_t *newTaskInstance(char *task_name, ast_node_t *task_named_instace, ast_node_t *task_parameter_list, int line_number);
ast_node_t *newTaskNamedInstance(ast_node_t *module_connect_list, int line_number);
ast_node_t *newModuleInstance(char* module_ref_name, ast_node_t *module_named_instance, int line_number);
ast_node_t *newFunctionInstance(char* function_ref_name, ast_node_t *function_named_instance, int line_number);
ast_node_t *newHardBlockInstance(char* module_ref_name, ast_node_t *module_named_instance, int line_number);
Expand All @@ -82,9 +85,11 @@ ast_node_t *newIntegerTypeVarDeclare(char* symbol, ast_node_t *expression1, ast_

/* HIGH LEVEL ITEMS */
ast_node_t *newModule(char* module_name, ast_node_t *list_of_parameters, ast_node_t *list_of_ports, ast_node_t *list_of_module_items, int line_number);
ast_node_t *newFunction(ast_node_t *list_of_ports, ast_node_t *list_of_module_items, int line_number);
ast_node_t *newFunction(ast_node_t *function_return, ast_node_t *list_of_ports, ast_node_t *list_of_module_items, int line_number, bool automatic);
ast_node_t *newTask(char *task_name, ast_node_t *list_of_ports, ast_node_t *list_of_task_items, int line_number, bool automatic);
void next_module();
void next_function();
void next_task();
ast_node_t *newDefparam(ids id, ast_node_t *val, int line_number);

void next_parsed_verilog_file(ast_node_t *file_items_list);
Expand Down
Loading