abc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
literal.h File Reference
#include <stdio.h>
#include <stdlib.h>
#include "bool/kit/kit.h"
#include "misc/vec/vec.h"
#include "misc/util/abc_global.h"

Go to the source code of this file.

Data Structures

struct  Literal_t_
 

Typedefs

typedef struct Literal_t_ Literal_t
 

Enumerations

enum  Operator_t { LIT_NONE = 0, LIT_AND, LIT_OR, LIT_XOR }
 INCLUDES ///. More...
 

Functions

static void Lit_TruthPositiveTransition (unsigned *pIn, unsigned *pOut, int nVars, int varIdx)
 FUNCTION DEFINITIONS ///. More...
 
static void Lit_TruthNegativeTransition (unsigned *pIn, unsigned *pOut, int nVars, int varIdx)
 
static Literal_tLit_Alloc (unsigned *pTruth, int nVars, int varIdx, char pol)
 
static Literal_tLit_GroupLiterals (Literal_t *lit1, Literal_t *lit2, Operator_t op, int nVars)
 
static Literal_tLit_CreateLiteralConst (unsigned *pTruth, int nVars, int constant)
 
static Literal_tLit_Copy (Literal_t *lit, int nVars)
 
static void Lit_PrintTT (unsigned *tt, int nVars)
 
static void Lit_PrintExp (Literal_t *lit)
 
static void Lit_Free (Literal_t *lit)
 

Typedef Documentation

typedef struct Literal_t_ Literal_t

Definition at line 50 of file literal.h.

Enumeration Type Documentation

enum Operator_t

INCLUDES ///.

CFile****************************************************************

FileName [literal.h]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [RPO]

Synopsis [Literal structure]

Author [Mayler G. A. Martins / Vinicius Callegaro]

Affiliation [UFRGS]

Date [Ver. 1.0. Started - May 08, 2013.]

Revision [

Id:
literal.h,v 1.00 2013/05/08 00:00:00 mgamartins Exp

]PARAMETERS ///

Enumerator
LIT_NONE 
LIT_AND 
LIT_OR 
LIT_XOR 

Definition at line 42 of file literal.h.

42  {
43  LIT_NONE = 0, // 0: unknown
44  LIT_AND, // 1: AND association
45  LIT_OR, // 2: OR association
46  LIT_XOR // 3: XOR association (not used yet)
47 } Operator_t;
Definition: literal.h:45
Operator_t
INCLUDES ///.
Definition: literal.h:42

Function Documentation

static Literal_t* Lit_Alloc ( unsigned *  pTruth,
int  nVars,
int  varIdx,
char  pol 
)
inlinestatic

Function*************************************************************

Synopsis [Create a literal given a polarity ]

Description [The inputs are the function, index and its polarity and a the output is a literal]

SideEffects []

SeeAlso []

Definition at line 131 of file literal.h.

131  {
132  unsigned * transition;
133  unsigned * function;
134  Vec_Str_t * exp;
135  Literal_t* lit;
136  assert(pol == '+' || pol == '-');
137  transition = ABC_ALLOC(unsigned, Kit_TruthWordNum(nVars));
138  if (pol == '+') {
139  Lit_TruthPositiveTransition(pTruth, transition, nVars, varIdx);
140  } else {
141  Lit_TruthNegativeTransition(pTruth, transition, nVars, varIdx);
142  }
143  if (!Kit_TruthIsConst0(transition,nVars)) {
144  function = ABC_ALLOC(unsigned, Kit_TruthWordNum(nVars));
145  Kit_TruthIthVar(function, nVars, varIdx);
146  //Abc_Print(-2, "Allocating function %X %d %c \n", *function, varIdx, pol);
147  exp = Vec_StrAlloc(5);
148  if (pol == '-') {
149  Kit_TruthNot(function, function, nVars);
150  Vec_StrPutC(exp, '!');
151  }
152  Vec_StrPutC(exp, (char)('a' + varIdx));
153  Vec_StrPutC(exp, '\0');
154  lit = ABC_ALLOC(Literal_t, 1);
155  lit->function = function;
156  lit->transition = transition;
157  lit->expression = exp;
158  return lit;
159  } else {
160  ABC_FREE(transition); // free the function.
161  return NULL;
162  }
163 }
static void Lit_TruthNegativeTransition(unsigned *pIn, unsigned *pOut, int nVars, int varIdx)
Definition: literal.h:103
static int Kit_TruthWordNum(int nVars)
Definition: kit.h:224
static void Lit_TruthPositiveTransition(unsigned *pIn, unsigned *pOut, int nVars, int varIdx)
FUNCTION DEFINITIONS ///.
Definition: literal.h:75
static void Vec_StrPutC(Vec_Str_t *vOut, char c)
Definition: vecStr.h:910
#define ABC_ALLOC(type, num)
Definition: abc_global.h:229
static int Kit_TruthIsConst0(unsigned *pIn, int nVars)
Definition: kit.h:315
static Vec_Str_t * Vec_StrAlloc(int nCap)
Definition: bblif.c:495
Vec_Str_t * expression
Definition: literal.h:55
int lit
Definition: satVec.h:130
static void Kit_TruthNot(unsigned *pOut, unsigned *pIn, int nVars)
Definition: kit.h:373
static void Kit_TruthIthVar(unsigned *pTruth, int nVars, int iVar)
Definition: kit.h:473
unsigned * function
Definition: literal.h:54
unsigned * transition
Definition: literal.h:53
#define ABC_FREE(obj)
Definition: abc_global.h:232
#define assert(ex)
Definition: util_old.h:213
static Literal_t* Lit_Copy ( Literal_t lit,
int  nVars 
)
inlinestatic

