[14] | 1 | /**CFile*********************************************************************** |
---|
| 2 | |
---|
| 3 | FileName [ioWriteBlifMv.c] |
---|
| 4 | |
---|
| 5 | PackageName [io] |
---|
| 6 | |
---|
| 7 | Synopsis [Writes out a blif-mv file.] |
---|
| 8 | |
---|
| 9 | Description [] |
---|
| 10 | |
---|
| 11 | SeeAlso [] |
---|
| 12 | |
---|
| 13 | Author [Yuji Kukimoto] |
---|
| 14 | |
---|
| 15 | Copyright [Copyright (c) 1994-1996 The Regents of the Univ. of California. |
---|
| 16 | All rights reserved. |
---|
| 17 | |
---|
| 18 | Permission is hereby granted, without written agreement and without license |
---|
| 19 | or royalty fees, to use, copy, modify, and distribute this software and its |
---|
| 20 | documentation for any purpose, provided that the above copyright notice and |
---|
| 21 | the following two paragraphs appear in all copies of this software. |
---|
| 22 | |
---|
| 23 | IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR |
---|
| 24 | DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT |
---|
| 25 | OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE UNIVERSITY OF |
---|
| 26 | CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
---|
| 27 | |
---|
| 28 | THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES, |
---|
| 29 | INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND |
---|
| 30 | FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS ON AN |
---|
| 31 | "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATION TO PROVIDE |
---|
| 32 | MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.] |
---|
| 33 | |
---|
| 34 | ******************************************************************************/ |
---|
| 35 | |
---|
| 36 | #include "ioInt.h" |
---|
| 37 | |
---|
| 38 | static char rcsid[] UNUSED = "$Id: ioWriteBlifMv.c,v 1.8 1998/09/24 00:07:34 hsv Exp $"; |
---|
| 39 | |
---|
| 40 | /*---------------------------------------------------------------------------*/ |
---|
| 41 | /* Constant declarations */ |
---|
| 42 | /*---------------------------------------------------------------------------*/ |
---|
| 43 | |
---|
| 44 | |
---|
| 45 | /*---------------------------------------------------------------------------*/ |
---|
| 46 | /* Type declarations */ |
---|
| 47 | /*---------------------------------------------------------------------------*/ |
---|
| 48 | |
---|
| 49 | |
---|
| 50 | /*---------------------------------------------------------------------------*/ |
---|
| 51 | /* Stucture declarations */ |
---|
| 52 | /*---------------------------------------------------------------------------*/ |
---|
| 53 | |
---|
| 54 | |
---|
| 55 | /*---------------------------------------------------------------------------*/ |
---|
| 56 | /* Variable declarations */ |
---|
| 57 | /*---------------------------------------------------------------------------*/ |
---|
| 58 | |
---|
| 59 | |
---|
| 60 | /*---------------------------------------------------------------------------*/ |
---|
| 61 | /* Macro declarations */ |
---|
| 62 | /*---------------------------------------------------------------------------*/ |
---|
| 63 | |
---|
| 64 | |
---|
| 65 | /**AutomaticStart*************************************************************/ |
---|
| 66 | |
---|
| 67 | /*---------------------------------------------------------------------------*/ |
---|
| 68 | /* Static function prototypes */ |
---|
| 69 | /*---------------------------------------------------------------------------*/ |
---|
| 70 | |
---|
| 71 | |
---|
| 72 | /**AutomaticEnd***************************************************************/ |
---|
| 73 | |
---|
| 74 | |
---|
| 75 | /*---------------------------------------------------------------------------*/ |
---|
| 76 | /* Definition of exported functions */ |
---|
| 77 | /*---------------------------------------------------------------------------*/ |
---|
| 78 | |
---|
| 79 | |
---|
| 80 | /*---------------------------------------------------------------------------*/ |
---|
| 81 | /* Definition of internal functions */ |
---|
| 82 | /*---------------------------------------------------------------------------*/ |
---|
| 83 | |
---|
| 84 | |
---|
| 85 | /**Function******************************************************************** |
---|
| 86 | |
---|
| 87 | Synopsis [The top-level routine for writing out a BLIF-MV file.] |
---|
| 88 | |
---|
| 89 | Description [The top-level routine for writing out a blif-mv file. |
---|
| 90 | The user has to check if the hmgr has a hierarchy read in before |
---|
| 91 | calling this procedure.] |
---|
| 92 | |
---|
| 93 | SideEffects [] |
---|
| 94 | |
---|
| 95 | SeeAlso [] |
---|
| 96 | |
---|
| 97 | ******************************************************************************/ |
---|
| 98 | void |
---|
| 99 | IoBlifMvWrite( |
---|
| 100 | FILE *fp, |
---|
| 101 | Hrc_Manager_t *hmgr) |
---|
| 102 | { |
---|
| 103 | char *rootModelName; |
---|
| 104 | Hrc_Model_t *model, *rootModel; |
---|
| 105 | Hrc_Node_t *currentNode; |
---|
| 106 | array_t *models; |
---|
| 107 | int i; |
---|
| 108 | boolean isRootModel; |
---|
| 109 | char *rootInstanceName, *instanceName; |
---|
| 110 | |
---|
| 111 | currentNode = Hrc_ManagerReadCurrentNode(hmgr); |
---|
| 112 | models = Hrc_ManagerObtainComponentModels(hmgr); |
---|
| 113 | |
---|
| 114 | rootModelName = Hrc_NodeReadModelName(currentNode); |
---|
| 115 | rootModel = Hrc_ManagerFindModelByName(hmgr,rootModelName); |
---|
| 116 | rootInstanceName = Hrc_NodeReadInstanceName(currentNode); |
---|
| 117 | assert(rootModel != NIL(Hrc_Model_t)); |
---|
| 118 | |
---|
| 119 | for (i=0; i < array_n(models); i++){ |
---|
| 120 | model = array_fetch(Hrc_Model_t *,models,i); |
---|
| 121 | isRootModel = (model == rootModel) ? TRUE : FALSE; |
---|
| 122 | instanceName = (isRootModel == TRUE) ? rootInstanceName : NIL(char); |
---|
| 123 | Hrc_ModelWriteBlifMv(fp,model,isRootModel,instanceName); |
---|
| 124 | } |
---|
| 125 | |
---|
| 126 | array_free(models); |
---|
| 127 | } |
---|
| 128 | |
---|
| 129 | /**Function******************************************************************** |
---|
| 130 | |
---|
| 131 | Synopsis [Prints out .mv declaration for a given variable.] |
---|
| 132 | |
---|
| 133 | Description [Prints out .mv declaration for a given variable.] |
---|
| 134 | |
---|
| 135 | SideEffects [] |
---|
| 136 | |
---|
| 137 | SeeAlso [] |
---|
| 138 | |
---|
| 139 | ******************************************************************************/ |
---|
| 140 | void |
---|
| 141 | IoMvPrint( |
---|
| 142 | FILE *fp, |
---|
| 143 | Var_Variable_t *var) |
---|
| 144 | { |
---|
| 145 | int is_enum, range, i; |
---|
| 146 | |
---|
| 147 | is_enum = Var_VariableTestIsEnumerative(var); |
---|
| 148 | range = Var_VariableReadNumValues(var); |
---|
| 149 | |
---|
| 150 | if (is_enum == 1){ |
---|
| 151 | if (range == 2){ |
---|
| 152 | /* Boolean enumerative variables need no .mv declaration. */ |
---|
| 153 | return; |
---|
| 154 | } |
---|
| 155 | else { |
---|
| 156 | (void)fprintf(fp,".mv %s %d\n",Var_VariableReadName(var),range); |
---|
| 157 | } |
---|
| 158 | } |
---|
| 159 | else { |
---|
| 160 | /* variable var is symbolic */ |
---|
| 161 | (void)fprintf(fp,".mv %s %d ",Var_VariableReadName(var),range); |
---|
| 162 | for (i=0; i < range; i++){ |
---|
| 163 | (void)fprintf(fp,"%s ",Var_VariableReadSymbolicValueFromIndex(var,i)); |
---|
| 164 | } |
---|
| 165 | (void)fprintf(fp,"\n"); |
---|
| 166 | } |
---|
| 167 | } |
---|
| 168 | |
---|
| 169 | /**Function******************************************************************** |
---|
| 170 | |
---|
| 171 | Synopsis [Prints out .mv declaration for a given variable, with the special |
---|
| 172 | string "_bufin" appended to the variable name.] |
---|
| 173 | |
---|
| 174 | Description [Prints out .mv declaration for a given variable.] |
---|
| 175 | |
---|
| 176 | SideEffects [] |
---|
| 177 | |
---|
| 178 | SeeAlso [] |
---|
| 179 | |
---|
| 180 | ******************************************************************************/ |
---|
| 181 | void |
---|
| 182 | IoMvPrintSpecial( |
---|
| 183 | FILE *fp, |
---|
| 184 | Var_Variable_t *var) |
---|
| 185 | { |
---|
| 186 | int is_enum, range, i; |
---|
| 187 | |
---|
| 188 | is_enum = Var_VariableTestIsEnumerative(var); |
---|
| 189 | range = Var_VariableReadNumValues(var); |
---|
| 190 | |
---|
| 191 | if (is_enum == 1){ |
---|
| 192 | if (range == 2){ |
---|
| 193 | /* Boolean enumerative variables need no .mv declaration. */ |
---|
| 194 | return; |
---|
| 195 | } |
---|
| 196 | else { |
---|
| 197 | (void)fprintf(fp,".mv %s_bufin %d\n",Var_VariableReadName(var),range); |
---|
| 198 | } |
---|
| 199 | } |
---|
| 200 | else { |
---|
| 201 | /* variable var is symbolic */ |
---|
| 202 | (void)fprintf(fp,".mv %s_bufin %d ",Var_VariableReadName(var),range); |
---|
| 203 | for (i=0; i < range; i++){ |
---|
| 204 | (void)fprintf(fp,"%s ",Var_VariableReadSymbolicValueFromIndex(var,i)); |
---|
| 205 | } |
---|
| 206 | (void)fprintf(fp,"\n"); |
---|
| 207 | } |
---|
| 208 | } |
---|
| 209 | |
---|
| 210 | |
---|
| 211 | |
---|