ioReadVerilog.c 3.02 KB
Newer Older
Alan Mishchenko committed
1 2 3 4 5 6 7 8
/**CFile****************************************************************

  FileName    [ioReadVerilog.c]

  SystemName  [ABC: Logic synthesis and verification system.]

  PackageName [Command processing package.]

Alan Mishchenko committed
9
  Synopsis    [Procedure to read network from file.]
Alan Mishchenko committed
10 11 12 13 14 15 16 17 18 19 20

  Author      [Alan Mishchenko]
  
  Affiliation [UC Berkeley]

  Date        [Ver. 1.0. Started - June 20, 2005.]

  Revision    [$Id: ioReadVerilog.c,v 1.00 2005/06/20 00:00:00 alanmi Exp $]

***********************************************************************/

Alan Mishchenko committed
21
#include "ioAbc.h"
22
#include "base/ver/ver.h"
23 24 25

ABC_NAMESPACE_IMPL_START

Alan Mishchenko committed
26 27 28 29 30

////////////////////////////////////////////////////////////////////////
///                        DECLARATIONS                              ///
////////////////////////////////////////////////////////////////////////

31
//extern Abc_Lib_t * Ver_ParseFile( char * pFileName, Abc_Lib_t * pGateLib, int fCheck, int fUseMemMan );
Alan Mishchenko committed
32 33

////////////////////////////////////////////////////////////////////////
Alan Mishchenko committed
34
///                     FUNCTION DEFINITIONS                         ///
Alan Mishchenko committed
35 36 37 38
////////////////////////////////////////////////////////////////////////

/**Function*************************************************************

Alan Mishchenko committed
39
  Synopsis    [Reads hierarchical design from the Verilog file.]
Alan Mishchenko committed
40 41 42 43 44 45 46 47

  Description []
               
  SideEffects []

  SeeAlso     []

***********************************************************************/
Alan Mishchenko committed
48
Abc_Ntk_t * Io_ReadVerilog( char * pFileName, int fCheck )
Alan Mishchenko committed
49
{
50
    Abc_Ntk_t * pNtk, * pTemp;
Alan Mishchenko committed
51
    Abc_Lib_t * pDesign;
52
    int i, RetValue;
Alan Mishchenko committed
53

Alan Mishchenko committed
54 55 56
    // parse the verilog file
    pDesign = Ver_ParseFile( pFileName, NULL, fCheck, 1 );
    if ( pDesign == NULL )
Alan Mishchenko committed
57 58
        return NULL;

Alan Mishchenko committed
59 60
    // detect top-level model
    RetValue = Abc_LibFindTopLevelModels( pDesign );
61
    pNtk = (Abc_Ntk_t *)Vec_PtrEntry( pDesign->vTops, 0 );
Alan Mishchenko committed
62
    if ( RetValue > 1 )
63 64 65 66 67 68 69
    {
        printf( "Warning: The design has %d root-level modules: ", Vec_PtrSize(pDesign->vTops) );
        Vec_PtrForEachEntry( Abc_Ntk_t *, pDesign->vTops, pTemp, i )
            printf( " %s", Abc_NtkName(pTemp) );
        printf( "\n" );
        printf( "The first one (%s) will be used.\n", pNtk->pName );
    }
Alan Mishchenko committed
70

Alan Mishchenko committed
71 72 73
    // extract the master network
    pNtk->pDesign = pDesign;
    pDesign->pManFunc = NULL;
Alan Mishchenko committed
74

Alan Mishchenko committed
75 76 77
    // verify the design for cyclic dependence
    assert( Vec_PtrSize(pDesign->vModules) > 0 );
    if ( Vec_PtrSize(pDesign->vModules) == 1 )
Alan Mishchenko committed
78
    {
Alan Mishchenko committed
79 80 81 82
//        printf( "Warning: The design is not hierarchical.\n" );
        Abc_LibFree( pDesign, pNtk );
        pNtk->pDesign = NULL;
        pNtk->pSpec = Extra_UtilStrsav( pFileName );
Alan Mishchenko committed
83 84 85
    }
    else
    {
Alan Mishchenko committed
86 87
        // check that there is no cyclic dependency
        Abc_NtkIsAcyclicHierarchy( pNtk );
Alan Mishchenko committed
88 89
    }

Alan Mishchenko committed
90
//Io_WriteVerilog( pNtk, "_temp.v" );
91
    Abc_NtkPrintBoxInfo( pNtk );
Alan Mishchenko committed
92
    return pNtk;
Alan Mishchenko committed
93 94
}

Alan Mishchenko committed
95 96 97 98 99 100
////////////////////////////////////////////////////////////////////////
///                       END OF FILE                                ///
////////////////////////////////////////////////////////////////////////



101 102
ABC_NAMESPACE_IMPL_END