Definition at line 249 of file literal.h.

249  {
250  Literal_t* newLit = ABC_ALLOC(Literal_t,1);
251  newLit->function = ABC_ALLOC(unsigned, Kit_TruthWordNum(nVars));
252  Kit_TruthCopy(newLit->function,lit->function,nVars);
253  newLit->transition = ABC_ALLOC(unsigned, Kit_TruthWordNum(nVars));
254  Kit_TruthCopy(newLit->transition,lit->transition,nVars);
255  newLit->expression = Vec_StrDup(lit->expression);
256 // Abc_Print(-2,"Copying: %s\n",newLit->expression->pArray);
257  return newLit;
258 }
static int Kit_TruthWordNum(int nVars)
Definition: kit.h:224
#define ABC_ALLOC(type, num)
Definition: abc_global.h:229
Vec_Str_t * expression
Definition: literal.h:55
unsigned * function
Definition: literal.h:54
unsigned * transition
Definition: literal.h:53
static void Kit_TruthCopy(unsigned *pOut, unsigned *pIn, int nVars)
Definition: kit.h:355
static Vec_Str_t * Vec_StrDup(Vec_Str_t *pVec)
Definition: vecStr.h:158
static Literal_t* Lit_CreateLiteralConst ( unsigned *  pTruth,
int  nVars,
int  constant 
)
inlinestatic

Function*************************************************************

Synopsis [Create a const literal ]

Description []

SideEffects []

SeeAlso []

Definition at line 237 of file literal.h.

237  {
238  Vec_Str_t * exp = Vec_StrAlloc(3);
239  Literal_t* lit;
240  Vec_StrPutC(exp, (char)('0' + constant));
241  Vec_StrPutC(exp, '\0');
242  lit = ABC_ALLOC(Literal_t, 1);
243  lit->expression = exp;
244  lit->function = pTruth;
245  lit->transition = pTruth; // wrong but no effect ###
246  return lit;
247 }
static void Vec_StrPutC(Vec_Str_t *vOut, char c)
Definition: vecStr.h:910
#define ABC_ALLOC(type, num)
Definition: abc_global.h:229
static Vec_Str_t * Vec_StrAlloc(int nCap)
Definition: bblif.c:495
Vec_Str_t * expression
Definition: literal.h:55
int lit
Definition: satVec.h:130
unsigned * function
Definition: literal.h:54
unsigned * transition
Definition: literal.h:53
static void Lit_Free ( Literal_t lit)
inlinestatic

Function*************************************************************

Synopsis [Delete the literal ]

Description []

SideEffects []

SeeAlso []

Definition at line 283 of file literal.h.

