Main Page | Class List | File List | Class Members | File Members

net.c File Reference

#include "tarski.h"

Go to the source code of this file.

Defines

#define BUFFER_SIZE   128
#define DEFAULT_MEM_SIZE   8

Functions

FnodeNet_NameToNode (Net_t *net, char *name)
 Return the node associated with a name (which could be a PI, a register, a constant, or an internal node).
Net_tNet_CreateFromFormula (Fnode *aFormula)
 Create a net struct from a formula.
Net_tNet_CreateFromFormulaArray (array_t *aFormulas)
 Create a net struct from an array of formulas.
int Net_FreeNet (Net_t *net)
 Deallocate the net object.
int Net_PopulateFields (Net_t *net, Fnode *aFormula, Fnode *parentFormula, st_table *processedNodes)
 Take a formula and its parent, and add it and its subformula information to the Net_t structure being created for it.
int Net_DoBryantReduction (Net_t *net)
 Take a net structure and replace all UIFs with new PIs. Use the Bryant reduction.
int Node_PrintVHDL (Net_t *net, Fnode *formula, FILE *fptr, st_table *nodeToNameHash, st_table *processedNodes, st_table *uifInstantiateHash, st_table *uifToNumInputs, int vector_width)
 Print VHDL for a Node.
int Net_NodeGetId (Net_t *net, Fnode *formula)
 Get id for node.
int Net_ConstrainInput (Net_t *net, char *input, Fnode *const_formula)
 Constrain an input.
int Net_UnConstrainInput (Net_t *net, char *input, Fnode *const_formula)
 UnConstrain an input.
Net_tNet_ReplaceWritewithRead (Net_t *net, char *writeUifName, char *readUifName, int output_index)
 ReplaceWritewithRead Wrapper.
FnodeNet_AccessOutput (Net_t *net, int output_index)
 Access the Outputs of Netlist.
int Net_PrintVHDL (Net_t *net, int vector_width, char *fileName, char *entity_name)
 Wrapper function for Net_PrintVHDL Calls Net_PrintVHDLInt.
int Net_SetMemSize (Net_t *net, char *memName, int memSize)
 Set the size of registerfile/mem.
int Net_AnalyzeScalarBitWidth (Net_t *net)
 Use finite domain property to come up with a bit width for scalar variables.
array_t * node_array_tfe (array_t *input_array, int N)
 Perform time frame expansion on an array of formulas.
Fnodenode_tfe (Fnode *formula, int N)
 Perform time frame expansion on formula.
int Net_PrintFormula (Net_t *net, Fnode *formula, char *filename)
 PrintFormula Wrapper.
int ReplaceWritewithRead (Net_t *net, char *writeUifName, char *readUifName)
 Replaces WRITEs by READs.
int AddReadatEnd (Net_t *net, Fnode *readAddress, char *readUifName, int formula_index)
 Add Read at the end to enable replacing writes with reads.
int Net_TopologicalSort (Fnode *aFormula, st_table *sortedTable, st_table *processedNodes)
 Topological Sorting of a Netlist.
int Net_ConstantPropagation (st_table *sortedTable, st_table *equivalentNodeHash, int max_depth)
 Constant Propagation in a Netlist.
st_table * Net_ReadNodeVals (char *fileName)
int Net_CheckBurchFeasibility (Fnode *aFormula, Fnode *ctrl_child)
void Net_CollectMuxes (Fnode *aFormula, st_table *mux_hash)
FnodeNet_SimplifyUsingConstantPropagation (Fnode *aFormula)
 Simplify a formula using constant propagation.


Define Documentation

#define BUFFER_SIZE   128
 

CFile***********************************************************************

FileName [net.c]

PackageName [trk]

Synopsis []

Author [Adnan Aziz, Hari Mony]

Copyright [Copyright (c) 2006 Adnan Aziz]

Definition at line 18 of file net.c.

#define DEFAULT_MEM_SIZE   8
 

Definition at line 19 of file net.c.


Function Documentation

int AddReadatEnd Net_t net,
Fnode readAddress,
char *  readUifName,
int  formula_index
 

Add Read at the end to enable replacing writes with reads.

