The source code and dockerfile for the GSW2024 AI Lab.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.

180 lines
6.2 KiB

4 weeks ago
  1. /**CFile**********************************************************************
  2. FileName [dddmpConvert.c]
  3. PackageName [dddmp]
  4. Synopsis [Conversion between ASCII and binary formats]
  5. Description [Conversion between ASCII and binary formats is presently
  6. supported by loading a BDD in the source format and storing it
  7. in the target one. We plan to introduce ad hoc procedures
  8. avoiding explicit BDD node generation.
  9. ]
  10. Author [Gianpiero Cabodi and Stefano Quer]
  11. Copyright [
  12. Copyright (c) 2004 by Politecnico di Torino.
  13. All Rights Reserved. This software is for educational purposes only.
  14. Permission is given to academic institutions to use, copy, and modify
  15. this software and its documentation provided that this introductory
  16. message is not removed, that this software and its documentation is
  17. used for the institutions' internal research and educational purposes,
  18. and that no monies are exchanged. No guarantee is expressed or implied
  19. by the distribution of this code.
  20. Send bug-reports and/or questions to:
  21. {gianpiero.cabodi,stefano.quer}@polito.it.
  22. ]
  23. ******************************************************************************/
  24. #include "dddmpInt.h"
  25. /*---------------------------------------------------------------------------*/
  26. /* Stucture declarations */
  27. /*---------------------------------------------------------------------------*/
  28. /*---------------------------------------------------------------------------*/
  29. /* Type declarations */
  30. /*---------------------------------------------------------------------------*/
  31. /*---------------------------------------------------------------------------*/
  32. /* Variable declarations */
  33. /*---------------------------------------------------------------------------*/
  34. /*---------------------------------------------------------------------------*/
  35. /* Macro declarations */
  36. /*---------------------------------------------------------------------------*/
  37. /**AutomaticStart*************************************************************/
  38. /*---------------------------------------------------------------------------*/
  39. /* Static function prototypes */
  40. /*---------------------------------------------------------------------------*/
  41. /**AutomaticEnd***************************************************************/
  42. /*---------------------------------------------------------------------------*/
  43. /* Definition of exported functions */
  44. /*---------------------------------------------------------------------------*/
  45. /**Function********************************************************************
  46. Synopsis [Converts from ASCII to binary format]
  47. Description [Converts from ASCII to binary format. A BDD array is loaded and
  48. and stored to the target file.]
  49. SideEffects [None]
  50. SeeAlso [Dddmp_Bin2Text()]
  51. ******************************************************************************/
  52. int
  53. Dddmp_Text2Bin (
  54. char *filein /* IN: name of ASCII file */,
  55. char *fileout /* IN: name of binary file */
  56. )
  57. {
  58. DdManager *ddMgr; /* pointer to DD manager */
  59. DdNode **roots; /* array of BDD roots to be loaded */
  60. int nRoots; /* number of BDD roots */
  61. int retValue;
  62. ddMgr = Cudd_Init(0,0,CUDD_UNIQUE_SLOTS,CUDD_CACHE_SLOTS,0);
  63. if (ddMgr == NULL) {
  64. return (0);
  65. }
  66. nRoots = Dddmp_cuddBddArrayLoad(ddMgr,DDDMP_ROOT_MATCHLIST,NULL,
  67. DDDMP_VAR_MATCHIDS,NULL,NULL,NULL,
  68. DDDMP_MODE_TEXT,filein,NULL,&roots);
  69. Dddmp_CheckAndGotoLabel (nRoots<=0,
  70. "Negative Number of Roots.", failure);
  71. retValue = Dddmp_cuddBddArrayStore (ddMgr,NULL,nRoots,roots,NULL,
  72. NULL,NULL,DDDMP_MODE_BINARY,DDDMP_VARIDS,fileout,NULL);
  73. Dddmp_CheckAndGotoLabel (retValue<=0,
  74. "Error code returned.", failure);
  75. Cudd_Quit(ddMgr);
  76. return (1);
  77. failure:
  78. printf("error converting BDD format\n");
  79. Cudd_Quit(ddMgr);
  80. return (0);
  81. }
  82. /**Function********************************************************************
  83. Synopsis [Converts from binary to ASCII format]
  84. Description [Converts from binary to ASCII format. A BDD array is loaded and
  85. and stored to the target file.]
  86. SideEffects [None]
  87. SeeAlso [Dddmp_Text2Bin()]
  88. ******************************************************************************/
  89. int
  90. Dddmp_Bin2Text (
  91. char *filein /* IN: name of binary file */,
  92. char *fileout /* IN: name of ASCII file */
  93. )
  94. {
  95. DdManager *ddMgr; /* pointer to DD manager */
  96. DdNode **roots; /* array of BDD roots to be loaded */
  97. int nRoots; /* number of BDD roots */
  98. int retValue;
  99. ddMgr = Cudd_Init(0,0,CUDD_UNIQUE_SLOTS,CUDD_CACHE_SLOTS,0);
  100. if (ddMgr == NULL) {
  101. return (0);
  102. }
  103. nRoots = Dddmp_cuddBddArrayLoad(ddMgr,DDDMP_ROOT_MATCHLIST,NULL,
  104. DDDMP_VAR_MATCHIDS,NULL,NULL,NULL,
  105. DDDMP_MODE_BINARY,filein,NULL,&roots);
  106. Dddmp_CheckAndGotoLabel (nRoots<=0,
  107. "Negative Number of Roots.", failure);
  108. retValue = Dddmp_cuddBddArrayStore (ddMgr,NULL,nRoots,roots,NULL,
  109. NULL,NULL,DDDMP_MODE_TEXT,DDDMP_VARIDS,fileout,NULL);
  110. Dddmp_CheckAndGotoLabel (retValue<=0,
  111. "Error code returned.", failure);
  112. Cudd_Quit(ddMgr);
  113. return (1);
  114. failure:
  115. printf("error converting BDD format\n");
  116. Cudd_Quit(ddMgr);
  117. return (0);
  118. }
  119. /*---------------------------------------------------------------------------*/
  120. /* Definition of internal functions */
  121. /*---------------------------------------------------------------------------*/
  122. /*---------------------------------------------------------------------------*/
  123. /* Definition of static functions */
  124. /*---------------------------------------------------------------------------*/
  125. /*---------------------------------------------------------------------------*/
  126. /* Static function prototypes */
  127. /*---------------------------------------------------------------------------*/