/*---------------------------------------------------------------------------------------------
 * (function: ou_initialize_macro_type_lookup )
 * 	Allows a string of a macro type to lookup the associated macro node identifying number
 *-------------------------------------------------------------------------------------------*/
void ou_initialize_macro_type_lookup()
{
	int i;
	int sc_idx;

	/* initialize the has function */
	macro_numbers_sc = sc_new_string_cache();

	//printf("%d -1 == %d\n", MACRO_STRING_SIZE, MN_END_POINT);

	assert(MACRO_STRING_SIZE - 1 == MN_END_POINT);

	for (i = 0; i < MN_END_POINT; i++)
	{
		/* add the next macro string into the hash */
		sc_idx = sc_add_string(macro_numbers_sc, macro_string[i]);
	    if(macro_numbers_sc->data[sc_idx] == NULL)
		{
			/* IF - record the number associated with this string */
			macro_numbers_sc->data[sc_idx] = (void*)i;
		}
		else
		{
			/* ELSE - the string has data */
			assert(FALSE);
		}
	}
}
Exemple #2
0
/*---------------------------------------------------------------------------------------------
 * (function:  add_node_to_netlist)
 *-------------------------------------------------------------------------------------------*/
void add_node_to_netlist(netlist_t *netlist, nnode_t *node, short special_node)
{
	long sc_spot;

//	if (node->type != OUTPUT_NODE)
	{
		/* add the node to the list */
		sc_spot = sc_add_string(netlist->nodes_sc, node->name);
		if (netlist->nodes_sc->data[sc_spot] != NULL) {
			error_message(NETLIST_ERROR, file_line_number, -1, "Two nodes with the same name (%s)\n", node->name);
		}
		netlist->nodes_sc->data[sc_spot] = (void*)node;
	}
		
	if (special_node == INPUT_NODE)
	{
		/* This is for clocks, gnd, and vcc */
		/* store the input nodes for traversal */
		netlist->top_input_nodes = (nnode_t**)realloc(netlist->top_input_nodes, sizeof(nnode_t*)*(netlist->num_top_input_nodes+1));
		netlist->top_input_nodes[netlist->num_top_input_nodes] = node;
		netlist->num_top_input_nodes++;
	}
	else if (node->type == INPUT_NODE)
	{
		/* store the input nodes for traversal */
		netlist->top_input_nodes = (nnode_t**)realloc(netlist->top_input_nodes, sizeof(nnode_t*)*(netlist->num_top_input_nodes+1));
		netlist->top_input_nodes[netlist->num_top_input_nodes] = node;
		netlist->num_top_input_nodes++;
	}
	else if (node->type == OUTPUT_NODE)
	{
		netlist->top_output_nodes = (nnode_t**)realloc(netlist->top_output_nodes, sizeof(nnode_t*)*(netlist->num_top_output_nodes+1));
		netlist->top_output_nodes[netlist->num_top_output_nodes] = node;
		netlist->num_top_output_nodes++;
	}
	else if (node->type == FF_NODE)
	{
		netlist->ff_nodes = (nnode_t**)realloc(netlist->ff_nodes, sizeof(nnode_t*)*(netlist->num_ff_nodes+1));
		netlist->ff_nodes[netlist->num_ff_nodes] = node;
		netlist->num_ff_nodes++;
	}
	else 
	{
		netlist->internal_nodes = (nnode_t**)realloc(netlist->internal_nodes, sizeof(nnode_t*)*(netlist->num_internal_nodes+1));
		netlist->internal_nodes[netlist->num_internal_nodes] = node;
		netlist->num_internal_nodes++;
	}
}
/*---------------------------------------------------------------------------------------------
 * (function: ou_lookup_macro_type )
 * 	this function returns the value of a macro string 
 *-------------------------------------------------------------------------------------------*/
short ou_lookup_macro_type(char *lookup_name)
{
	int sc_idx;
	int return_id = -1;

	/* add the next macro string into the hash */
	sc_idx = sc_add_string(macro_numbers_sc, lookup_name);
    if(macro_numbers_sc->data[sc_idx] == NULL)
	{
		/* IF - record the number associated with this string */
		assert(FALSE);
	}
	else
	{
		/* ELSE - the string has data */
		return_id = (int)macro_numbers_sc->data[sc_idx];
	}

	return return_id;
}