Definition at line 4028 of file net.c.

References Equal_c, NetStruct::formulas, Func_c, Fnode::lchild, List_c, Net_t, new_node_raw(), nil, node_cmp(), node_hash(), Not_c, and Fnode::rchild.

Referenced by build_dlx_uclid_compare(), and Net_ReplaceWritewithRead().

Fnode* Net_AccessOutput Net_t net,
int  output_index
 

Access the Outputs of Netlist.

Definition at line 950 of file net.c.

References NetStruct::formulas, and Net_t.

int Net_AnalyzeScalarBitWidth Net_t net  ) 
 

Use finite domain property to come up with a bit width for scalar variables.

Definition at line 998 of file net.c.

References Net_t, NetStruct::PIs, and Fnode::type.

int Net_CheckBurchFeasibility Fnode aFormula,
Fnode ctrl_child
 

Definition at line 4548 of file net.c.

References And_c, BooleanPI_c, BooleanReg_c, Equal_c, FALSE_c, Func_c, Iff_c, InternalBooleanVar_c, InternalScalarVar_c, List_c, Mux_c, Mux_ElseInput(), Mux_ThenInput(), Not_c, Or_c, Pair_c, Reg_InitFunc(), Reg_NsFunc(), ScalarConst_c, ScalarPI_c, ScalarReg_c, TRUE_c, Fnode::type, UnaryFunc_c, and Undef_c.

void Net_CollectMuxes Fnode aFormula,
st_table *  mux_hash
 

Definition at line 4634 of file net.c.

References And_c, BooleanPI_c, BooleanReg_c, Equal_c, FALSE_c, Func_c, Iff_c, InternalBooleanVar_c, InternalScalarVar_c, List_c, Mux_c, Not_c, Or_c, Pair_c, Reg_InitFunc(), Reg_NsFunc(), ScalarConst_c, ScalarPI_c, ScalarReg_c, TRUE_c, Fnode::type, UnaryFunc_c, and Undef_c.

int Net_ConstantPropagation st_table *  sortedTable,
st_table *  equivalentNodeHash,
int  max_depth
 

Constant Propagation in a Netlist.

Definition at line 4181 of file net.c.

References And_c, BooleanPI_c, BooleanReg_c, Equal_c, FALSE_c, Func_c, Iff_c, InternalBooleanVar_c, InternalScalarVar_c, Fnode::lchild, List_c, Mux_c, Mux_ElseInput(), Mux_ThenInput(), new_node_raw(), nil, node_GetUnique(), Not_c, Or_c, Pair_c, Fnode::rchild, ScalarConst_c, ScalarPI_c, ScalarReg_c, TRUE_c, Fnode::type, UnaryFunc_c, and Undef_c.

Referenced by build_dlx_uclid_compare(), build_dlx_uclid_superscalar_seq(), and Net_SimplifyUsingConstantPropagation().

int Net_ConstrainInput Net_t net,
char *  input,
Fnode const_formula
 

Constrain an input.

Definition at line 865 of file net.c.

References Net_NameToNode(), Net_t, nil, node_cmp(), and node_hash().

Referenced by build_dlx_uclid_compare().

Net_t* Net_CreateFromFormula Fnode aFormula  ) 
 

Create a net struct from a formula.

Definition at line 106 of file net.c.

References NetStruct::allNodes, NetStruct::constants, NetStruct::formulas, NetStruct::memToSizeHash, NetStruct::nameToNodeHash, Net_PopulateFields(), Net_t, nil, node_cmp(), node_hash(), NetStruct::nodeToFanoutArray, NetStruct::nodeToId, NetStruct::numNodes, NetStruct::PIs, and NetStruct::UIFs.

Referenced by build_dlx_uclid_superscalar_seq(), build_fold_unfold_check(), build_microarch_wrapper(), Net_ReplaceWritewithRead(), and node_tfe().

Net_t* Net_CreateFromFormulaArray array_t *  aFormulas  ) 
 

Create a net struct from an array of formulas.

Definition at line 150 of file net.c.

