VIS

src/io/ioWriteBlifMv.c

Go to the documentation of this file.
00001 
00036 #include "ioInt.h"
00037 
00038 static char rcsid[] UNUSED = "$Id: ioWriteBlifMv.c,v 1.8 1998/09/24 00:07:34 hsv Exp $";
00039 
00040 /*---------------------------------------------------------------------------*/
00041 /* Constant declarations                                                     */
00042 /*---------------------------------------------------------------------------*/
00043 
00044 
00045 /*---------------------------------------------------------------------------*/
00046 /* Type declarations                                                         */
00047 /*---------------------------------------------------------------------------*/
00048 
00049 
00050 /*---------------------------------------------------------------------------*/
00051 /* Stucture declarations                                                     */
00052 /*---------------------------------------------------------------------------*/
00053 
00054 
00055 /*---------------------------------------------------------------------------*/
00056 /* Variable declarations                                                     */
00057 /*---------------------------------------------------------------------------*/
00058 
00059 
00060 /*---------------------------------------------------------------------------*/
00061 /* Macro declarations                                                        */
00062 /*---------------------------------------------------------------------------*/
00063 
00064 
00067 /*---------------------------------------------------------------------------*/
00068 /* Static function prototypes                                                */
00069 /*---------------------------------------------------------------------------*/
00070 
00071 
00075 /*---------------------------------------------------------------------------*/
00076 /* Definition of exported functions                                          */
00077 /*---------------------------------------------------------------------------*/
00078 
00079 
00080 /*---------------------------------------------------------------------------*/
00081 /* Definition of internal functions                                          */
00082 /*---------------------------------------------------------------------------*/
00083 
00084 
00098 void
00099 IoBlifMvWrite(
00100   FILE *fp,
00101   Hrc_Manager_t *hmgr)
00102 { 
00103   char *rootModelName;
00104   Hrc_Model_t *model, *rootModel;
00105   Hrc_Node_t *currentNode;
00106   array_t *models;
00107   int i;
00108   boolean isRootModel;
00109   char *rootInstanceName, *instanceName;
00110   
00111   currentNode = Hrc_ManagerReadCurrentNode(hmgr);
00112   models = Hrc_ManagerObtainComponentModels(hmgr);
00113 
00114   rootModelName = Hrc_NodeReadModelName(currentNode);
00115   rootModel = Hrc_ManagerFindModelByName(hmgr,rootModelName);
00116   rootInstanceName = Hrc_NodeReadInstanceName(currentNode);
00117   assert(rootModel != NIL(Hrc_Model_t));
00118   
00119   for (i=0; i < array_n(models); i++){
00120     model = array_fetch(Hrc_Model_t *,models,i);
00121     isRootModel = (model == rootModel) ? TRUE : FALSE;
00122     instanceName = (isRootModel == TRUE) ? rootInstanceName : NIL(char);
00123     Hrc_ModelWriteBlifMv(fp,model,isRootModel,instanceName);
00124   }  
00125 
00126   array_free(models);
00127 }
00128 
00140 void
00141 IoMvPrint(
00142   FILE *fp,
00143   Var_Variable_t *var)
00144 {
00145   int is_enum, range, i;
00146 
00147   is_enum = Var_VariableTestIsEnumerative(var);
00148   range = Var_VariableReadNumValues(var);
00149     
00150   if (is_enum == 1){
00151     if (range == 2){
00152       /* Boolean enumerative variables need no .mv declaration. */
00153       return;
00154     }
00155     else {
00156       (void)fprintf(fp,".mv %s %d\n",Var_VariableReadName(var),range);
00157     }
00158   }
00159   else {
00160   /* variable var is symbolic */
00161     (void)fprintf(fp,".mv %s %d ",Var_VariableReadName(var),range);
00162     for (i=0; i < range; i++){
00163       (void)fprintf(fp,"%s ",Var_VariableReadSymbolicValueFromIndex(var,i));
00164     }
00165     (void)fprintf(fp,"\n");
00166   }
00167 }
00168 
00181 void
00182 IoMvPrintSpecial(
00183   FILE *fp,
00184   Var_Variable_t *var)
00185 {
00186   int is_enum, range, i;
00187 
00188   is_enum = Var_VariableTestIsEnumerative(var);
00189   range = Var_VariableReadNumValues(var);
00190     
00191   if (is_enum == 1){
00192     if (range == 2){
00193       /* Boolean enumerative variables need no .mv declaration. */
00194       return;
00195     }
00196     else {
00197       (void)fprintf(fp,".mv %s_bufin %d\n",Var_VariableReadName(var),range);
00198     }
00199   }
00200   else {
00201   /* variable var is symbolic */
00202     (void)fprintf(fp,".mv %s_bufin %d ",Var_VariableReadName(var),range);
00203     for (i=0; i < range; i++){
00204       (void)fprintf(fp,"%s ",Var_VariableReadSymbolicValueFromIndex(var,i));
00205     }
00206     (void)fprintf(fp,"\n");
00207   }
00208 }
00209 
00210 
00211