-
Notifications
You must be signed in to change notification settings - Fork 0
/
shrinquem.h
52 lines (41 loc) · 1.21 KB
/
shrinquem.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
// shrinquem - An algorithm for logic minimization.
// Copyright (C) 2021 Damon Bohls <damonbohls@gmail.com>
// MIT License: https://github.com/d-bohls/shrinquem/blob/main/LICENSE
#if !defined(INC_SHRINQUEM_H)
#define INC_SHRINQUEM_H
typedef char triLogic;
#define LOGIC_FALSE (0)
#define LOGIC_TRUE (1)
#define LOGIC_DONT_CARE (2)
typedef enum
{
STATUS_OKAY = 0,
STATUS_TOO_FEW_VARIABLES,
STATUS_TOO_MANY_VARIABLES,
STATUS_OUT_OF_MEMORY,
STATUS_NULL_ARGUMENT,
} shrinquemStatus;
typedef struct SumOfProducts
{
unsigned long numVars;
unsigned long numTerms;
unsigned long* terms;
unsigned long* dontCares;
char* equation;
} SumOfProducts;
void FinalizeSumOfProducts(
SumOfProducts* sumOfProducts);
shrinquemStatus ReduceLogic(
const triLogic truthTable[],
SumOfProducts* sumOfProducts);
shrinquemStatus GenerateEquationString(
SumOfProducts* sumOfProducts,
const char** const varNames);
triLogic EvaluateSumOfProducts(
const SumOfProducts sumOfProducts,
const unsigned long input);
// functions used for metrics and testing
void ResetTermCounters();
unsigned long GetNumTermsKept();
unsigned long GetNumTermsRemoved();
#endif // !defined(INC_SHRINQUEM_H)