The share package

Routines for common subexpression sharing of CFSM.



Routines for common subexpression sharing of CFSM. It manipulates on two-level network, which includes one CFSM node and its combinatorial subcircuits for data computation. These data flow elements and their connectivity are translated into a directed data flow graph. Vertices correspond to subcircuits, variables and have information about the represented object:
  name: instance (variable) name;
  type: model (variable) type;
  state set: set of values of the control state variable of a CFSM at
  which the instance (variable) is used for giving input event values
  to CFSM look-up table;
  select in set: set of _select values derived from state set;
  select out set: set of _select values at which the instance
  (variable) is used for giving the output event values to CFSM
  look-up table;
  cost: the cost of the instance (area);
  flag: a flag for internal usage;
  var: a pointer to a variable the vertex represents;
  node: a pointer to an instance the vertex represents;
  
The algorithms find possible sharings on data flow graph for HW and SW implementations.

void 
share_add_out_var(
  net_node_t * node, 
  net_var_t * out_var 
)
Adds the output variable to a node. It inserts the new variable into array of variables keeping the order INPUTs, OUTPUTs, ... It updates indices of variables.

array_t * 
share_append_ticket_sets(
  array_t * ticket1, 
  array_t * ticket2 
)
Returns the union of two ticket sets. It also deletes dupplicated items from union set.

void 
share_constant_to_graph(
  net_node_t * node, 
  graph_t ** graph 
)
Creates vertices for representing constant variables of a NET node. It sets data (name, type, pointer) associated with the vertex. It also connects the vertex to other vertices by edges according to connectivity given by NET node. If it is not connected to any other vertices which represent combinational subcircuits then it deletes the created vertex, else it adds vertex to the given graph.

See Also share_fanin_to_graph share_internal_to_graph share_fanout_to_graph
net_node_t * 
share_create_mpx_inst(
  int  num_mpx_input, 
  char * inst_name 
)
Creates and returns a multiplexer instance node which has the given number of inputs.

See Also share_create_mpx_model
net_node_t * 
share_create_mpx_model(
  int  num_mpx_input 
)
Creates and returns a multiplexer model node which has the given number of inputs.

See Also share_create_mpx_inst
graph_t * 
share_create_sharing_graph(
  array_t * nodes 
)
Returns the sharing graph of vertices. Two vertices are connected if only if the intersection of their ticket sets is zero, that means that they can be shared.

int 
share_disjoint_ticket(
  array_t * set1, 
  array_t * set2 
)
Tests if two ticket sets are disjoint. It returns TRUE if they are disjoint, else FALSE.

void 
share_fanin_to_graph(
  net_node_t * node, 
  graph_t ** graph 
)
Creates vertices for representing fanin variables of a NET node. It sets data (name, type, pointer) associated with the vertex. It also connects the vertex to other vertices by edges according to connectivity given by NET node. If it is not connected to any other vertices which represent combinational subcircuits then it deletes the created vertex, else it adds vertex to the given graph.

See Also share_constant_to_graph share_internal_to_graph share_fanout_to_graph
void 
share_fanout_to_graph(
  net_node_t * node, 
  graph_t ** graph 
)
Creates vertices for representing fanout variables of a NET node. It sets data (name, type, pointer) associated with the vertex. It also connects the vertex to other vertices by edges according to connectivity given by NET node. If it is not connected to any other vertices which represent combinational subcircuits then it deletes the created vertex, else it adds vertex to the given graph.

See Also share_fanin_to_graph share_constant_to_graph share_internal_to_graph
void 
share_free_ticket_sets(
  array_t * sets 
)
Frees array of ticket sets.

array_t * 
share_get_adjacent_vertices(
  array_t *  vertices 
)
Gets all adjencent vertices of a set of vertices.

int 
share_get_cfsm(
  net_node_t * net_node, 
  net_node_t ** cfsm_node 
)
Gets the CFSM component of a NET node. It sets cfsm_node to the model node of the only CFSM component. If there is more then one then it returns (-1) setting the first one. If there is no cfsm among components then it returns (-2), else 0.

