ABC: A System for Sequential Synthesis and Verification
 
Loading...
Searching...
No Matches
kitty_dynamic_tt.hpp
Go to the documentation of this file.
1#ifndef _KITTY_DYNAMIC_TT_H_
2#define _KITTY_DYNAMIC_TT_H_
3#pragma once
4
5#include <vector>
6#include <cstdint>
7#include <type_traits>
8
9#include "kitty_constants.hpp"
10
12
13namespace kitty
14{
15
19{
32 : _bits( ( num_vars <= 6 ) ? 1u : ( 1u << ( num_vars - 6 ) ) ),
33 _num_vars( num_vars )
34 {
35 }
36
44 dynamic_truth_table() : _num_vars( 0 ) {}
45
48 {
49 return dynamic_truth_table( _num_vars );
50 }
51
54 inline uint32_t num_vars() const noexcept { return _num_vars; }
55
58 inline uint32_t num_blocks() const noexcept { return _bits.size(); }
59
62 inline uint32_t num_bits() const noexcept { return uint64_t( 1 ) << _num_vars; }
63
66 inline std::vector<uint64_t>::iterator begin() noexcept { return _bits.begin(); }
67
70 inline std::vector<uint64_t>::iterator end() noexcept { return _bits.end(); }
71
74 inline std::vector<uint64_t>::const_iterator begin() const noexcept { return _bits.begin(); }
75
78 inline std::vector<uint64_t>::const_iterator end() const noexcept { return _bits.end(); }
79
82 inline std::vector<uint64_t>::reverse_iterator rbegin() noexcept { return _bits.rbegin(); }
83
86 inline std::vector<uint64_t>::reverse_iterator rend() noexcept { return _bits.rend(); }
87
90 inline std::vector<uint64_t>::const_iterator cbegin() const noexcept { return _bits.cbegin(); }
91
94 inline std::vector<uint64_t>::const_iterator cend() const noexcept { return _bits.cend(); }
95
98 inline std::vector<uint64_t>::const_reverse_iterator crbegin() const noexcept { return _bits.crbegin(); }
99
102 inline std::vector<uint64_t>::const_reverse_iterator crend() const noexcept { return _bits.crend(); }
103
111 template<class TT>
112 dynamic_truth_table& operator=( const TT& other )
113 {
114 _bits.resize( other.num_blocks() );
115 std::copy( other.begin(), other.end(), begin() );
116 _num_vars = other.num_vars();
117
118 if ( _num_vars < 6 )
119 {
120 mask_bits();
121 }
122
123 return *this;
124 }
125
132 inline void mask_bits() noexcept
133 {
134 if ( _num_vars < 6 )
135 {
136 _bits[0u] &= detail::masks[_num_vars];
137 }
138 }
139
141public: /* fields */
142 std::vector<uint64_t> _bits;
143 uint32_t _num_vars;
145};
146
147} //namespace kitty
148
150
151#endif // _KITTY_DYNAMIC_TT_H_
unsigned int uint32_t
Definition Fxch.h:32
#define ABC_NAMESPACE_CXX_HEADER_START
#define ABC_NAMESPACE_CXX_HEADER_END
std::vector< uint64_t >::const_iterator cend() const noexcept
Constant end iterator to bits.
dynamic_truth_table & operator=(const TT &other)
Assign other truth table.
std::vector< uint64_t >::const_reverse_iterator crbegin() const noexcept
Constant reverse begin iterator to bits.
uint32_t num_blocks() const noexcept
dynamic_truth_table(uint32_t num_vars)
std::vector< uint64_t >::reverse_iterator rbegin() noexcept
Reverse begin iterator to bits.
uint32_t num_bits() const noexcept
std::vector< uint64_t >::const_iterator begin() const noexcept
Begin iterator to bits.
std::vector< uint64_t >::reverse_iterator rend() noexcept
Reverse end iterator to bits.
uint32_t num_vars() const noexcept
std::vector< uint64_t >::iterator begin() noexcept
Begin iterator to bits.
dynamic_truth_table construct() const
std::vector< uint64_t >::iterator end() noexcept
End iterator to bits.
std::vector< uint64_t >::const_iterator cbegin() const noexcept
Constant begin iterator to bits.
std::vector< uint64_t >::const_iterator end() const noexcept
End iterator to bits.
std::vector< uint64_t >::const_reverse_iterator crend() const noexcept
Constant teverse end iterator to bits.
#define const
Definition zconf.h:196