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.

167 lines
5.1 KiB

2 months ago
  1. /**CFile**********************************************************************
  2. FileName [dddmpDbg.c]
  3. PackageName [dddmp]
  4. Synopsis [Functions to display BDD files]
  5. Description [Functions to display BDD files in binary format
  6. ]
  7. Author [Gianpiero Cabodi and Stefano Quer]
  8. Copyright [
  9. Copyright (c) 2004 by Politecnico di Torino.
  10. All Rights Reserved. This software is for educational purposes only.
  11. Permission is given to academic institutions to use, copy, and modify
  12. this software and its documentation provided that this introductory
  13. message is not removed, that this software and its documentation is
  14. used for the institutions' internal research and educational purposes,
  15. and that no monies are exchanged. No guarantee is expressed or implied
  16. by the distribution of this code.
  17. Send bug-reports and/or questions to:
  18. {gianpiero.cabodi,stefano.quer}@polito.it.
  19. ]
  20. ******************************************************************************/
  21. #include "dddmpInt.h"
  22. /*---------------------------------------------------------------------------*/
  23. /* Stucture declarations */
  24. /*---------------------------------------------------------------------------*/
  25. /*---------------------------------------------------------------------------*/
  26. /* Type declarations */
  27. /*---------------------------------------------------------------------------*/
  28. /*---------------------------------------------------------------------------*/
  29. /* Variable declarations */
  30. /*---------------------------------------------------------------------------*/
  31. /*---------------------------------------------------------------------------*/
  32. /* Macro declarations */
  33. /*---------------------------------------------------------------------------*/
  34. /**AutomaticStart*************************************************************/
  35. /*---------------------------------------------------------------------------*/
  36. /* Static function prototypes */
  37. /*---------------------------------------------------------------------------*/
  38. /**AutomaticEnd***************************************************************/
  39. /*---------------------------------------------------------------------------*/
  40. /* Definition of exported functions */
  41. /*---------------------------------------------------------------------------*/
  42. /**Function********************************************************************
  43. Synopsis [Display a binary dump file in a text file]
  44. Description [Display a binary dump file in a text file]
  45. SideEffects [None]
  46. SeeAlso [Dddmp_cuddBddStore , Dddmp_cuddBddLoad ]
  47. ******************************************************************************/
  48. int
  49. Dddmp_cuddBddDisplayBinary(
  50. char *fileIn /* IN: name of binary file */,
  51. char *fileOut /* IN: name of text file */
  52. )
  53. {
  54. FILE *fp, *fpo;
  55. int id, size;
  56. struct binary_dd_code code;
  57. char buf[1000];
  58. int nnodes, i;
  59. char *retval;
  60. fp = fopen (fileIn, "rb");
  61. if (fp == 0) {
  62. return (0);
  63. }
  64. fpo = fopen (fileOut, "w");
  65. if (fpo == 0) {
  66. return (0);
  67. }
  68. while (fgets(buf, 999,fp)!=NULL) {
  69. fprintf (fpo, "%s", buf);
  70. if (strncmp(buf, ".nnodes", 7) == 0) {
  71. sscanf (buf, "%*s %d", &nnodes);
  72. }
  73. if (strncmp(buf, ".rootids", 8) == 0) {
  74. break;
  75. }
  76. }
  77. for (i=1; i<=nnodes; i++) {
  78. if (feof(fp)) {
  79. return (0);
  80. }
  81. if (DddmpReadCode(fp,&code) == 0) {
  82. return (0);
  83. }
  84. fprintf (fpo, "c : v %d | T %d | E %d\n",
  85. (int)code.V, (int)code.T,
  86. (code.Ecompl ? -(int)(code.E) : (int)(code.E)));
  87. if (code.V == DDDMP_TERMINAL) {
  88. continue;
  89. }
  90. if (code.V <= DDDMP_RELATIVE_ID) {
  91. size = DddmpReadInt(fp,&id);
  92. if (size == 0) {
  93. return (0);
  94. }
  95. fprintf(fpo, "v(%d): %d\n", size, id);
  96. }
  97. if (code.T <= DDDMP_RELATIVE_ID) {
  98. size = DddmpReadInt(fp,&id);
  99. if (size == 0) {
  100. return (0);
  101. }
  102. fprintf(fpo, "T(%d): %d\n", size, id);
  103. }
  104. if (code.E <= DDDMP_RELATIVE_ID) {
  105. size = DddmpReadInt(fp,&id);
  106. if (size == 0) {
  107. return (0);
  108. }
  109. fprintf(fpo, "E(%d): %d\n", size, id);
  110. }
  111. }
  112. retval = fgets(buf, 999,fp);
  113. if (!retval || strncmp(buf, ".end", 4) != 0) {
  114. return (0);
  115. }
  116. fprintf(fpo, ".end");
  117. fclose(fp);
  118. fclose(fpo);
  119. return (1);
  120. }
  121. /*---------------------------------------------------------------------------*/
  122. /* Definition of internal functions */
  123. /*---------------------------------------------------------------------------*/
  124. /*---------------------------------------------------------------------------*/
  125. /* Definition of static functions */
  126. /*---------------------------------------------------------------------------*/