int 
share_get_control_state(
  net_node_t * cfsm_node, 
  net_var_t ** state_var 
)
Gets the control state variable of a CFSM node. It sets state_var to the control state variable. If there is more then one then it returns (-1) setting the first one. If there is no control state variable then it returns (-2), else 0.

array_t * 
share_get_delete_graph_max_clique(
  graph_t * graph 
)
Returns and delete the maximal clique of a graph.

array_t * 
share_get_hw_nodes_for_sharing(
  graph_t * graph 
)
Gets the set of HW nodes, represented by vertices of a graph, which can be shared.

int 
share_get_select_for_out(
  net_node_t * cfsm_node, 
  net_var_t * var, 
  array_t ** select_values 
)
Gets those values of _select variable where a variable is used for computing output functions. If the given variable is not used then it returns FALSE otherwise TRUE.

int 
share_get_state_select_for_in(
  net_node_t * cfsm_node, 
  net_var_t * var, 
  net_var_t * state_var, 
  array_t ** state_values, 
  array_t ** select_values 
)
Gets those values of control state and _select variables which are in the care set of CFSM transitions with values of a variable. If the given variable is not in any care set then it returns FALSE otherwise TRUE.

void 
share_graph_alloc_vertex(
  vertex_t * v 
)
Allocates a new vertex. It gives the following default values: name=NIL(char), type=NIL(char), state set=array_alloc(int,0), select in set=array_alloc(int,0), select out set=array_alloc(int,0), cost=0, flag=0, var=NIL(net_var_t), node=NIL(net_node_t).

See Also share_graph_free_v
int 
share_graph_cost(
  vertex_t * vertex 
)
Returns the cost of a vertex. If the function is called on a NIL vertex then it returns (-1).

int 
share_graph_flag(
  vertex_t * vertex 
)
Returns the flag of a vertex. If the function is called on a NIL node then it returns (-1).

See Also share_graph_set_flag share_graph_reset_flag_all
void 
share_graph_free_v(
  vertex_t * v 
)
Frees the vertex. All information of vertex is also freed.

See Also share_graph__alloc_vertex
void 
share_graph_free(
  graph_t * graph 
)
Frees the graph.

vertex_t * 
share_graph_get_vertex_by_name(
  graph_t * graph, 
  char * name 
)
Returns the named vertex of a graph. If the function is called on a NIL parameter or the vertex does not exist then it returns NIL.

char * 
share_graph_name(
  vertex_t * vertex 
)
Returns the name of a vertex. User must not free this string. If the function is called on a NIL vertex then it returns NIL.

See Also share_graph_set_name
net_node_t * 
share_graph_node(
  vertex_t * vertex 
)
Returns node the vertex represents. If the function is called on a NIL parameter then it does not do anything.

Side Effects share_graph_set_node

See Also share_graph_set_node
void 
share_graph_print(
  graph_t * g 
)
Prints the entire graph.

void 
share_graph_reset_flag_all(
  vertex_t * vertex 
)
Resets flags of all vertices of a subgraph.

See Also share_graph_set_flag share_graph_flag
array_t * 
share_graph_select_in(
  vertex_t * vertex 
)
Returns the select in values of a vertex. If the function is called on a NIL vertex then it returns NIL.

See Also share_graph_set_select_in
array_t * 
share_graph_select_out(
  vertex_t * vertex 
)
Returns the select out values of a vertex. If the function is called on a NIL vertex then it returns NIL.

See Also share_graph_set_select_out
void 
share_graph_set_flag(
  vertex_t * vertex, 
  int  flag 
)
Sets the flag of a vertex. If the function is called on a NIL vertex then it does not do anything.

See Also share_graph_flag share_graph_reset_flag_all
void 
share_graph_set_name(
  vertex_t * vertex, 
  char * name 
)
Sets the name of a vertex. User has to allocate this string. If the function is called on a NIL parameter then it does not do anything.

See Also share_graph_name
void 
share_graph_set_node(
  vertex_t * vertex, 
  net_node_t * node 
)
Sets node the vertex represents. If the function is called on a NIL parameter then it does not do anything.

