ABC: A System for Sequential Synthesis and Verification
 
Loading...
Searching...
No Matches
rrrAbc.h
Go to the documentation of this file.
1#pragma once
2
3#include "aig/gia/gia.h"
4#include "base/main/main.h"
5#include "base/cmd/cmd.h"
6
7#include "rrrUtils.h"
8
10
11namespace rrr {
12
13 template <typename Ntk>
14 void GiaReader(Gia_Man_t *pGia, Ntk *pNtk) {
15 int i;
16 Gia_Obj_t *pObj;
17 pNtk->Reserve(Gia_ManObjNum(pGia));
18 Gia_ManConst0(pGia)->Value = pNtk->GetConst0();
19 Gia_ManForEachObj1(pGia, pObj, i) {
20 if(Gia_ObjIsCi(pObj)) {
21 pObj->Value = pNtk->AddPi();
22 } else if(Gia_ObjIsCo(pObj)) {
23 pNtk->AddPo(Gia_ObjFanin0(pObj)->Value, Gia_ObjFaninC0(pObj));
24 } else {
25 // TODO: support XOR (and BUF and MUX?), maybe create another function
26 pObj->Value = pNtk->AddAnd(Gia_ObjFanin0(pObj)->Value, Gia_ObjFanin1(pObj)->Value, Gia_ObjFaninC0(pObj), Gia_ObjFaninC1(pObj));
27 }
28 }
29 }
30
31 template <typename Ntk>
32 Gia_Man_t *CreateGia(Ntk *pNtk, bool fHash = true) {
33 Gia_Man_t *pGia = Gia_ManStart(pNtk->GetNumNodes());
34 if(fHash) {
35 Gia_ManHashStart(pGia);
36 }
37 std::vector<int> v(pNtk->GetNumNodes());
38 v[0] = Gia_ManConst0Lit();
39 pNtk->ForEachPi([&](int id) {
40 v[id] = Gia_ManAppendCi(pGia);
41 });
42 pNtk->ForEachInt([&](int id) {
43 assert(pNtk->GetNodeType(id) == rrr::AND);
44 int x = -1;
45 pNtk->ForEachFanin(id, [&](int fi, bool c) {
46 if(x == -1) {
47 x = Abc_LitNotCond(v[fi], c);
48 } else if(fHash) {
49 x = Gia_ManHashAnd(pGia, x, Abc_LitNotCond(v[fi], c));
50 } else {
51 x = Gia_ManAppendAnd(pGia, x, Abc_LitNotCond(v[fi], c));
52 }
53 });
54 if(x == -1) {
55 x = Abc_LitNot(v[0]);
56 }
57 v[id] = x;
58 });
59 pNtk->ForEachPoDriver([&](int fi, bool c) {
60 Gia_ManAppendCo(pGia, Abc_LitNotCond(v[fi], c));
61 });
62 if(fHash) {
63 Gia_ManHashStop(pGia);
64 }
65 return pGia;
66 }
67
68 template <typename Ntk>
69 void Abc9Execute(Ntk *pNtk, std::string Command) {
71 Abc_FrameUpdateGia(pAbc, CreateGia(pNtk));
73 int r = Cmd_CommandExecute(pAbc, Command.c_str());
74 assert(r == 0);
75 } else {
77 int r = Cmd_CommandExecute(pAbc, Command.c_str());
78 assert(r == 0);
80 }
81 pNtk->Read(Abc_FrameReadGia(pAbc), GiaReader<Ntk>, false);
82 }
83
84}
85
void Abc_FrameUpdateGia(Abc_Frame_t *pAbc, Gia_Man_t *pNew)
Definition abc.c:824
#define ABC_NAMESPACE_CXX_HEADER_START
#define ABC_NAMESPACE_CXX_HEADER_END
typedefABC_NAMESPACE_HEADER_START struct Abc_Frame_t_ Abc_Frame_t
INCLUDES ///.
Definition abcapis.h:38
ABC_DLL Abc_Frame_t * Abc_FrameGetGlobalFrame()
Definition mainFrame.c:643
ABC_DLL void Abc_FrameSetBatchMode(int Mode)
Definition mainFrame.c:111
ABC_DLL Gia_Man_t * Abc_FrameReadGia(Abc_Frame_t *p)
Definition mainFrame.c:343
ABC_DLL int Abc_FrameIsBatchMode()
Definition mainFrame.c:110
ABC_DLL int Cmd_CommandExecute(Abc_Frame_t *pAbc, const char *sCommand)
Definition cmdApi.c:193
void Gia_ManHashStart(Gia_Man_t *p)
Definition giaHash.c:125
Gia_Man_t * Gia_ManStart(int nObjsMax)
FUNCTION DEFINITIONS ///.
Definition giaMan.c:57
struct Gia_Obj_t_ Gia_Obj_t
Definition gia.h:76
struct Gia_Man_t_ Gia_Man_t
Definition gia.h:96
#define Gia_ManForEachObj1(p, pObj, i)
Definition gia.h:1192
int Gia_ManHashAnd(Gia_Man_t *p, int iLit0, int iLit1)
Definition giaHash.c:576
void Gia_ManHashStop(Gia_Man_t *p)
Definition giaHash.c:149
Definition rrr.h:16
void Abc9Execute(Ntk *pNtk, std::string Command)
Definition rrrAbc.h:69
void GiaReader(Gia_Man_t *pGia, Ntk *pNtk)
Definition rrrAbc.h:14
Gia_Man_t * CreateGia(Ntk *pNtk, bool fHash=true)
Definition rrrAbc.h:32
@ AND
Definition rrrTypes.h:13
unsigned Value
Definition gia.h:89
#define assert(ex)
Definition util_old.h:213