-
Notifications
You must be signed in to change notification settings - Fork 0
/
TechLibrary.h
78 lines (61 loc) · 1.62 KB
/
TechLibrary.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#ifndef TECHLIBRARY_H
#define TECHLIBRARY_H
#include <bitset>
#include <string>
#include <tr1/unordered_set>
#include <boost/functional/hash.hpp>
// currently, all cells with > 8 inputs does not use truth table and still
// uses blif
class lib_cell {
public:
lib_cell(int num_inputs_, std::string blif_) :
num_inputs(num_inputs_), blif(blif_) {}
/*!
* Simulate output given input given by string of 0/1s
*/
int simulate(std::string& inputstr);
int get_minterm(int row)
{
return ttable[row];
}
void set_minterm(int row, int result)
{
ttable[row] = result;
}
unsigned long get_table_value() const
{
return ttable.to_ulong();
}
std::string get_blif() const
{
return blif;
}
private:
int num_inputs; // Number of inputs
std::bitset<256> ttable; // Truth table, for <= 8 inputs only
std::string blif; // blif ttable representation
};
struct lib_cell_hash {
size_t operator()(const lib_cell* cell) const
{
return boost::hash_value(cell->get_blif());
}
};
// ?! allow blif to be build from ttable ?? (in old circuit)
/*!
* Collection of cells containing truth tables for simulation.
*/
class TechLibrary {
public:
/*!
* Create a library cell and add it to the heap and return
* the cell (or return a previously created library cell)
*/
lib_cell* create_libcell(std::string blif, int num_inputs);
~TechLibrary();
private:
//! each cell has only one output
typedef std::tr1::unordered_set<lib_cell*, lib_cell_hash> Library_t;
Library_t cells;
};
#endif