ABC: A System for Sequential Synthesis and Verification
 
Loading...
Searching...
No Matches
kitty_static_tt.hpp
Go to the documentation of this file.
1#ifndef _KITTY_STATIC_TT_H_
2#define _KITTY_STATIC_TT_H_
3#pragma once
4
5#include <array>
6#include <cstdint>
7
8#include "kitty_constants.hpp"
9
11
12namespace kitty
13{
14
15template<uint32_t NumVars, bool = ( NumVars <= 6 )>
16struct static_truth_table;
17
20template<uint32_t NumVars>
22{
24 enum
25 {
26 NumBits = uint64_t( 1 ) << NumVars
27 };
29
35
38 inline uint32_t num_vars() const noexcept { return NumVars; }
39
42 inline uint32_t num_blocks() const noexcept { return 1u; }
43
46 inline uint32_t num_bits() const noexcept { return NumBits; }
47
50 inline uint64_t * begin() noexcept { return &_bits; }
51
54 inline uint64_t * end() noexcept { return ( &_bits ) + 1; }
55
58 inline const uint64_t * begin() const noexcept { return &_bits; }
59
62 inline const uint64_t * end() const noexcept { return ( &_bits ) + 1; }
63
66 inline uint64_t * rbegin() noexcept { return &_bits; }
67
70 inline uint64_t * rend() noexcept { return ( &_bits ) + 1; }
71
74 inline const uint64_t * cbegin() const noexcept { return &_bits; }
75
78 inline const uint64_t * cend() const noexcept { return ( &_bits ) + 1; }
79
82 inline const uint64_t * crbegin() const noexcept { return &_bits; }
83
86 inline const uint64_t * crend() const noexcept { return ( &_bits ) + 1; }
87
96 template<class TT>
98 {
99 if ( other.num_vars() == num_vars() )
100 {
101 std::copy( other.begin(), other.end(), begin() );
102 }
103
104 return *this;
105 }
106
113 inline void mask_bits() noexcept { _bits &= detail::masks[NumVars]; }
114
116public: /* fields */
117 uint64_t _bits = 0;
119};
120
123template<uint32_t NumVars>
125{
127 enum
128 {
129 NumBlocks = ( NumVars <= 6 ) ? 1u : ( 1u << ( NumVars - 6 ) )
130 };
131
132 enum
133 {
134 NumBits = uint64_t( 1 ) << NumVars
135 };
137
145 {
146 _bits.fill( 0 );
147 }
148
151 {
153 }
154
157 inline uint32_t num_vars() const noexcept { return NumVars; }
158
161 inline uint32_t num_blocks() const noexcept { return NumBlocks; }
162
165 inline uint32_t num_bits() const noexcept { return NumBits; }
166
169 inline typename std::array<uint64_t, NumBlocks>::iterator begin() noexcept { return _bits.begin(); }
170
173 inline typename std::array<uint64_t, NumBlocks>::iterator end() noexcept { return _bits.end(); }
174
177 inline typename std::array<uint64_t, NumBlocks>::const_iterator begin() const noexcept { return _bits.begin(); }
178
181 inline typename std::array<uint64_t, NumBlocks>::const_iterator end() const noexcept { return _bits.end(); }
182
185 inline typename std::array<uint64_t, NumBlocks>::reverse_iterator rbegin() noexcept { return _bits.rbegin(); }
186
189 inline typename std::array<uint64_t, NumBlocks>::reverse_iterator rend() noexcept { return _bits.rend(); }
190
193 inline typename std::array<uint64_t, NumBlocks>::const_iterator cbegin() const noexcept { return _bits.cbegin(); }
194
197 inline typename std::array<uint64_t, NumBlocks>::const_iterator cend() const noexcept { return _bits.cend(); }
198
201 inline typename std::array<uint64_t, NumBlocks>::const_reverse_iterator crbegin() const noexcept { return _bits.crbegin(); }
202
205 inline typename std::array<uint64_t, NumBlocks>::const_reverse_iterator crend() const noexcept { return _bits.crend(); }
206
215 template<class TT>
217 {
218 if ( other.num_bits() == num_bits() )
219 {
220 std::copy( other.begin(), other.end(), begin() );
221 }
222
223 return *this;
224 }
225
231 inline void mask_bits() noexcept {}
232
234public: /* fields */
235 std::array<uint64_t, NumBlocks> _bits;
237};
238
239} //namespace kitty
240
242
243#endif // _KITTY_STATIC_TT_H_
unsigned int uint32_t
Definition Fxch.h:32
#define ABC_NAMESPACE_CXX_HEADER_START
#define ABC_NAMESPACE_CXX_HEADER_END
std::array< uint64_t, NumBlocks >::iterator end() noexcept
End iterator to bits.
static_truth_table< NumVars > construct() const
std::array< uint64_t, NumBlocks >::const_iterator cend() const noexcept
Constant end iterator to bits.
std::array< uint64_t, NumBlocks >::reverse_iterator rend() noexcept
Reverse end iterator to bits.
std::array< uint64_t, NumBlocks >::const_reverse_iterator crend() const noexcept
Constant teverse end iterator to bits.
std::array< uint64_t, NumBlocks >::iterator begin() noexcept
Begin iterator to bits.
static_truth_table< NumVars > & operator=(const TT &other)
Assign other truth table if number of variables match.
std::array< uint64_t, NumBlocks >::reverse_iterator rbegin() noexcept
Reverse begin iterator to bits.
std::array< uint64_t, NumBlocks >::const_reverse_iterator crbegin() const noexcept
Constant reverse begin iterator to bits.
std::array< uint64_t, NumBlocks >::const_iterator begin() const noexcept
Begin iterator to bits.
std::array< uint64_t, NumBlocks >::const_iterator end() const noexcept
End iterator to bits.
std::array< uint64_t, NumBlocks >::const_iterator cbegin() const noexcept
Constant begin iterator to bits.
const uint64_t * crend() const noexcept
Constant everse end iterator to bits.
uint64_t * begin() noexcept
Begin iterator to bits.
uint64_t * rbegin() noexcept
Reverse begin iterator to bits.
const uint64_t * crbegin() const noexcept
Constant reverse begin iterator to bits.
const uint64_t * begin() const noexcept
Begin iterator to bits.
uint64_t * rend() noexcept
Reverse end iterator to bits.
uint64_t * end() noexcept
End iterator to bits.
static_truth_table< NumVars > & operator=(const TT &other)
Assign other truth table if number of variables match.
const uint64_t * end() const noexcept
End iterator to bits.
static_truth_table< NumVars > construct() const
const uint64_t * cbegin() const noexcept
Constant begin iterator to bits.
const uint64_t * cend() const noexcept
Constant end iterator to bits.
#define const
Definition zconf.h:196