283  {
284  if(lit == NULL) {
285  return;
286  }
287 // Abc_Print(-2,"Freeing: %s\n",lit->expression->pArray);
288  ABC_FREE(lit->function);
289  ABC_FREE(lit->transition);
290  Vec_StrFree(lit->expression);
291  ABC_FREE(lit);
292 }
Vec_Str_t * expression
Definition: literal.h:55
static void Vec_StrFree(Vec_Str_t *p)
Definition: bblif.c:616
unsigned * function
Definition: literal.h:54
unsigned * transition
Definition: literal.h:53
#define ABC_FREE(obj)
Definition: abc_global.h:232
static Literal_t* Lit_GroupLiterals ( Literal_t lit1,
Literal_t lit2,
Operator_t  op,
int  nVars 
)
inlinestatic

Function*************************************************************

Synopsis [Group 2 literals using AND or OR]

Description []

SideEffects []

SeeAlso []

Definition at line 178 of file literal.h.

178  {
179  unsigned * newFunction = ABC_ALLOC(unsigned, Kit_TruthWordNum(nVars));
180  unsigned * newTransition = ABC_ALLOC(unsigned, Kit_TruthWordNum(nVars));
181  Vec_Str_t * newExp = Vec_StrAlloc(lit1->expression->nSize + lit2->expression->nSize + 3);
182  Literal_t* newLiteral;
183  char opChar = '%';
184  switch (op) {
185  case LIT_AND:
186  {
187  //Abc_Print(-2, "Grouping AND %X %X \n", *lit1->function, *lit2->function);
188  Kit_TruthAnd(newFunction, lit1->function, lit2->function, nVars);
189  opChar = '*';
190  break;
191  }
192  case LIT_OR:
193  {
194  //Abc_Print(-2, "Grouping OR %X %X \n", *lit1->function, *lit2->function);
195  Kit_TruthOr(newFunction, lit1->function, lit2->function, nVars);
196  opChar = '+';
197  break;
198  }
199  default:
200  {
201  Abc_Print(-2, "Lit_GroupLiterals with op not defined.");
202  //TODO Call ABC Abort
203  }
204  }
205 
206  Kit_TruthOr(newTransition, lit1->transition, lit2->transition, nVars);
207  // create a new expression.
208  Vec_StrPutC(newExp, '(');
209  Vec_StrAppend(newExp, lit1->expression->pArray);
210  //Vec_StrPop(newExp); // pop the \0
211  Vec_StrPutC(newExp, opChar);
212  Vec_StrAppend(newExp, lit2->expression->pArray);
213  //Vec_StrPop(newExp); // pop the \0
214  Vec_StrPutC(newExp, ')');
215  Vec_StrPutC(newExp, '\0');
216 
217  newLiteral = ABC_ALLOC(Literal_t, 1);
218  newLiteral->function = newFunction;
219  newLiteral->transition = newTransition;
220  newLiteral->expression = newExp;
221  return newLiteral;
222 }
Definition: literal.h:45
static int Kit_TruthWordNum(int nVars)
Definition: kit.h:224
static void Vec_StrPutC(Vec_Str_t *vOut, char c)
Definition: vecStr.h:910
#define ABC_ALLOC(type, num)
Definition: abc_global.h:229
static Vec_Str_t * Vec_StrAlloc(int nCap)
Definition: bblif.c:495
Vec_Str_t * expression
Definition: literal.h:55
static void Kit_TruthAnd(unsigned *pOut, unsigned *pIn0, unsigned *pIn1, int nVars)
Definition: kit.h:379
static void Vec_StrAppend(Vec_Str_t *p, const char *pString)
Definition: vecStr.h:645
char * pArray
Definition: bblif.c:51
static void Abc_Print(int level, const char *format,...)
Definition: abc_global.h:313
unsigned * function
Definition: literal.h:54
unsigned * transition
Definition: literal.h:53
int nSize
Definition: bblif.c:50
static void Kit_TruthOr(unsigned *pOut, unsigned *pIn0, unsigned *pIn1, int nVars)
Definition: kit.h:385
static void Lit_PrintExp ( Literal_t lit)
inlinestatic

Definition at line 267 of file literal.h.

267  {
268  Abc_Print(-2, "%s", lit->expression->pArray);
269 }
Vec_Str_t * expression
Definition: literal.h:55
char * pArray
Definition: bblif.c:51
static void Abc_Print(int level, const char *format,...)
Definition: abc_global.h:313
static void Lit_PrintTT ( unsigned *  tt,
int  nVars 
)
inlinestatic

Definition at line 260 of file literal.h.