References NetStruct::allNodes, NetStruct::constants, NetStruct::formulas, NetStruct::memToSizeHash, NetStruct::nameToNodeHash, Net_PopulateFields(), Net_t, nil, node_cmp(), node_hash(), NetStruct::nodeToFanoutArray, NetStruct::nodeToId, NetStruct::numNodes, NetStruct::PIs, and NetStruct::UIFs.

Referenced by build_dlx_uclid_compare(), build_microarch_wrapper(), and node_array_tfe().

int Net_DoBryantReduction Net_t net  ) 
 

Take a net structure and replace all UIFs with new PIs. Use the Bryant reduction.

Given

  *  F u_0, F u_1, F u_2,... F u_{n-1}
  *               replace these with 
  *               v_0
  *               (u_1 = u_0 ) ? v_0 : 
  * 	v_1
  *               (u_2 = u_0 ) ? v_0 : 
  * 	(u_2 = u_1 ) ?  v_1 : 
  * 	 v_2
  *               (u_{n-1} = u_0 ) ? v_0 : 
  * 	(u_{n-1} = u_1 ) ? v_1 : 
  * 	  (u_{n-1} = u_{n-2}) ? v_{n-2} : 
  * 	   v_{n-1}
  * 

This is quadratic in complexity, but avoids the comparisons between v_i's, which is the case for the Ackerman reduction, wherein for each i, j<i there's a constraint u_i = u_j v_i = v_j. The Ackermann style also add a lot of logic flowing to the output node. As implemented, the Net_t structure passed in is corrupted, since we change fanouts, remove/add nodes, etc. Rather than try to repair the structure on the fly, it's better to recreate it from the new formula.

Definition at line 383 of file net.c.

References Fnode::lchild, Net_t, new_node(), nil, node_cmp(), node_hash(), Fnode::rchild, ScalarPI_c, and NetStruct::UIFs.

Referenced by build_dlx_uclid_compare(), and build_fold_unfold_check().

int Net_FreeNet Net_t net  ) 
 

Deallocate the net object.

Definition at line 192 of file net.c.

References NetStruct::allNodes, NetStruct::constants, NetStruct::memToSizeHash, NetStruct::nameToNodeHash, Net_t, NetStruct::nodeToFanoutArray, NetStruct::nodeToId, NetStruct::PIs, and NetStruct::UIFs.

Referenced by build_dlx_uclid_compare(), and Net_ReplaceWritewithRead().

Fnode* Net_NameToNode Net_t net,
char *  name
 

Return the node associated with a name (which could be a PI, a register, a constant, or an internal node).

Definition at line 84 of file net.c.

References NetStruct::nameToNodeHash, and Net_t.

Referenced by Net_ConstrainInput(), and Net_UnConstrainInput().

int Net_NodeGetId Net_t net,
Fnode formula
 

Get id for node.

Definition at line 845 of file net.c.

References Net_t, and NetStruct::nodeToId.

int Net_PopulateFields Net_t net,
Fnode aFormula,
Fnode parentFormula,
st_table *  processedNodes
 

Take a formula and its parent, and add it and its subformula information to the Net_t structure being created for it.

We need the parent to fill in the fanout information.

Definition at line 226 of file net.c.

References NetStruct::allNodes, NetStruct::constants, Fnode::lchild, NetStruct::nameToNodeHash, Net_t, Node_HasLeftChildNode(), Node_HasRightChildNode(), NetStruct::nodeToFanoutArray, NetStruct::nodeToId, NetStruct::numNodes, NetStruct::PIs, Fnode::rchild, ScalarConst_c, Fnode::type, and NetStruct::UIFs.

Referenced by Net_CreateFromFormula(), and Net_CreateFromFormulaArray().

int Net_PrintFormula Net_t net,
Fnode formula,
char *  filename
 

PrintFormula Wrapper.

Definition at line 1105 of file net.c.

References Net_t.

Referenced by build_dlx_uclid_compare().

int Net_PrintVHDL Net_t net,
int  vector_width,
char *  fileName,
char *  entity_name
 

Wrapper function for Net_PrintVHDL Calls Net_PrintVHDLInt.

Definition at line 964 of file net.c.

References Net_t.

