177{
179 Vec_Ptr_t * vNamesIn = NULL, * vNamesOut = NULL, * vNamesRegIn = NULL, * vNamesRegOut = NULL, * vNamesNode = NULL;
180 Vec_Int_t * vLits = NULL, * vPoTypes = NULL;
181 Vec_Int_t * vNodes, * vDrivers, * vInits = NULL;
182 int iObj, iNode0, iNode1, fHieOnly = 0;
183 int nTotal, nInputs, nOutputs, nLatches, nAnds, i;
184 int nBad = 0, nConstr = 0, nJust = 0, nFair = 0;
185 unsigned char * pDrivers, * pSymbols, * pCur;
186 unsigned uLit0, uLit1, uLit;
187
188
189 pCur = (unsigned char *)pContents; while ( *pCur != ' ' ) pCur++; pCur++;
190
191 nTotal = atoi( (
const char *)pCur );
while ( *pCur !=
' ' ) pCur++; pCur++;
192
193 nInputs = atoi( (const char *)pCur ); while ( *pCur != ' ' ) pCur++; pCur++;
194
195 nLatches = atoi( (const char *)pCur ); while ( *pCur != ' ' ) pCur++; pCur++;
196
197 nOutputs = atoi( (const char *)pCur ); while ( *pCur != ' ' ) pCur++; pCur++;
198
199 nAnds = atoi( (const char *)pCur ); while ( *pCur != ' ' && *pCur != '\n' ) pCur++;
200 if ( *pCur == ' ' )
201 {
202
203
204 pCur++;
205 nBad = atoi( (const char *)pCur ); while ( *pCur != ' ' && *pCur != '\n' ) pCur++;
206 nOutputs += nBad;
207 }
208 if ( *pCur == ' ' )
209 {
210
211 pCur++;
212 nConstr = atoi( (const char *)pCur ); while ( *pCur != ' ' && *pCur != '\n' ) pCur++;
213 nOutputs += nConstr;
214 }
215 if ( *pCur == ' ' )
216 {
217
218 pCur++;
219 nJust = atoi( (const char *)pCur ); while ( *pCur != ' ' && *pCur != '\n' ) pCur++;
220 nOutputs += nJust;
221 }
222 if ( *pCur == ' ' )
223 {
224
225 pCur++;
226 nFair = atoi( (const char *)pCur ); while ( *pCur != ' ' && *pCur != '\n' ) pCur++;
227 nOutputs += nFair;
228 }
229 if ( *pCur != '\n' )
230 {
231 fprintf( stdout, "The parameter line is in a wrong format.\n" );
232 return NULL;
233 }
234 pCur++;
235
236
237 if (
nTotal != nInputs + nLatches + nAnds )
238 {
239 fprintf( stdout, "The number of objects does not match.\n" );
240 return NULL;
241 }
242 if ( nJust || nFair )
243 {
244 fprintf( stdout, "Reading AIGER files with liveness properties is currently not supported.\n" );
245 return NULL;
246 }
247
248 if ( nConstr )
249 {
250 if ( nConstr == 1 )
251 fprintf( stdout, "Warning: The last output is interpreted as a constraint.\n" );
252 else
253 fprintf( stdout, "Warning: The last %d outputs are interpreted as constraints.\n", nConstr );
254 }
255
256
260
261
262 vNodes = Vec_IntAlloc( 1 +
nTotal );
263 Vec_IntPush( vNodes, 0 );
264
265
266 for ( i = 0; i < nInputs + nLatches; i++ )
267 {
268 iObj = Gia_ManAppendCi(pNew);
269 Vec_IntPush( vNodes, iObj );
270 }
271
272
273 pDrivers = pCur;
274 if ( pContents[3] == ' ' )
275 {
276
277 for ( i = 0; i < nLatches + nOutputs; )
278 if ( *pCur++ == '\n' )
279 i++;
280 }
281 else
282 {
284 }
285
286
287 if ( !fGiaSimple && !fSkipStrash )
289 for ( i = 0; i < nAnds; i++ )
290 {
291 uLit = ((i + 1 + nInputs + nLatches) << 1);
292 uLit1 = uLit - Gia_AigerReadUnsigned( &pCur );
293 uLit0 = uLit1 - Gia_AigerReadUnsigned( &pCur );
294
295 iNode0 = Abc_LitNotCond( Vec_IntEntry(vNodes, uLit0 >> 1), uLit0 & 1 );
296 iNode1 = Abc_LitNotCond( Vec_IntEntry(vNodes, uLit1 >> 1), uLit1 & 1 );
297 assert( Vec_IntSize(vNodes) == i + 1 + nInputs + nLatches );
298 if ( !fGiaSimple && fSkipStrash )
299 {
300 if ( iNode0 == iNode1 )
301 Vec_IntPush( vNodes, Gia_ManAppendBuf(pNew, iNode0) );
302 else
303 Vec_IntPush( vNodes, Gia_ManAppendAnd(pNew, iNode0, iNode1) );
304 }
305 else
307 }
308 if ( !fGiaSimple && !fSkipStrash )
310
311
312 pSymbols = pCur;
313
314
315 vDrivers = Vec_IntAlloc( nLatches + nOutputs );
316 if ( pContents[3] == ' ' )
317 {
318 vInits = Vec_IntAlloc( nLatches );
319 pCur = pDrivers;
320 for ( i = 0; i < nLatches; i++ )
321 {
322 uLit0 = atoi( (char *)pCur );
323 while ( *pCur != ' ' && *pCur != '\n' )
324 pCur++;
325 if ( *pCur == ' ' )
326 {
327 pCur++;
328 Vec_IntPush( vInits, atoi( (char *)pCur ) );
329 while ( *pCur++ != '\n' );
330 }
331 else
332 {
333 pCur++;
334 Vec_IntPush( vInits, 0 );
335 }
336 iNode0 = Abc_LitNotCond( Vec_IntEntry(vNodes, uLit0 >> 1), (uLit0 & 1) );
337 Vec_IntPush( vDrivers, iNode0 );
338 }
339
340 for ( i = 0; i < nOutputs; i++ )
341 {
342 uLit0 = atoi( (char *)pCur ); while ( *pCur++ != '\n' );
343 iNode0 = Abc_LitNotCond( Vec_IntEntry(vNodes, uLit0 >> 1), (uLit0 & 1) );
344 Vec_IntPush( vDrivers, iNode0 );
345 }
346
347 }
348 else
349 {
350
351 for ( i = 0; i < nLatches; i++ )
352 {
353 uLit0 = Vec_IntEntry( vLits, i );
354 iNode0 = Abc_LitNotCond( Vec_IntEntry(vNodes, uLit0 >> 1), (uLit0 & 1) );
355 Vec_IntPush( vDrivers, iNode0 );
356 }
357
358 for ( i = 0; i < nOutputs; i++ )
359 {
360 uLit0 = Vec_IntEntry( vLits, i+nLatches );
361 iNode0 = Abc_LitNotCond( Vec_IntEntry(vNodes, uLit0 >> 1), (uLit0 & 1) );
362 Vec_IntPush( vDrivers, iNode0 );
363 }
364 Vec_IntFree( vLits );
365 }
366
367
368 for ( i = 0; i < nOutputs; i++ )
369 Gia_ManAppendCo( pNew, Vec_IntEntry(vDrivers, nLatches + i) );
370 for ( i = 0; i < nLatches; i++ )
371 Gia_ManAppendCo( pNew, Vec_IntEntry(vDrivers, i) );
372 Vec_IntFree( vDrivers );
373
374
376
377
378 pCur = pSymbols;
379 if ( pCur < (unsigned char *)pContents + nFileSize && *pCur != 'c' )
380 {
381 int fReadNames = 1;
382 if ( fReadNames )
383 {
384 int fError = 0;
385 while ( !fError && pCur < (unsigned char *)pContents + nFileSize && *pCur != 'c' )
386 {
387 int iTerm;
388 char * pType = (char *)pCur;
389 char * pName = NULL;
390
391 if ( *pCur != 'i' && *pCur != 'o' && *pCur != 'l' && *pCur != 'n' )
392 {
393 fError = 1;
394 break;
395 }
396
397 iTerm = atoi( (char *)++pCur ); while ( *pCur++ != ' ' );
398
399 while ( *pCur == ' ' )
400 pCur++;
401
402 for ( pName = (char *)pCur; *pCur && *pCur != '\n'; pCur++ );
403 if ( *pCur == '\n' )
404 *pCur = 0;
405
406 if ( *pType == 'i' )
407 {
408 if ( vNamesIn == NULL )
409 vNamesIn = Vec_PtrStart( nInputs );
410 if ( Vec_PtrSize(vNamesIn) <= iTerm )
411 {
412 fError = 1;
413 break;
414 }
415 Vec_PtrWriteEntry( vNamesIn, iTerm, Abc_UtilStrsav(pName) );
416 }
417 else if ( *pType == 'o' )
418 {
419 if ( vNamesOut == NULL )
420 vNamesOut = Vec_PtrStart( nOutputs );
421 if ( Vec_PtrSize(vNamesOut) <= iTerm )
422 {
423 fError = 1;
424 break;
425 }
426 Vec_PtrWriteEntry( vNamesOut, iTerm, Abc_UtilStrsav(pName) );
427 }
428 else if ( *pType == 'l' )
429 {
430 char Buffer[1000];
432 sprintf( Buffer,
"%s_in", pName );
433 if ( vNamesRegIn == NULL )
434 vNamesRegIn = Vec_PtrStart( nLatches );
435 if ( vNamesRegOut == NULL )
436 vNamesRegOut = Vec_PtrStart( nLatches );
437 if ( Vec_PtrSize(vNamesRegIn) <= iTerm )
438 {
439 fError = 1;
440 break;
441 }
442 Vec_PtrWriteEntry( vNamesRegIn, iTerm, Abc_UtilStrsav(Buffer) );
443 Vec_PtrWriteEntry( vNamesRegOut, iTerm, Abc_UtilStrsav(pName) );
444 }
445 else if ( *pType == 'n' )
446 {
447 if ( Vec_IntSize(&pNew->
vHTable) != 0 )
448 {
449 printf( "Structural hashing should be disabled to read internal nodes names.\n" );
450 fError = 1;
451 break;
452 }
453 if ( vNamesNode == NULL )
454 vNamesNode = Vec_PtrStart( Gia_ManObjNum(pNew) );
455 Vec_PtrWriteEntry( vNamesNode, iTerm, Abc_UtilStrsav(pName) );
456 }
457 else
458 {
459 fError = 1;
460 break;
461 }
462 pCur++;
463 }
464 if ( fError )
465 {
466 printf( "Error occurred when reading signal names. Signal names ignored.\n" );
467 if ( vNamesIn ) Vec_PtrFreeFree( vNamesIn ), vNamesIn = NULL;
468 if ( vNamesOut ) Vec_PtrFreeFree( vNamesOut ), vNamesOut = NULL;
469 if ( vNamesRegIn ) Vec_PtrFreeFree( vNamesRegIn ), vNamesRegIn = NULL;
470 if ( vNamesRegOut ) Vec_PtrFreeFree( vNamesRegOut ), vNamesRegOut = NULL;
471 if ( vNamesNode ) Vec_PtrFreeFree( vNamesNode ), vNamesNode = NULL;
472 }
473 }
474 else
475 {
476 int fBreakUsed = 0;
477 unsigned char * pCurOld = pCur;
478 pNew->
vUserPiIds = Vec_IntStartFull( nInputs );
479 pNew->
vUserPoIds = Vec_IntStartFull( nOutputs );
480 pNew->
vUserFfIds = Vec_IntStartFull( nLatches );
481 while ( pCur < (unsigned char *)pContents + nFileSize && *pCur != 'c' )
482 {
483 int iTerm;
484 char * pType = (char *)pCur;
485
486 if ( *pCur != 'i' && *pCur != 'o' && *pCur != 'l' )
487 {
488
489 fBreakUsed = 1;
490 break;
491 }
492
493 iTerm = atoi( (char *)++pCur ); while ( *pCur++ != ' ' );
494
495 while ( *pCur == ' ' )
496 pCur++;
497
498
499
500
501 if ( *pCur++ != '@' )
502 {
503 fBreakUsed = 1;
504 break;
505 }
506 if ( *pCur == 'i' && *pType == 'i' )
507 Vec_IntWriteEntry( pNew->
vUserPiIds, iTerm, atoi((
char *)pCur+1) );
508 else if ( *pCur == 'o' && *pType == 'o' )
509 Vec_IntWriteEntry( pNew->
vUserPoIds, iTerm, atoi((
char *)pCur+1) );
510 else if ( *pCur == 'l' && *pType == 'l' )
511 Vec_IntWriteEntry( pNew->
vUserFfIds, iTerm, atoi((
char *)pCur+1) );
512 else
513 {
514 fprintf( stdout, "Wrong name format.\n" );
515 fBreakUsed = 1;
516 break;
517 }
518
519 while ( *pCur++ != '\n' );
520 }
521
522 if ( fBreakUsed )
523 {
524 unsigned char * pName;
525 int Entry, nInvars, nConstr, iTerm;
526
527 Vec_Int_t * vPoNames = Vec_IntStartFull( nOutputs );
528
532
533
534 fBreakUsed = 0;
535 pCur = (unsigned char *)pCurOld;
536 while ( pCur < (unsigned char *)pContents + nFileSize && *pCur != 'c' )
537 {
538
539 if ( *pCur == 'i' || *pCur == 'l' )
540 {
541
542 while ( *pCur++ != '\n' );
543 *(pCur-1) = 0;
544 continue;
545 }
546 if ( *pCur != 'o' )
547 {
548
549 fBreakUsed = 1;
550 break;
551 }
552
553 iTerm = atoi( (char *)++pCur ); while ( *pCur++ != ' ' );
554
555 if ( iTerm < 0 || iTerm >= nOutputs )
556 {
557 fprintf( stdout, "The output number (%d) is out of range.\n", iTerm );
558 fBreakUsed = 1;
559 break;
560 }
561 if ( Vec_IntEntry(vPoNames, iTerm) != ~0 )
562 {
563 fprintf( stdout, "The output number (%d) is listed twice.\n", iTerm );
564 fBreakUsed = 1;
565 break;
566 }
567
568
569 pName = pCur; while ( *pCur++ != '\n' );
570 *(pCur-1) = 0;
571
572 Vec_IntWriteEntry( vPoNames, iTerm, pName - (unsigned char *)pContents );
573 }
574
575
576 if ( !fBreakUsed )
577 {
578 nInvars = nConstr = 0;
579 vPoTypes = Vec_IntStart( Gia_ManPoNum(pNew) );
581 {
582 if ( Entry == ~0 )
583 continue;
584 if (
strncmp( pContents+Entry,
"constraint:", 11 ) == 0 )
585 {
586 Vec_IntWriteEntry( vPoTypes, i, 1 );
587 nConstr++;
588 }
589 if (
strncmp( pContents+Entry,
"invariant:", 10 ) == 0 )
590 {
591 Vec_IntWriteEntry( vPoTypes, i, 2 );
592 nInvars++;
593 }
594 }
595 if ( nConstr )
596 fprintf( stdout, "Recognized and added %d constraints.\n", nConstr );
597 if ( nInvars )
598 fprintf( stdout, "Recognized and skipped %d invariants.\n", nInvars );
599 if ( nConstr == 0 && nInvars == 0 )
600 Vec_IntFreeP( &vPoTypes );
601 }
602 Vec_IntFree( vPoNames );
603 }
604 }
605 }
606
607
608
609 if ( pCur + 1 < (unsigned char *)pContents + nFileSize && *pCur == 'c' )
610 {
613 unsigned char * pCurTemp;
614 pCur++;
615
616
617
618 while ( pCur < (unsigned char *)pContents + nFileSize )
619 {
620
621 if ( *pCur == 'a' )
622 {
623 pCur++;
624 vStr = Vec_StrStart( Gia_AigerReadInt(pCur) ); pCur += 4;
625 memcpy( Vec_StrArray(vStr), pCur, (
size_t)Vec_StrSize(vStr) );
626 pCur += Vec_StrSize(vStr);
628 Vec_StrFree( vStr );
629 if ( fVerbose ) printf( "Finished reading extension \"a\".\n" );
630 }
631
632 else if ( *pCur == 'c' )
633 {
634 pCur++;
635 assert( Gia_AigerReadInt(pCur) == 4 ); pCur += 4;
636 pNew->
nConstrs = Gia_AigerReadInt( pCur ); pCur += 4;
637 if ( fVerbose ) printf( "Finished reading extension \"c\".\n" );
638 }
639
640 else if ( *pCur == 'd' )
641 {
642 pCur++;
643 assert( Gia_AigerReadInt(pCur) == 4 ); pCur += 4;
644 pNew->
nAnd2Delay = Gia_AigerReadInt(pCur); pCur += 4;
645 if ( fVerbose ) printf( "Finished reading extension \"d\".\n" );
646 }
647 else if ( *pCur == 'i' )
648 {
649 pCur++;
650 nInputs = Gia_AigerReadInt(pCur)/4; pCur += 4;
651 pNew->
vInArrs = Vec_FltStart( nInputs );
652 memcpy( Vec_FltArray(pNew->
vInArrs), pCur, (
size_t)4*nInputs ); pCur += 4*nInputs;
653 if ( fVerbose ) printf( "Finished reading extension \"i\".\n" );
654 }
655 else if ( *pCur == 'o' )
656 {
657 pCur++;
658 nOutputs = Gia_AigerReadInt(pCur)/4; pCur += 4;
659 pNew->
vOutReqs = Vec_FltStart( nOutputs );
660 memcpy( Vec_FltArray(pNew->
vOutReqs), pCur, (
size_t)4*nOutputs ); pCur += 4*nOutputs;
661 if ( fVerbose ) printf( "Finished reading extension \"o\".\n" );
662 }
663
664 else if ( *pCur == 'e' )
665 {
667 pCur++;
668 pCurTemp = pCur + Gia_AigerReadInt(pCur) + 4; pCur += 4;
671 assert( pCur == pCurTemp );
672 if ( fVerbose ) printf( "Finished reading extension \"e\".\n" );
673 }
674
675 else if ( *pCur == 'f' )
676 {
677 pCur++;
678 assert( Gia_AigerReadInt(pCur) == 4*Gia_ManRegNum(pNew) ); pCur += 4;
679 pNew->
vFlopClasses = Vec_IntStart( Gia_ManRegNum(pNew) );
680 memcpy( Vec_IntArray(pNew->
vFlopClasses), pCur, (
size_t)4*Gia_ManRegNum(pNew) ); pCur += 4*Gia_ManRegNum(pNew);
681 if ( fVerbose ) printf( "Finished reading extension \"f\".\n" );
682 }
683
684 else if ( *pCur == 'g' )
685 {
686 pCur++;
687 assert( Gia_AigerReadInt(pCur) == 4*Gia_ManObjNum(pNew) ); pCur += 4;
688 pNew->
vGateClasses = Vec_IntStart( Gia_ManObjNum(pNew) );
689 memcpy( Vec_IntArray(pNew->
vGateClasses), pCur, (
size_t)4*Gia_ManObjNum(pNew) ); pCur += 4*Gia_ManObjNum(pNew);
690 if ( fVerbose ) printf( "Finished reading extension \"g\".\n" );
691 }
692
693 else if ( *pCur == 'h' )
694 {
695 pCur++;
696 vStr = Vec_StrStart( Gia_AigerReadInt(pCur) ); pCur += 4;
697 memcpy( Vec_StrArray(vStr), pCur, (
size_t)Vec_StrSize(vStr) );
698 pCur += Vec_StrSize(vStr);
700 Vec_StrFree( vStr );
701 fHieOnly = 1;
702 if ( fVerbose ) printf( "Finished reading extension \"h\".\n" );
703 }
704
705 else if ( *pCur == 'k' )
706 {
708 int nSize;
709 pCur++;
710 nSize = Gia_AigerReadInt(pCur);
711 pCurTemp = pCur + nSize + 4; pCur += 4;
713 assert( pCur == pCurTemp );
714 if ( fVerbose ) printf( "Finished reading extension \"k\".\n" );
715 }
716
717 else if ( *pCur == 'm' )
718 {
722 int nSize;
723 pCur++;
724 nSize = Gia_AigerReadInt(pCur);
725 pCurTemp = pCur + nSize + 4; pCur += 4;
727 assert( pCur == pCurTemp );
728 if ( fVerbose ) printf( "Finished reading extension \"m\".\n" );
729 }
730
731 else if ( *pCur == 'n' )
732 {
733 pCur++;
734 if ( (*pCur >= 'a' && *pCur <= 'z') || (*pCur >= 'A' && *pCur <= 'Z') || (*pCur >= '0' && *pCur <= '9') )
735 {
737 pNew->
pName = Abc_UtilStrsav( (
char *)pCur ); pCur +=
strlen(pNew->
pName) + 1;
738 }
739 else
740 {
741 pCurTemp = pCur + Gia_AigerReadInt(pCur) + 4; pCur += 4;
743 pNew->
pName = Abc_UtilStrsav( (
char *)pCur ); pCur +=
strlen(pNew->
pName) + 1;
744 assert( pCur == pCurTemp );
745 }
746 }
747
748 else if ( *pCur == 'p' )
749 {
751 pCur++;
752 pCurTemp = pCur + Gia_AigerReadInt(pCur) + 4; pCur += 4;
754 memcpy( pPlacement, pCur, (
size_t)4*Gia_ManObjNum(pNew) ); pCur += 4*Gia_ManObjNum(pNew);
755 assert( pCur == pCurTemp );
757 if ( fVerbose ) printf( "Finished reading extension \"p\".\n" );
758 }
759
760 else if ( *pCur == 'r' )
761 {
762 int i, nRegs;
763 pCur++;
764 pCurTemp = pCur + Gia_AigerReadInt(pCur) + 4; pCur += 4;
765 nRegs = Gia_AigerReadInt(pCur); pCur += 4;
766
768 for ( i = 0; i < nRegs; i++ )
769 Vec_IntPush( pNew->
vRegClasses, Gia_AigerReadInt(pCur) ), pCur += 4;
770 assert( pCur == pCurTemp );
771 if ( fVerbose ) printf( "Finished reading extension \"r\".\n" );
772 }
773
774 else if ( *pCur == 's' )
775 {
776 int i, nRegs;
777 pCur++;
778 pCurTemp = pCur + Gia_AigerReadInt(pCur) + 4; pCur += 4;
779 nRegs = Gia_AigerReadInt(pCur); pCur += 4;
781 for ( i = 0; i < nRegs; i++ )
782 Vec_IntPush( pNew->
vRegInits, Gia_AigerReadInt(pCur) ), pCur += 4;
783 assert( pCur == pCurTemp );
784 if ( fVerbose ) printf( "Finished reading extension \"s\".\n" );
785 }
786
787 else if ( *pCur == 'b' )
788 {
789 int nSize;
790 pCur++;
791 nSize = Gia_AigerReadInt(pCur);
792 pCurTemp = pCur + nSize + 4; pCur += 4;
793 pNew->
pCellStr = Abc_UtilStrsav( (
char*)pCur ); pCur +=
strlen((
char*)pCur) + 1;
796 pNew->
vConfigs = Vec_IntAlloc(nSize / 4);
797
798 for ( i = 0; i < nSize / 4; i++ )
799 Vec_IntPush( pNew->
vConfigs, Gia_AigerReadInt(pCur) ), pCur += 4;
800 assert( pCur == pCurTemp );
801 if ( fVerbose ) printf( "Finished reading extension \"b\".\n" );
802 }
803
804 else if ( *pCur == 'q' )
805 {
806 int i, nPairs, iRepr, iNode;
807 assert( !Gia_ManHasChoices(pNew) );
809 pCur++;
810 pCurTemp = pCur + Gia_AigerReadInt(pCur) + 4; pCur += 4;
811 nPairs = Gia_AigerReadInt(pCur); pCur += 4;
812 for ( i = 0; i < nPairs; i++ )
813 {
814 iRepr = Gia_AigerReadInt(pCur); pCur += 4;
815 iNode = Gia_AigerReadInt(pCur); pCur += 4;
816 pNew->
pSibls[iRepr] = iNode;
818 }
819 assert( pCur == pCurTemp );
820 if ( fVerbose ) printf( "Finished reading extension \"q\".\n" );
821 }
822
823 else if ( *pCur == 'u' )
824 {
825 unsigned char * pSwitching;
826 pCur++;
827 pCurTemp = pCur + Gia_AigerReadInt(pCur) + 4; pCur += 4;
828 pSwitching =
ABC_ALLOC(
unsigned char, Gia_ManObjNum(pNew) );
829 memcpy( pSwitching, pCur, (
size_t)Gia_ManObjNum(pNew) ); pCur += Gia_ManObjNum(pNew);
830 assert( pCur == pCurTemp );
831 if ( fVerbose ) printf( "Finished reading extension \"s\".\n" );
832 }
833
834 else if ( *pCur == 't' )
835 {
836 pCur++;
837 vStr = Vec_StrStart( Gia_AigerReadInt(pCur) ); pCur += 4;
838 memcpy( Vec_StrArray(vStr), pCur, (
size_t)Vec_StrSize(vStr) ); pCur += Vec_StrSize(vStr);
840 Vec_StrFree( vStr );
841 if ( fVerbose ) printf( "Finished reading extension \"t\".\n" );
842 }
843
844 else if ( *pCur == 'v' )
845 {
846 pCur++;
847 pNew->
vObjClasses = Vec_IntStart( Gia_AigerReadInt(pCur)/4 ); pCur += 4;
850 if ( fVerbose ) printf( "Finished reading extension \"v\".\n" );
851 }
852
853 else if ( *pCur == 'w' )
854 {
856 int i, nPairs;
857 pCur++;
858 pCurTemp = pCur + Gia_AigerReadInt(pCur) + 4; pCur += 4;
859 nPairs = Gia_AigerReadInt(pCur); pCur += 4;
860 vPairs = Vec_IntAlloc( 2*nPairs );
861 for ( i = 0; i < 2*nPairs; i++ )
862 Vec_IntPush( vPairs, Gia_AigerReadInt(pCur) ), pCur += 4;
863 assert( pCur == pCurTemp );
864 if ( fSkipStrash )
865 {
867 if ( fVerbose ) printf( "Finished reading extension \"w\".\n" );
868 }
869 else
870 printf( "Cannot read extension \"w\" because AIG is rehashed. Use \"&r -s <file.aig>\".\n" );
871 Vec_IntFree( vPairs );
872 }
873 else break;
874 }
875 }
876
877
878 Vec_IntFree( vNodes );
879
880
881 if ( nBad || nConstr || nJust || nFair )
883
884
885 if ( vPoTypes )
886 {
889 Vec_IntFreeP( &vPoTypes );
890 }
891
893 {
896 Vec_Int_t * vFlopMap, * vGateMap, * vObjMap, * vRegClasses, * vRegInits;
905 if ( (vGateMap || vObjMap) && (Gia_ManObjNum(pNew) < Gia_ManObjNum(pTemp)) )
906 printf( "Cleanup removed objects after reading. Old gate/object abstraction maps are invalid!\n" );
915 }
916
917 if ( fHieOnly )
918 {
919
921 printf( "Warning: Creating unit-delay box delay tables because box library is not available.\n" );
923 }
924 Vec_FltFreeP( &pNew->
vInArrs );
926
927
928
929
930
931
932
933
934
935
936 if ( vInits && Vec_IntSum(vInits) )
937 {
938 char * pInit =
ABC_ALLOC(
char, Vec_IntSize(vInits) + 1 );
940 int i;
941 assert( Vec_IntSize(vInits) == Gia_ManRegNum(pNew) );
943 {
944 if ( Vec_IntEntry(vInits, i) == 0 )
945 pInit[i] = '0';
946 else if ( Vec_IntEntry(vInits, i) == 1 )
947 pInit[i] = '1';
948 else
949 {
950 assert( Vec_IntEntry(vInits, i) == Abc_Var2Lit(Gia_ObjId(pNew, pObj), 0) );
951
952 pInit[i] = 'X';
953 }
954 }
955 pInit[i] = 0;
956 if ( !fSkipStrash )
957 {
961 }
963 }
964 Vec_IntFreeP( &vInits );
965 if ( !fGiaSimple && !fSkipStrash && pNew->
vMapping )
966 {
967 Abc_Print( 0, "Structural hashing enabled while reading AIGER invalidated the mapping. Consider using \"&r -s\".\n" );
969 }
970 if ( vNamesIn && Gia_ManPiNum(pNew) != Vec_PtrSize(vNamesIn) )
971 Abc_Print( 0, "The number of inputs does not match the number of input names.\n" );
972 else if ( vNamesOut && Gia_ManPoNum(pNew) != Vec_PtrSize(vNamesOut) )
973 Abc_Print( 0, "The number of output does not match the number of output names.\n" );
974 else if ( vNamesRegOut && Gia_ManRegNum(pNew) != Vec_PtrSize(vNamesRegOut) )
975 Abc_Print( 0, "The number of inputs does not match the number of flop names.\n" );
976 else if ( vNamesIn && vNamesOut )
977 {
978 pNew->
vNamesIn = vNamesIn; vNamesIn = NULL;
979 pNew->
vNamesOut = vNamesOut; vNamesOut = NULL;
980 if ( vNamesRegOut )
981 {
982 Vec_PtrAppend( pNew->
vNamesIn, vNamesRegOut );
983 Vec_PtrClear( vNamesRegOut );
984 Vec_PtrFree( vNamesRegOut );
985 vNamesRegOut = NULL;
986 }
987 if ( vNamesRegIn )
988 {
989 Vec_PtrAppend( pNew->
vNamesOut, vNamesRegIn );
990 Vec_PtrClear( vNamesRegIn );
991 Vec_PtrFree( vNamesRegIn );
992 vNamesRegIn = NULL;
993 }
994 }
995 if ( vNamesNode && Gia_ManObjNum(pNew) != Vec_PtrSize(vNamesNode) )
996 Abc_Print( 0, "The size of the node name array does not match the number of objects. Names are not entered.\n" );
997 else if ( vNamesNode )
998 pNew->
vNamesNode = vNamesNode, vNamesNode = NULL;
999 if ( vNamesIn ) Vec_PtrFreeFree( vNamesIn );
1000 if ( vNamesOut ) Vec_PtrFreeFree( vNamesOut );
1001 if ( vNamesRegIn ) Vec_PtrFreeFree( vNamesRegIn );
1002 if ( vNamesRegOut ) Vec_PtrFreeFree( vNamesRegOut );
1003 return pNew;
1004}
ABC_DLL void * Abc_FrameReadLibBox()
struct Vec_Str_t_ Vec_Str_t
ABC_NAMESPACE_IMPL_START Gia_Rpr_t * Gia_AigerReadEquivClasses(unsigned char **ppPos, int nSize)
DECLARATIONS ///.
int * Gia_AigerReadMappingSimple(unsigned char **ppPos, int nSize)
Vec_Int_t * Gia_AigerReadMappingDoc(unsigned char **ppPos, int nObjs)
int * Gia_AigerReadMapping(unsigned char **ppPos, int nSize)
Vec_Int_t * Gia_AigerReadPacking(unsigned char **ppPos, int nSize)
Vec_Int_t * Gia_AigerReadLiterals(unsigned char **ppPos, int nEntries)
struct Gia_Rpr_t_ Gia_Rpr_t
void Gia_ManStop(Gia_Man_t *p)
#define Gia_ManForEachRo(p, pObj, i)
int Gia_ManHasDangling(Gia_Man_t *p)
void Gia_ManSetRegNum(Gia_Man_t *p, int nRegs)
int * Gia_ManDeriveNexts(Gia_Man_t *p)
void Gia_ManHashAlloc(Gia_Man_t *p)
struct Gia_Plc_t_ Gia_Plc_t
Gia_Man_t * Gia_ManStart(int nObjsMax)
FUNCTION DEFINITIONS ///.
Gia_Man_t * Gia_ManCleanup(Gia_Man_t *p)
int Gia_ManHashAnd(Gia_Man_t *p, int iLit0, int iLit1)
Gia_Man_t * Gia_ManDupWithConstraints(Gia_Man_t *p, Vec_Int_t *vPoTypes)
void Gia_ManEdgeFromArray(Gia_Man_t *p, Vec_Int_t *vArray)
FUNCTION DEFINITIONS ///.
void Gia_ManInvertConstraints(Gia_Man_t *pAig)
Gia_Man_t * Gia_ManDupZeroUndc(Gia_Man_t *p, char *pInit, int nNewPis, int fGiaSimple, int fVerbose)
void Gia_ManHashStop(Gia_Man_t *p)
typedefABC_NAMESPACE_HEADER_START struct Tim_Man_t_ Tim_Man_t
INCLUDES ///.
Tim_Man_t * Tim_ManLoad(Vec_Str_t *p, int fHieOnly)
void Tim_ManCreate(Tim_Man_t *p, void *pLib, Vec_Flt_t *vInArrs, Vec_Flt_t *vOutReqs)
#define Vec_IntForEachEntry(vVec, Entry, i)
MACRO DEFINITIONS ///.
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.