260  {
261  int w;
262  for(w=nVars-1; w>=0; w--) {
263  Abc_Print(-2, "%08X", tt[w]);
264  }
265 }
static void Abc_Print(int level, const char *format,...)
Definition: abc_global.h:313
static void Lit_TruthNegativeTransition ( unsigned *  pIn,
unsigned *  pOut,
int  nVars,
int  varIdx 
)
inlinestatic

Function*************************************************************

Synopsis [Compute the negative transition]

Description [The inputs are a function, the number of variables and a variable index and the output is a function]

SideEffects [Should this function be in kitTruth.c ?]

SeeAlso []

Definition at line 103 of file literal.h.

104 {
105  unsigned * cof0 = ABC_ALLOC (unsigned, Kit_TruthWordNum(nVars) );
106  unsigned * cof1 = ABC_ALLOC (unsigned, Kit_TruthWordNum(nVars) );
107  unsigned * ncof1;
108  Kit_TruthCofactor0New(cof0, pIn,nVars,varIdx);
109  Kit_TruthCofactor1New(cof1, pIn,nVars,varIdx);
110  ncof1 = ABC_ALLOC (unsigned, Kit_TruthWordNum(nVars) );
111  Kit_TruthNot(ncof1,cof1,nVars);
112  Kit_TruthAnd(pOut,ncof1,cof0,nVars);
113  ABC_FREE(cof0);
114  ABC_FREE(cof1);
115  ABC_FREE(ncof1);
116 }
static int Kit_TruthWordNum(int nVars)
Definition: kit.h:224
#define ABC_ALLOC(type, num)
Definition: abc_global.h:229
static void Kit_TruthAnd(unsigned *pOut, unsigned *pIn0, unsigned *pIn1, int nVars)
Definition: kit.h:379
void Kit_TruthCofactor0New(unsigned *pOut, unsigned *pIn, int nVars, int iVar)
Definition: kitTruth.c:521
void Kit_TruthCofactor1New(unsigned *pOut, unsigned *pIn, int nVars, int iVar)
Definition: kitTruth.c:573
static void Kit_TruthNot(unsigned *pOut, unsigned *pIn, int nVars)
Definition: kit.h:373
#define ABC_FREE(obj)
Definition: abc_global.h:232
static void Lit_TruthPositiveTransition ( unsigned *  pIn,
unsigned *  pOut,
int  nVars,
int  varIdx 
)
inlinestatic

FUNCTION DEFINITIONS ///.

Function*************************************************************

Synopsis [Compute the positive transition]

Description [The inputs are a function, the number of variables and a variable index and the output is a function]

SideEffects [Should this function be in kitTruth.c ?]

SeeAlso []

Definition at line 75 of file literal.h.

76 {
77  unsigned * cof0 = ABC_ALLOC (unsigned, Kit_TruthWordNum(nVars) );
78  unsigned * cof1 = ABC_ALLOC (unsigned, Kit_TruthWordNum(nVars) );
79  unsigned * ncof0;
80  Kit_TruthCofactor0New(cof0, pIn,nVars,varIdx);
81  Kit_TruthCofactor1New(cof1, pIn,nVars,varIdx);
82  ncof0 = ABC_ALLOC (unsigned, Kit_TruthWordNum(nVars) );
83  Kit_TruthNot(ncof0,cof0,nVars);
84  Kit_TruthAnd(pOut,ncof0,cof1, nVars);
85  ABC_FREE(cof0);
86  ABC_FREE(ncof0);
87  ABC_FREE(cof1);
88 }
static int Kit_TruthWordNum(int nVars)
Definition: kit.h:224
#define ABC_ALLOC(type, num)
Definition: abc_global.h:229
static void Kit_TruthAnd(unsigned *pOut, unsigned *pIn0, unsigned *pIn1, int nVars)
Definition: kit.h:379
void Kit_TruthCofactor0New(unsigned *pOut, unsigned *pIn, int nVars, int iVar)
Definition: kitTruth.c:521
void Kit_TruthCofactor1New(unsigned *pOut, unsigned *pIn, int nVars, int iVar)
Definition: kitTruth.c:573
static void Kit_TruthNot(unsigned *pOut, unsigned *pIn, int nVars)
Definition: kit.h:373
#define ABC_FREE(obj)
Definition: abc_global.h:232