Referenced by build_dlx_uclid_superscalar_seq(), build_fold_unfold_check(), and build_microarch_wrapper().

st_table* Net_ReadNodeVals char *  fileName  ) 
 

Definition at line 4520 of file net.c.

Net_t* Net_ReplaceWritewithRead Net_t net,
char *  writeUifName,
char *  readUifName,
int  output_index
 

ReplaceWritewithRead Wrapper.

This function will first add a generic Read (with random read_address) at the specific output and then call the ReplaceWritewithRead function to perform the actual transformation

Definition at line 917 of file net.c.

References AddReadatEnd(), NetStruct::formulas, Net_CreateFromFormula(), Net_FreeNet(), Net_t, F::raw, ReplaceWritewithRead(), si(), and NetStruct::UIFs.

int Net_SetMemSize Net_t net,
char *  memName,
int  memSize
 

Set the size of registerfile/mem.

Definition at line 978 of file net.c.

References NetStruct::memToSizeHash, and Net_t.

Fnode* Net_SimplifyUsingConstantPropagation Fnode aFormula  ) 
 

Simplify a formula using constant propagation.

Definition at line 4695 of file net.c.

References Net_ConstantPropagation(), and Net_TopologicalSort().

int Net_TopologicalSort Fnode aFormula,
st_table *  sortedTable,
st_table *  processedNodes
 

Topological Sorting of a Netlist.

Definition at line 4080 of file net.c.

References And_c, BooleanPI_c, BooleanReg_c, Equal_c, FALSE_c, Func_c, Iff_c, InternalBooleanVar_c, InternalScalarVar_c, List_c, Mux_c, Not_c, Or_c, Pair_c, ScalarConst_c, ScalarPI_c, ScalarReg_c, TRUE_c, UnaryFunc_c, and Undef_c.

Referenced by build_dlx_uclid_compare(), build_dlx_uclid_superscalar_seq(), and Net_SimplifyUsingConstantPropagation().

int Net_UnConstrainInput Net_t net,
char *  input,
Fnode const_formula
 

UnConstrain an input.

Definition at line 893 of file net.c.

References Net_NameToNode(), Net_t, and nil.

Referenced by build_dlx_uclid_compare().

array_t* node_array_tfe array_t *  input_array,
int  N
 

Perform time frame expansion on an array of formulas.

Definition at line 1026 of file net.c.

References Net_CreateFromFormulaArray(), Net_t, and node_dup().

int Node_PrintVHDL Net_t net,
Fnode formula,
FILE *  fptr,
st_table *  nodeToNameHash,
st_table *  processedNodes,
st_table *  uifInstantiateHash,
st_table *  uifToNumInputs,
int  vector_width
 

Print VHDL for a Node.

Definition at line 607 of file net.c.

References And_c, Assign_c, BooleanPI_c, BooleanReg_c, Equal_c, FALSE_c, Func_c, Func_FirstArg(), Iff_c, InternalBooleanVar_c, InternalScalarVar_c, List_c, Mux_c, Mux_ElseInput(), Mux_ThenInput(), Net_t, NetStruct::nodeToId, Not_c, Operator_t, Or_c, Pair_c, Reg_InitFunc(), Reg_NsFunc(), ScalarConst_c, ScalarPI_c, ScalarReg_c, TRUE_c, Fnode::type, UnaryFunc_c, and Undef_c.

Fnode* node_tfe Fnode formula,
int  N
 

Perform time frame expansion on formula.

Definition at line 1069 of file net.c.

References Net_CreateFromFormula(), and Net_t.

Referenced by build_dlx_uclid_compare(), and build_fold_unfold_check().

int ReplaceWritewithRead Net_t net,
char *  writeUifName,
char *  readUifName
 

Replaces WRITEs by READs.

Definition at line 3845 of file net.c.

References Func_FirstArg(), Func_SecondArg(), Net_t, nil, node_cmp(), node_hash(), and NetStruct::UIFs.

Referenced by build_dlx_uclid_compare(), and Net_ReplaceWritewithRead().


Generated on Thu Oct 11 11:47:29 2007 for Tarski by  doxygen 1.3.9.1