-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBooleanFunction.h
63 lines (48 loc) · 1.61 KB
/
BooleanFunction.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
/*
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
* Click nbfs://nbhost/SystemFileSystem/Templates/cppFiles/class.h to edit this template
*/
/*
* File: BooleanFunction.h
* Author: anton
*
* Created on 20 luglio 2023, 16:48
*/
#ifndef BOOLEANFUNCTION_H
#define BOOLEANFUNCTION_H
#include <iostream>
#include <string>
#include <list>
using namespace std;
typedef struct{
string min;
bool used;
} Term ;
class BooleanFunction {
public:
//constructor
BooleanFunction(int __variables);
virtual ~BooleanFunction(){};
//asks P-Form minterms and fills into minterms
void askMinterms();
//adds a single minterm
bool addMinterm(string __minterm);
//prints minterms list into the stdout
void printMinterms() const;
//prints the boolean function's prime implicants(after calling McCluskeyMinimize
void printPrimeImplicants() const;
//fills minimized_minterms with the McCluskey algorithm
void McCluskeyMinimize();
private:
list<string> minterms;
int variables;
int n_minterms = 0;
list<string> minimized_minterms;
//McCluskey's definitions
bool checkMinterm(string __minterm) const;
int countOneOccurrences(string __minterm) const;
int getMintermsDifference(string __minterm1, string __minterm2) const;
Term combineMinterms(string __minterm1, string __minterm2) const;
list<Term>* generateLayer(list<Term>* p, list<string>& prime_implicants);
};
#endif /* BOOLEANFUNCTION_H */