See Also share_graph_node
void 
share_graph_set_select_in(
  vertex_t * vertex, 
  array_t * select 
)
Sets the select in values of a vertex. It appends the given values to the old set, sorts them, and deletes duplications. If the function is called on a NIL parameter then it does not do anything.

See Also share_graph_select_in
void 
share_graph_set_select_out(
  vertex_t * vertex, 
  array_t * select 
)
Sets the select out values of a vertex. It appends the given values to the old set, sorts them, and deletes duplications. If the function is called on a NIL parameter then it does not do anything.

See Also share_graph_select_out
void 
share_graph_set_state(
  vertex_t * vertex, 
  array_t * state 
)
Sets the state values of a vertex. It appends the given values to the old set, sorts them, and deletes duplications. If the function is called on a NIL parameter then it does not do anything.

See Also share_graph_state
void 
share_graph_set_type(
  vertex_t * vertex, 
  char * type 
)
Sets the type of a vertex. User has to allocate this string. If the function is called on a NIL parameter then it does not do anything.

See Also share_graph__type
void 
share_graph_set_var(
  vertex_t * vertex, 
  net_var_t * var 
)
Sets variable the vertex represents. If the function is called on a NIL parameter then it does not do anything.

array_t * 
share_graph_state(
  vertex_t * vertex 
)
Returns the state values of a vertex. If the function is called on a NIL vertex then it returns NIL.

See Also share_graph_set_state
char * 
share_graph_type(
  vertex_t * vertex 
)
Returns the type of a vertex. User must not free this string. If the function is called on a NIL vertex then it returns NIL.

See Also share_graph_set_type
void 
share_group_graph_nodes(
  graph_t * graph, 
  net_node_t * cfsm_node, 
  net_var_t * state_var, 
  array_t ** in_nodes, 
  array_t ** in_state, 
  array_t ** in_select, 
  array_t ** out_nodes, 
  array_t ** out_select, 
  array_t ** in_out_nodes, 
  array_t ** in_out_state, 
  array_t ** in_out_select 
)
Groups graph vertices according that they are in the care sets of CFSM transitions, output functions or both.

int 
share_hw_comb(
  net_node_t * net_node 
)
Share combinational subcircuits. The parameter should be a NET node with HW implementation. The NET node has to include only one CFSM node. Combinational subcircuits can be connected either to input and/or output of a CFSM node for data computation. The condition of sharing between subcircuits connected to CFSM inputs is that the data computed by them have to be used at different states. For subcircuits connected to CFSM outputs the condition is that they have to be used at different transitions. For subcircuits connected to CFSM inputs and outputs a sharing can be done if the intersect of the set of all transitions from states, where inputs are used, and the set of transitions, where outputs are used, is zero. It substitutes them with a NET includes MUXs as well as it modifies CFSM to address MUXs. If there is an error it returns 0, otherwise 1.

See Also share_sw_comb
void 
share_insert_array_trel_out(
  array_t * array, 
  trel_out_t * new_trel_out, 
  int  trel_index 
)
Inserts the trel_out structure into look-up table at the given position.

void 
share_internal_to_graph(
  net_node_t * node, 
  graph_t ** graph 
)
Creates vertices for representing internal variables of a NET node. It sets data (name, type, pointer) associated with the vertex. It also connects the vertex to other vertices by edges according to connectivity given by NET node. If it is not connected to any other vertices which represent combinational subcircuits then it deletes the created vertex, else it adds vertex to the given graph.

See Also share_fanin_to_graph share_constant_to_graph share_fanout_to_graph
int 
share_mdd_to_multi_value(
  mdd_manager * manager, 
  int  mdd_id, 
  array_t * mdd_value, 
  array_t * values, 
  array_t * new_value1, 
  array_t * new_value2 
)
Converts encoded MDD value of a variable into multi value. If the conversion is successfull then it returns TRUE inserting the multi value into a list of values. However the value is not inserted if it is out of range. A not succesfull conversation is caused by a dont care and in this case it returns FALSE creating two new MDD values by splitting the first don't care bit into 0 and 1.

