[14] | 1 | /**CFile*********************************************************************** |
---|
| 2 | |
---|
| 3 | FileName [truesimCmd.c] |
---|
| 4 | |
---|
| 5 | PackageName [truesim] |
---|
| 6 | |
---|
| 7 | Synopsis [Command interface for the truesim package.] |
---|
| 8 | |
---|
| 9 | Description [Command interface for the truesim package. This package |
---|
| 10 | implements delay-based simulation of a combinational circuit in addition |
---|
| 11 | to zero-delay simulation. The 'sim' package does zero-delay simulation, |
---|
| 12 | but handles both combinational and sequential circuits. This package |
---|
| 13 | can take as input circuits described in BLIF format only. |
---|
| 14 | |
---|
| 15 | In delay-based simulation each node of the network has a certain |
---|
| 16 | amount of propagation delay through it. The delay and load for each node |
---|
| 17 | of the circuit can be specified by the user. In the absence of delay |
---|
| 18 | values, the fanout count of the node is assumed to be the delay. In |
---|
| 19 | this implementation the delay values do not have units. For example, |
---|
| 20 | a node with 2 fanouts has a delay of 2, an node with fanout 4 has |
---|
| 21 | delay of 4, etc. Primary outputs are assumed to have a delay of 1, |
---|
| 22 | unlesss specfied otherwise. Load values are used by other |
---|
| 23 | applications to compute power dissipation (by using the node switching |
---|
| 24 | information via simulation.) |
---|
| 25 | |
---|
| 26 | Boolean vectors can be specified for the primary inputs of the circuit. |
---|
| 27 | Alternatively, bit vectors can also be generated randomly. The bit |
---|
| 28 | vectors are applied to the circuit one at a time. The effects of one |
---|
| 29 | pattern (a bit-vector for the primary inputs) are propagated through |
---|
| 30 | the circuit and subsequent patterns are applied only after all the |
---|
| 31 | signals in the circuit have settled.] |
---|
| 32 | |
---|
| 33 | Author [Balakrishna Kumthekar <kumtheka@colorado.edu>] |
---|
| 34 | |
---|
| 35 | Copyright [This file was created at the University of Colorado at |
---|
| 36 | Boulder. The University of Colorado at Boulder makes no warranty about |
---|
| 37 | the suitability of this software for any purpose. It is presented on |
---|
| 38 | an AS IS basis.] |
---|
| 39 | |
---|
| 40 | ******************************************************************************/ |
---|
| 41 | |
---|
| 42 | #include "truesimInt.h" |
---|
| 43 | |
---|
| 44 | /*---------------------------------------------------------------------------*/ |
---|
| 45 | /* Constant declarations */ |
---|
| 46 | /*---------------------------------------------------------------------------*/ |
---|
| 47 | |
---|
| 48 | #define DEFAULT_NUM_PATTERNS 1000 |
---|
| 49 | /*---------------------------------------------------------------------------*/ |
---|
| 50 | /* Type declarations */ |
---|
| 51 | /*---------------------------------------------------------------------------*/ |
---|
| 52 | |
---|
| 53 | |
---|
| 54 | /*---------------------------------------------------------------------------*/ |
---|
| 55 | /* Structure declarations */ |
---|
| 56 | /*---------------------------------------------------------------------------*/ |
---|
| 57 | |
---|
| 58 | |
---|
| 59 | /*---------------------------------------------------------------------------*/ |
---|
| 60 | /* Variable declarations */ |
---|
| 61 | /*---------------------------------------------------------------------------*/ |
---|
| 62 | |
---|
| 63 | static jmp_buf timeOutEnv; |
---|
| 64 | |
---|
| 65 | /* Global variable used within truesim package */ |
---|
| 66 | int createdPart; |
---|
| 67 | int truesimRptHeader; |
---|
| 68 | int truesimVerbose; |
---|
| 69 | |
---|
| 70 | /**AutomaticStart*************************************************************/ |
---|
| 71 | |
---|
| 72 | /*---------------------------------------------------------------------------*/ |
---|
| 73 | /* Static function prototypes */ |
---|
| 74 | /*---------------------------------------------------------------------------*/ |
---|
| 75 | |
---|
| 76 | static int CommandTruesim(Hrc_Manager_t **hmgr, int argc, char **argv); |
---|
| 77 | static void TimeOutHandle(void); |
---|
| 78 | static int TestIsNetworkMultipleValued(Ntk_Network_t *network); |
---|
| 79 | |
---|
| 80 | /**AutomaticEnd***************************************************************/ |
---|
| 81 | |
---|
| 82 | |
---|
| 83 | /*---------------------------------------------------------------------------*/ |
---|
| 84 | /* Definition of exported functions */ |
---|
| 85 | /*---------------------------------------------------------------------------*/ |
---|
| 86 | |
---|
| 87 | /**Function******************************************************************** |
---|
| 88 | |
---|
| 89 | Synopsis [This function initializes the truesim package.] |
---|
| 90 | |
---|
| 91 | SideEffects [None] |
---|
| 92 | |
---|
| 93 | SeeAlso [Truesim_End] |
---|
| 94 | |
---|
| 95 | ******************************************************************************/ |
---|
| 96 | void |
---|
| 97 | Truesim_Init(void) |
---|
| 98 | { |
---|
| 99 | Cmd_CommandAdd("truesim", CommandTruesim, 0); |
---|
| 100 | } |
---|
| 101 | |
---|
| 102 | /**Function******************************************************************** |
---|
| 103 | |
---|
| 104 | Synopsis [This function ends the truesim package.] |
---|
| 105 | |
---|
| 106 | SideEffects [None] |
---|
| 107 | |
---|
| 108 | SeeAlso [Truesim_Init] |
---|
| 109 | |
---|
| 110 | ******************************************************************************/ |
---|
| 111 | void |
---|
| 112 | Truesim_End(void) |
---|
| 113 | { |
---|
| 114 | |
---|
| 115 | } /* End of Truesim_End */ |
---|
| 116 | |
---|
| 117 | |
---|
| 118 | /*---------------------------------------------------------------------------*/ |
---|
| 119 | /* Definition of internal functions */ |
---|
| 120 | /*---------------------------------------------------------------------------*/ |
---|
| 121 | |
---|
| 122 | |
---|
| 123 | /*---------------------------------------------------------------------------*/ |
---|
| 124 | /* Definition of static functions */ |
---|
| 125 | /*---------------------------------------------------------------------------*/ |
---|
| 126 | |
---|
| 127 | /**Function******************************************************************** |
---|
| 128 | |
---|
| 129 | Synopsis [Implements the truesim command.] |
---|
| 130 | |
---|
| 131 | CommandName [truesim] |
---|
| 132 | |
---|
| 133 | CommandSynopsis [Simulate the flattened network] |
---|
| 134 | |
---|
| 135 | CommandArguments [\[ -D <filename> \] \[ -d \] |
---|
| 136 | \[ -f <filename> \] \[ -g <filename> \] \[ -h \] |
---|
| 137 | \[ -n <N> \] \[ -p <filename> \] \[ -r <N> \] |
---|
| 138 | \[ -t <time> \] \[ -v <N> \]] |
---|
| 139 | |
---|
| 140 | CommandDescription [Simulates a network with a set of input |
---|
| 141 | vectors. Before calling this command, the user should create a partition |
---|
| 142 | (using the command <tt>build_partition_mdds</tt>). The simulation |
---|
| 143 | vectors can be provided by the user (using -f vectors_file), or |
---|
| 144 | generated randomly. <p> |
---|
| 145 | |
---|
| 146 | Command options:<p> |
---|
| 147 | |
---|
| 148 | <dl> |
---|
| 149 | <dt>-D <filename> |
---|
| 150 | <dd> File to dump randomly generated vectors. Primary input |
---|
| 151 | probability file SHOULD be specified with -p option. |
---|
| 152 | |
---|
| 153 | |
---|
| 154 | <dt>-d |
---|
| 155 | <dd>Perform event-driven true delay simulation. The fanout count of |
---|
| 156 | the nodes is used as an estimate for the node delay. Primary inputs |
---|
| 157 | are assumed to have arrival times of zero. |
---|
| 158 | |
---|
| 159 | |
---|
| 160 | <dt>-f <filename> |
---|
| 161 | <dd> File containing simulation vectors. The format is simple but |
---|
| 162 | strict and hence, few checks are made. The file format is as below: |
---|
| 163 | |
---|
| 164 | <p>.i <code>c n d o e p f q g r h s i t j u k a l b m</code><br> |
---|
| 165 | .s <br> |
---|
| 166 | 0 1 1 1 1 1 0 1 1 1 1 1 1 1 1 1 0 1 1 1 1 ; <br> |
---|
| 167 | 0 1 1 0 0 0 0 1 0 1 1 0 1 1 1 1 0 0 0 0 1 ; <br> |
---|
| 168 | 0 0 1 0 0 0 0 1 0 1 0 0 0 1 0 1 0 0 0 0 1 ; <br> |
---|
| 169 | 0 1 1 0 0 0 0 1 1 1 1 1 1 1 1 1 0 1 0 0 1 ; <br> |
---|
| 170 | |
---|
| 171 | <p> The .i statement specifies the primary inputs of the network. The |
---|
| 172 | patterns start after .s key word. Each vector is a space separated list |
---|
| 173 | of bits and ends in a semi-colon. The length of any vector should be |
---|
| 174 | equal to the number of signals specified in the .i statement. A line |
---|
| 175 | starting with # is a comment. <p> |
---|
| 176 | |
---|
| 177 | |
---|
| 178 | <dt>-g <filename> |
---|
| 179 | <dd> File to output random probabilities for primary inputs. Use this |
---|
| 180 | option ONLY to produce a vector of signal probabilities for primary |
---|
| 181 | inputs. This option does not proceed with simulation. |
---|
| 182 | |
---|
| 183 | |
---|
| 184 | <dt>-h |
---|
| 185 | <dd>Print a help message that details all options. |
---|
| 186 | |
---|
| 187 | |
---|
| 188 | <dt> -n <N> |
---|
| 189 | <dd> Number of patterns to simulate. The default is 1000. Use this |
---|
| 190 | option ONLY with -p option. |
---|
| 191 | |
---|
| 192 | |
---|
| 193 | <dt>-p <filename> |
---|
| 194 | <dd> File containing primary input probabilities. The format is as |
---|
| 195 | shown below: |
---|
| 196 | |
---|
| 197 | <p> |
---|
| 198 | PI_Name1 0.67 <br> |
---|
| 199 | PI_Name2 0.45 <br> |
---|
| 200 | |
---|
| 201 | |
---|
| 202 | <dt>-r <N> |
---|
| 203 | <dd> Print PI/PO names after every N patterns simulated, for better |
---|
| 204 | readability of simulation output. This option is effective only when |
---|
| 205 | the verbosity flag is on. |
---|
| 206 | |
---|
| 207 | <dt>-T <filename> |
---|
| 208 | <dd> File containing node delay and load values. The file format is |
---|
| 209 | as shown below: |
---|
| 210 | |
---|
| 211 | <p> |
---|
| 212 | node1 delay1 load1 <br> |
---|
| 213 | node2 delay2 load2 <br> |
---|
| 214 | |
---|
| 215 | <p> The delay vaues are assumed as specified in a common unit. The same |
---|
| 216 | is true for load values too. |
---|
| 217 | |
---|
| 218 | |
---|
| 219 | <dt>-t <time> |
---|
| 220 | <dd> Time in seconds allowed to finish the simulation. The default |
---|
| 221 | is no limit. |
---|
| 222 | |
---|
| 223 | |
---|
| 224 | <dt>-v <N> |
---|
| 225 | <dd> Specify verbosity level, N. |
---|
| 226 | </dl> <p>] |
---|
| 227 | |
---|
| 228 | SideEffects [] |
---|
| 229 | |
---|
| 230 | ******************************************************************************/ |
---|
| 231 | static int |
---|
| 232 | CommandTruesim( |
---|
| 233 | Hrc_Manager_t **hmgr, |
---|
| 234 | int argc, |
---|
| 235 | char **argv) |
---|
| 236 | { |
---|
| 237 | Ntk_Network_t *network = NIL(Ntk_Network_t); |
---|
| 238 | graph_t *partition; |
---|
| 239 | boolean trueDelay; |
---|
| 240 | int genVectors,N,status; |
---|
| 241 | int c; /* For scanning command line arguments */ |
---|
| 242 | long timeOutPeriod,initialTime,finalTime; |
---|
| 243 | char *probFile,*simFile,*probGenFile,*dumpFile; |
---|
| 244 | char *delayFile; |
---|
| 245 | FILE *fp = NIL(FILE);; |
---|
| 246 | |
---|
| 247 | /* These are the default values. */ |
---|
| 248 | createdPart = 0; /* =1 when partiton is created by the command */ |
---|
| 249 | trueDelay = FALSE; /* Use zero-delay simulation by default */ |
---|
| 250 | timeOutPeriod = 0; /* Unlimited time */ |
---|
| 251 | genVectors = -1; /* Do not generate bit-vectors for simulation */ |
---|
| 252 | N = -1; /* Number of patterns to simulate */ |
---|
| 253 | probFile = NIL(char); /* File with probability values for PI */ |
---|
| 254 | simFile = NIL(char); /* Simulation bit-vector file */ |
---|
| 255 | probGenFile = NIL(char); /* File with prob. values for PI; used during |
---|
| 256 | * bit-vector generation */ |
---|
| 257 | dumpFile = NIL(char); /* File to dump generated bit-vectors */ |
---|
| 258 | delayFile = NIL(char); /* File with delay vaules for nodes of the |
---|
| 259 | * circuit */ |
---|
| 260 | truesimVerbose = 0; /* Verbosity level */ |
---|
| 261 | truesimRptHeader = -1; /* Print PI/PO names while printing simulation |
---|
| 262 | * results */ |
---|
| 263 | |
---|
| 264 | if (bdd_get_package_name() != CUDD) { |
---|
| 265 | (void) fprintf(vis_stderr, |
---|
| 266 | "** truesim error: The truesim package can be used only with CUDD package\n"); |
---|
| 267 | (void) fprintf(vis_stderr, |
---|
| 268 | "** truesim error: Please link with CUDD package\n"); |
---|
| 269 | return 0; |
---|
| 270 | } |
---|
| 271 | |
---|
| 272 | util_getopt_reset(); |
---|
| 273 | |
---|
| 274 | while((c = util_getopt(argc, argv, "D:df:g:hn:p:r:T:t:v:")) != EOF) { |
---|
| 275 | switch(c) { |
---|
| 276 | case 'D': |
---|
| 277 | if (!util_optarg) { |
---|
| 278 | (void) fprintf(vis_stderr, |
---|
| 279 | "** truesim error: File to output pattern vectors not specified.\n"); |
---|
| 280 | goto usage; |
---|
| 281 | } |
---|
| 282 | dumpFile = util_strsav(util_optarg); |
---|
| 283 | break; |
---|
| 284 | case 'd': |
---|
| 285 | trueDelay = TRUE; |
---|
| 286 | break; |
---|
| 287 | case 'f': |
---|
| 288 | if (!util_optarg) { |
---|
| 289 | (void) fprintf(vis_stderr, |
---|
| 290 | "** truesim error: Simulation file not specified.\n"); |
---|
| 291 | goto usage; |
---|
| 292 | } else { |
---|
| 293 | simFile = util_strsav(util_optarg); |
---|
| 294 | if ((fp = Cmd_FileOpen(simFile,"r",NIL(char *),1)) == NIL(FILE)) { |
---|
| 295 | (void) fprintf(vis_stderr, |
---|
| 296 | "** truesim error: Could not open %s for reading.\n", |
---|
| 297 | simFile); |
---|
| 298 | goto endgame; |
---|
| 299 | } else { |
---|
| 300 | fclose(fp); |
---|
| 301 | } |
---|
| 302 | /* Stop generation of vectors, in case -p is also used with -f */ |
---|
| 303 | N = -1; |
---|
| 304 | genVectors = 0; |
---|
| 305 | if (probFile) { |
---|
| 306 | FREE(probFile); |
---|
| 307 | probFile = NIL(char); |
---|
| 308 | } |
---|
| 309 | } |
---|
| 310 | break; |
---|
| 311 | case 'g': |
---|
| 312 | if (!util_optarg) { |
---|
| 313 | (void) fprintf(vis_stderr, |
---|
| 314 | "** truesim error: File to output input probs. not specified.\n"); |
---|
| 315 | goto usage; |
---|
| 316 | } |
---|
| 317 | probGenFile = util_strsav(util_optarg); |
---|
| 318 | break; |
---|
| 319 | case 'h': |
---|
| 320 | goto usage; |
---|
| 321 | case 'n': |
---|
| 322 | if (genVectors != 0) { |
---|
| 323 | N = atoi(util_optarg); |
---|
| 324 | genVectors = 1; |
---|
| 325 | } else { |
---|
| 326 | (void) fprintf(vis_stderr, |
---|
| 327 | "** truesim warning: Simulation file already specified.\n"); |
---|
| 328 | (void) fprintf(vis_stderr, |
---|
| 329 | "** truesim warning: Ignoring -n option.\n"); |
---|
| 330 | } |
---|
| 331 | break; |
---|
| 332 | case 'p': |
---|
| 333 | if (genVectors != 0) { |
---|
| 334 | if (!util_optarg) { |
---|
| 335 | (void) fprintf(vis_stderr, |
---|
| 336 | "** truesim error: Probability file not specified.\n"); |
---|
| 337 | goto usage; |
---|
| 338 | } else { |
---|
| 339 | probFile = util_strsav(util_optarg); |
---|
| 340 | if ((fp = Cmd_FileOpen(probFile,"r",NIL(char *),1)) == NIL(FILE)) { |
---|
| 341 | (void) fprintf(vis_stderr, |
---|
| 342 | "** truesim error: Could not open %s for reading.\n", |
---|
| 343 | probFile); |
---|
| 344 | goto endgame; |
---|
| 345 | } else { |
---|
| 346 | fclose(fp); |
---|
| 347 | } |
---|
| 348 | } |
---|
| 349 | genVectors = 1; |
---|
| 350 | } else { |
---|
| 351 | (void) fprintf(vis_stderr, |
---|
| 352 | "** truesim warning: Simulation file already specified.\n"); |
---|
| 353 | (void) fprintf(vis_stderr, |
---|
| 354 | "** truesim warning: Ignoring -p option.\n"); |
---|
| 355 | } |
---|
| 356 | break; |
---|
| 357 | case 'r': |
---|
| 358 | truesimRptHeader = atoi(util_optarg); |
---|
| 359 | break; |
---|
| 360 | case 'T': |
---|
| 361 | if (!util_optarg) { |
---|
| 362 | (void) fprintf(vis_stderr, |
---|
| 363 | "** truesim error: Delay file not specified.\n"); |
---|
| 364 | goto usage; |
---|
| 365 | } else { |
---|
| 366 | delayFile = util_strsav(util_optarg); |
---|
| 367 | if ((fp = Cmd_FileOpen(delayFile,"r",NIL(char *),1)) == NIL(FILE)) { |
---|
| 368 | (void) fprintf(vis_stderr, |
---|
| 369 | "** truesim error: Could not open %s for reading.\n", |
---|
| 370 | delayFile); |
---|
| 371 | goto endgame; |
---|
| 372 | } else { |
---|
| 373 | fclose(fp); |
---|
| 374 | } |
---|
| 375 | } |
---|
| 376 | break; |
---|
| 377 | case 't': |
---|
| 378 | timeOutPeriod = atoi(util_optarg); |
---|
| 379 | break; |
---|
| 380 | case 'v': |
---|
| 381 | truesimVerbose = atoi(util_optarg); |
---|
| 382 | break; |
---|
| 383 | default: |
---|
| 384 | goto usage; |
---|
| 385 | } |
---|
| 386 | } |
---|
| 387 | |
---|
| 388 | if(Hrc_ManagerReadCurrentNode(*hmgr) == NIL(Hrc_Node_t)) { |
---|
| 389 | (void) fprintf(vis_stderr,"** truesim error: The hierarchy manager is empty."); |
---|
| 390 | (void) fprintf(vis_stderr," Read in design.\n"); |
---|
| 391 | goto endgame; |
---|
| 392 | } |
---|
| 393 | |
---|
| 394 | network = (Ntk_Network_t *) |
---|
| 395 | Hrc_NodeReadApplInfo(Hrc_ManagerReadCurrentNode(*hmgr), |
---|
| 396 | NTK_HRC_NODE_APPL_KEY); |
---|
| 397 | |
---|
| 398 | if(network == NIL(Ntk_Network_t)) { |
---|
| 399 | (void) fprintf(vis_stderr,"** truesim error: There is no network. "); |
---|
| 400 | (void) fprintf(vis_stderr,"Use flatten_hierarchy.\n"); |
---|
| 401 | goto endgame; |
---|
| 402 | } |
---|
| 403 | |
---|
| 404 | /* Check if the current network has signals with multiple values. */ |
---|
| 405 | if (TestIsNetworkMultipleValued(network)) { |
---|
| 406 | (void) fprintf(vis_stderr,"** truesim error: Circuit has multiple valued variables.\n"); |
---|
| 407 | (void) fprintf(vis_stderr,"** truesim error: This algorithm applies to boolean signals only.\n"); |
---|
| 408 | goto endgame; |
---|
| 409 | } |
---|
| 410 | |
---|
| 411 | if(Ntk_NetworkReadNumPrimaryInputs(network) != |
---|
| 412 | Ntk_NetworkReadNumInputs(network)) { |
---|
| 413 | (void) fprintf(vis_stderr,"** truesim error: This algorithm applies only for circuits descrbied in BLIF format.\n"); |
---|
| 414 | goto endgame; |
---|
| 415 | } |
---|
| 416 | |
---|
| 417 | /* Generate a file with random values for primary inputs and return. No |
---|
| 418 | simulation is performed. */ |
---|
| 419 | if (probGenFile) { |
---|
| 420 | Truesim_GeneratePrimaryInputProbs(network,probGenFile); |
---|
| 421 | FREE(probGenFile); |
---|
| 422 | if (probFile) |
---|
| 423 | FREE(probFile); |
---|
| 424 | if (simFile) |
---|
| 425 | FREE(simFile); |
---|
| 426 | if (dumpFile) |
---|
| 427 | FREE(dumpFile); |
---|
| 428 | if (delayFile) |
---|
| 429 | FREE(delayFile); |
---|
| 430 | return 0; |
---|
| 431 | } |
---|
| 432 | |
---|
| 433 | /* Make sure that we either generate random vectors or we are |
---|
| 434 | supplied with simulation vectors */ |
---|
| 435 | if (genVectors == -1) { |
---|
| 436 | (void) fprintf(vis_stderr, |
---|
| 437 | "** truesim error: Neither simulation vector file nor "); |
---|
| 438 | (void) fprintf(vis_stderr, |
---|
| 439 | "PI probabilities provided.\n"); |
---|
| 440 | (void) fprintf(vis_stderr, |
---|
| 441 | "** truesim error: No simulation will be performed.\n"); |
---|
| 442 | goto endgame; |
---|
| 443 | } |
---|
| 444 | |
---|
| 445 | if (dumpFile && !genVectors) { |
---|
| 446 | if (!simFile) { |
---|
| 447 | (void) fprintf(vis_stderr, |
---|
| 448 | "** truesim error: PI probability file not specified.\n"); |
---|
| 449 | (void) fprintf(vis_stderr, |
---|
| 450 | "** truesim error: Use -p option.\n"); |
---|
| 451 | (void) fprintf(vis_stderr, |
---|
| 452 | "** truesim error: No simulation will be performed.\n"); |
---|
| 453 | goto endgame; |
---|
| 454 | } else { |
---|
| 455 | (void) fprintf(vis_stderr, |
---|
| 456 | "** truesim warning: Simulation file %s specified.\n", |
---|
| 457 | simFile); |
---|
| 458 | (void) fprintf(vis_stderr, |
---|
| 459 | "** truesim warning: Ignoring dump file %s\n",dumpFile); |
---|
| 460 | } |
---|
| 461 | } |
---|
| 462 | |
---|
| 463 | /* Make sure N is specified or a default value is used */ |
---|
| 464 | if (N == -1 && genVectors == 1) { |
---|
| 465 | (void) fprintf(vis_stderr, |
---|
| 466 | "** truesim warning: Number of patterns to be simulated is not specified.\n"); |
---|
| 467 | (void) fprintf(vis_stderr, |
---|
| 468 | "Assuming N = 1000 patterns to be simulated.\n"); |
---|
| 469 | N = DEFAULT_NUM_PATTERNS; |
---|
| 470 | } |
---|
| 471 | |
---|
| 472 | /* Access a 'total' partition */ |
---|
| 473 | partition = (graph_t *) Ntk_NetworkReadApplInfo(network, |
---|
| 474 | PART_NETWORK_APPL_KEY); |
---|
| 475 | createdPart = 0; /* Using partition of the network. */ |
---|
| 476 | if (partition == NIL(graph_t) || |
---|
| 477 | (Part_PartitionReadMethod(partition) != Part_Total_c)) { |
---|
| 478 | partition = Part_NetworkCreatePartition(network, |
---|
| 479 | NIL(Hrc_Node_t), |
---|
| 480 | "dummy", (lsList) 0, |
---|
| 481 | (lsList) 0, NIL(mdd_t), |
---|
| 482 | Part_Total_c, |
---|
| 483 | (lsList) 0, |
---|
| 484 | FALSE, FALSE, TRUE); |
---|
| 485 | if (partition == NIL(graph_t)) { |
---|
| 486 | (void) fprintf(vis_stderr,"** truesim error: Could not create a partition.\n"); |
---|
| 487 | goto endgame; |
---|
| 488 | } |
---|
| 489 | Ntk_NetworkAddApplInfo(network,PART_NETWORK_APPL_KEY, |
---|
| 490 | (Ntk_ApplInfoFreeFn)Part_PartitionFreeCallback, |
---|
| 491 | (void *)partition); |
---|
| 492 | createdPart = 1; /* Using new partition */ |
---|
| 493 | } |
---|
| 494 | |
---|
| 495 | /* Start the timer.*/ |
---|
| 496 | if (timeOutPeriod > 0){ |
---|
| 497 | (void) signal(SIGALRM, (void(*)(int))TimeOutHandle); |
---|
| 498 | (void) alarm(timeOutPeriod); |
---|
| 499 | if (setjmp(timeOutEnv) > 0) { |
---|
| 500 | (void) fprintf(vis_stderr, "** truesim warning: Timeout occurred after "); |
---|
| 501 | (void) fprintf(vis_stderr, "%ld seconds.\n", timeOutPeriod); |
---|
| 502 | alarm(0); |
---|
| 503 | goto endgame; |
---|
| 504 | } |
---|
| 505 | } |
---|
| 506 | |
---|
| 507 | initialTime = util_cpu_time(); |
---|
| 508 | status = TruesimSimulateNetwork(network,simFile,probFile,delayFile, |
---|
| 509 | dumpFile,trueDelay,genVectors,N); |
---|
| 510 | finalTime = util_cpu_time(); |
---|
| 511 | if(status) { |
---|
| 512 | (void) fprintf(vis_stdout, "%-20s%10ld\n", "** truesim info: analysis time =", |
---|
| 513 | (finalTime-initialTime)/1000); |
---|
| 514 | } |
---|
| 515 | else { |
---|
| 516 | (void) fprintf(vis_stdout, "** truesim error: Simulation was not successful.\n"); |
---|
| 517 | } |
---|
| 518 | |
---|
| 519 | alarm(0); |
---|
| 520 | /* Clean up */ |
---|
| 521 | if (probGenFile) |
---|
| 522 | FREE(probGenFile); |
---|
| 523 | if (probFile) |
---|
| 524 | FREE(probFile); |
---|
| 525 | if (simFile) |
---|
| 526 | FREE(simFile); |
---|
| 527 | if (dumpFile) |
---|
| 528 | FREE(dumpFile); |
---|
| 529 | if (delayFile) |
---|
| 530 | FREE(delayFile); |
---|
| 531 | return 0; /* normal exit */ |
---|
| 532 | |
---|
| 533 | endgame: |
---|
| 534 | /* Clean up */ |
---|
| 535 | if (probGenFile) |
---|
| 536 | FREE(probGenFile); |
---|
| 537 | if (probFile) |
---|
| 538 | FREE(probFile); |
---|
| 539 | if (simFile) |
---|
| 540 | FREE(simFile); |
---|
| 541 | if (dumpFile) |
---|
| 542 | FREE(dumpFile); |
---|
| 543 | if (delayFile) |
---|
| 544 | FREE(delayFile); |
---|
| 545 | |
---|
| 546 | if (createdPart) |
---|
| 547 | Ntk_NetworkFreeApplInfo(network,PART_NETWORK_APPL_KEY); |
---|
| 548 | |
---|
| 549 | return 1; /* Error exit */ |
---|
| 550 | |
---|
| 551 | usage: |
---|
| 552 | |
---|
| 553 | (void) fprintf(vis_stderr, "\nusage: Also see 'help truesim' for more details.\n\n"); |
---|
| 554 | (void) fprintf(vis_stderr, " -D <filename>\tFile to dump randomly generated pattern vectors.\n"); |
---|
| 555 | (void) fprintf(vis_stderr, " \t\tPrimary input probability file SHOULD be specified with \n"); |
---|
| 556 | (void) fprintf(vis_stderr, " \t\t-p option.\n\n"); |
---|
| 557 | (void) fprintf(vis_stderr, " -d \t\tPerform true delay simulation.\n\n"); |
---|
| 558 | (void) fprintf(vis_stderr, " -f <filename>\tFile containing simulation vectors.\n\n"); |
---|
| 559 | (void) fprintf(vis_stderr, " -g <filename>\tFile to output random probabilities for PI \n"); |
---|
| 560 | (void) fprintf(vis_stderr, " \t\tUse this option ONLY to produce a vector of \n"); |
---|
| 561 | (void) fprintf(vis_stderr, " \t\tprobability values for PI. No simulation is performed. \n\n"); |
---|
| 562 | (void) fprintf(vis_stderr, " -h \t\tCommand usage.\n\n"); |
---|
| 563 | (void) fprintf(vis_stderr, " -n <N> \t\tNumber of patterns to simulate. Default is 1000.\n"); |
---|
| 564 | (void) fprintf(vis_stderr, " \t\tShould ONLY be used with -p option.\n\n"); |
---|
| 565 | (void) fprintf(vis_stderr, " -p <filename>\tFile containing PI probabilities.\n"); |
---|
| 566 | (void) fprintf(vis_stderr, " \t\tSee help for file format.\n\n"); |
---|
| 567 | (void) fprintf(vis_stderr, " -r <N> \t\tPrint the node name header ever N iterations.\n"); |
---|
| 568 | (void) fprintf(vis_stderr, " \t\tThis is effective only when verbosity flag is on.\n\n"); |
---|
| 569 | (void) fprintf(vis_stderr, " -T <filename>\tFile containing node delay and load values.\n"); |
---|
| 570 | (void) fprintf(vis_stderr, " \t\tSee help for file format.\n\n"); |
---|
| 571 | (void) fprintf(vis_stderr, " -t <time> \t\tTime in seconds allowed to finish the simulation.\n\n"); |
---|
| 572 | (void) fprintf(vis_stderr, " -v <N> \t\tVerbosity level.\n"); |
---|
| 573 | |
---|
| 574 | return 1; /* error exit */ |
---|
| 575 | } |
---|
| 576 | |
---|
| 577 | /**Function******************************************************************** |
---|
| 578 | |
---|
| 579 | Synopsis [Handle function for timeout.] |
---|
| 580 | |
---|
| 581 | Description [This function is called when the time out occurs.] |
---|
| 582 | |
---|
| 583 | SideEffects [] |
---|
| 584 | |
---|
| 585 | ******************************************************************************/ |
---|
| 586 | static void |
---|
| 587 | TimeOutHandle(void) |
---|
| 588 | { |
---|
| 589 | longjmp(timeOutEnv, 1); |
---|
| 590 | } |
---|
| 591 | |
---|
| 592 | |
---|
| 593 | /**Function******************************************************************** |
---|
| 594 | |
---|
| 595 | Synopsis [Checks whether the network has multiple valued signals.] |
---|
| 596 | |
---|
| 597 | Description [Checks whether the network has multiple valued |
---|
| 598 | signals. Returns 1 if true, else 0.] |
---|
| 599 | |
---|
| 600 | SideEffects [None] |
---|
| 601 | |
---|
| 602 | SeeAlso [] |
---|
| 603 | |
---|
| 604 | ******************************************************************************/ |
---|
| 605 | static int |
---|
| 606 | TestIsNetworkMultipleValued(Ntk_Network_t *network) |
---|
| 607 | { |
---|
| 608 | Ntk_Node_t *node; |
---|
| 609 | lsGen gen; |
---|
| 610 | Var_Variable_t *var; |
---|
| 611 | int numValues; |
---|
| 612 | |
---|
| 613 | Ntk_NetworkForEachNode(network,gen,node) { |
---|
| 614 | var = Ntk_NodeReadVariable(node); |
---|
| 615 | numValues = Var_VariableReadNumValues(var); |
---|
| 616 | if (numValues > 2) |
---|
| 617 | return 1; |
---|
| 618 | } |
---|
| 619 | return 0; |
---|
| 620 | } |
---|