See Also share_mdd_value_to_values
void 
share_mdd_value_to_values(
  mdd_manager * manager, 
  int  mdd_id, 
  array_t * mdd_value, 
  array_t * values 
)
Converts encoded MDD value of a variable into a set of multi values.

See Also share_mdd_to_multi_value
void 
share_multiplex_instances(
  net_node_t * net_node, 
  array_t * vertices 
)
Shares nodes given represented by vertices inserting multiplexer into the NET node.

graph_t * 
share_net_to_graph(
  net_node_t * node 
)
Maps the NET node into a data flow graph. Vertices represents combinational subcircuits and variables. If the function is called on a not NET node then it returns NIL.

void 
share_propagate_select_in(
  vertex_t * vertex, 
  array_t * select_in_set 
)
Propagates the set of _select in values to vertices of subgraph.

See Also share_propagate_state share_propagate_select_out
void 
share_propagate_select_out(
  vertex_t * vertex, 
  array_t * select_out_set 
)
Propagates the set of _select out values to vertices of subgraph.

See Also share_propagate_state share_propagate_select_in
void 
share_propagate_state(
  vertex_t * vertex, 
  array_t * state_set 
)
Propagates the set of state values to vertices of subgraph.

See Also share_propagate_select_in share_propagate_select_out
void 
share_select_in_ticket(
  graph_t * graph, 
  array_t * vertex_list, 
  array_t * sets 
)
Tickets subgraphs by sets of _select in values.

See Also share_state_ticket share_select_out_ticket share_ticket_graph
void 
share_select_out_ticket(
  graph_t * graph, 
  array_t * vertex_list, 
  array_t * sets 
)
Tickets subgraphs by sets of _select out values.

See Also share_state_ticket share_select_in_ticket share_ticket_graph
void 
share_state_ticket(
  graph_t * graph, 
  array_t * vertex_list, 
  array_t * sets 
)
Tickets subgraphs by sets of state values.

See Also share_select_in_ticket share_select_out_ticket share_ticket_graph
int 
share_sw_comb(
  net_node_t * net_node 
)
Creates shared instances. Puts those instances represented by vertices into a NET node which can be shared. The parameter should be a NET node with SW implementation. The NET node has to include only one CFSM node. Combinational subcircuits can be connected either to input and/or output of a CFSM node for data computation. Combinational subcircuits can be shared if they have the same functionality. It clusters them in a NET giving shared=SW attribute. If there is an error it returns 0, otherwise 1.

See Also share_hw_comb
void 
share_sw_create_shared_instances(
  net_node_t * net_node, 
  array_t * vertices 
)
Creates shared instances. Puts those instances represented by vertices into a NET node which can be shared.

array_t * 
share_sw_get_nodes_for_sharing(
  graph_t * graph 
)
Returns all sets of vertices of a graph which have the same functionality.

array_t * 
share_sw_get_pairs_for_sharing(
  array_t * set1 
)
Returns all pairs of vertices which have the same functionality. The first elements of pairs are given.

See Also share_sw_get_nodes_for_sharing
void 
share_sw_replace_instance(
  net_node_t * inst, 
  net_node_t * model 
)
Replaces the instance by another instance of a model.

void 
share_sweep_graph(
  graph_t * graph 
)
Delete not used vertices from graph. If a subcircuit represented by a vertice is not used for CFSM transition then it deletes the vertex from graph. It prints not used subcircuits to polisout.

int 
share_ticket_graph(
  net_node_t * net_node, 
  graph_t * graph 
)
Tickets vertices of graph by values of state and _select variables. If there is no CFSM node then it returns (-2), if there are more control state variables then it returns (-3), if there is no control state variable then it returns (-4).

See Also share_state_ticket share_select_in_ticket share_select_out_ticket
int 
share_vertex_is_member(
  array_t * array, 
  vertex_t * vertex1 
)
Tests if the given vertex is in an array. It returns TRUE if the vertex is a member, else FALSE.


Generated automatically by extdoc on 951030
Contact 
©2002-2018 U.C. Regents