HAL  v4.5.0-251-g305763a14
The Hardware Analyzer - a comprehensive reverse engineering and manipulation framework for gate-level netlists.
hal::LUTComponent Class Reference

#include <hal_core/netlist/gate_library/gate_type_component/lut_component.h>

Inheritance diagram for hal::LUTComponent:
Inheritance graph
Collaboration diagram for hal::LUTComponent:
Collaboration graph

Classes

struct  LUTOutputConfig
 

Public Member Functions

ComponentType get_type () const override
 
std::vector< GateTypeComponent * > get_components (const std::function< bool(const GateTypeComponent *)> &filter=nullptr) const override
 
const LUTOutputConfig * get_output_pin_config (const std::string &pin_name) const
 
const std::unordered_map< std::string, LUTOutputConfig > & get_output_pin_configs () const
 
Result< std::string > get_init_string (const Gate *gate, const std::string &pin_name) const
 
Result< std::string > get_init_string (const Gate *gate, const GatePin *pin) const
 
Result< std::monostate > set_init_string (Gate *gate, const std::string &pin_name, const std::string &hex) const
 
Result< std::monostate > set_init_string (Gate *gate, const GatePin *pin, const std::string &hex) const
 
- Public Member Functions inherited from hal::GateTypeComponent
virtual ~GateTypeComponent ()=default
 
template<typename T >
T * convert_to ()
 
template<typename T >
const T * convert_to () const
 
GateTypeComponent * get_component (const std::function< bool(const GateTypeComponent *)> &filter=nullptr) const
 
template<typename T >
T * get_component_as (const std::function< bool(const GateTypeComponent *)> &filter=nullptr)
 

Static Public Member Functions

static std::unique_ptr< LUTComponent > create (std::unordered_map< std::string, LUTOutputConfig > configs={})
 
static bool is_class_of (const GateTypeComponent *component)
 
static Result< std::string > extract_init_slice (const std::string &full_hex, u32 bit_offset, u32 bit_count)
 
static Result< std::string > splice_init_slice (const std::string &full_hex, const std::string &slice_hex, u32 bit_offset, u32 bit_count)
 

Additional Inherited Members

- Public Types inherited from hal::GateTypeComponent
enum class  ComponentType {
  lut , ff , latch , ram ,
  mac , init , state , ram_port ,
  state_table
}
 

Detailed Description

A gate type component that describes a look-up table, in particular the bit-order of its initialization string.

Definition at line 44 of file lut_component.h.

Member Function Documentation

◆ create()

std::unique_ptr< LUTComponent > hal::LUTComponent::create ( std::unordered_map< std::string, LUTOutputConfig >  configs = {})
static

Create a new LUTComponent with the given per-output-pin configurations. Configurations with a bit_count of zero, a non-power-of-two bit_count, or empty input_pins are silently skipped.

Parameters
[in]configs- Map from output pin name to LUTOutputConfig.
Returns
The new LUTComponent.

Definition at line 18 of file lut_component.cpp.

References log_error.

Referenced by hal::GateLibraryWizard::setComponents().

◆ extract_init_slice()

Result< std::string > hal::LUTComponent::extract_init_slice ( const std::string &  full_hex,
u32  bit_offset,
u32  bit_count 
)
static

Extract a bit slice from a full INIT hex string. Returns the slice as an uppercase hex string padded to (bit_count+3)/4 characters.

Parameters
[in]full_hex- Full INIT value as a hex string.
[in]bit_offset- First bit (LSB = 0) of the slice.
[in]bit_count- Number of bits in the slice; must be non-zero.
Returns
OK with the extracted hex string on success, an error otherwise.

Definition at line 70 of file lut_component.cpp.

References ERR, and OK.

Referenced by hal::gate_type_components_init().

◆ get_components()

std::vector< GateTypeComponent * > hal::LUTComponent::get_components ( const std::function< bool(const GateTypeComponent *)> &  filter = nullptr) const
overridevirtual

Get the sub-components of the gate type component. A user-defined filter may be applied to the result vector, but is disabled by default.

Parameters
[in]filter- The user-defined filter function applied to all candidate components.
Returns
The sub-components of the gate type component.

Implements hal::GateTypeComponent.

Definition at line 51 of file lut_component.cpp.

◆ get_init_string() [1/2]

Result< std::string > hal::LUTComponent::get_init_string ( const Gate *  gate,
const GatePin *  pin 
) const

Get the INIT hex string for a specific LUT output pin on a gate instance.

Parameters
[in]gate- The gate instance.
[in]pin- The output pin.
Returns
OK with the hex INIT string (no prefix) on success, an error otherwise.

Definition at line 186 of file lut_component.cpp.

References hal::LUTComponent::LUTOutputConfig::bit_count, hal::LUTComponent::LUTOutputConfig::bit_offset, ERR, hal::BasePin< T >::get_direction(), hal::Gate::get_name(), hal::BasePin< T >::get_name(), hal::BasePin< T >::get_type(), hal::LUTComponent::LUTOutputConfig::init_identifier, and OK.

◆ get_init_string() [2/2]

Result< std::string > hal::LUTComponent::get_init_string ( const Gate *  gate,
const std::string &  pin_name 
) const

Get the INIT hex string for a specific LUT output pin on a gate instance. The pin must be of type PinType::lut and have a configured LUTOutputConfig.

Parameters
[in]gate- The gate instance.
[in]pin_name- The output pin name.
Returns
OK with the hex INIT string (no prefix) on success, an error otherwise.

Definition at line 172 of file lut_component.cpp.

References ERR, hal::GateType::get_name(), hal::GateType::get_pin_by_name(), and hal::Gate::get_type().

Referenced by hal::resynthesis::decompose_gates_of_type(), hal::resynthesis::resynthesize_gates(), and hal::xilinx_toolbox::split_lut().

◆ get_output_pin_config()

const LUTComponent::LUTOutputConfig * hal::LUTComponent::get_output_pin_config ( const std::string &  pin_name) const

Get the output configuration for a specific pin, or nullptr if none is set.

Parameters
[in]pin_name- Name of the LUT output pin.
Returns
Pointer to the LUTOutputConfig, or nullptr.

Definition at line 56 of file lut_component.cpp.

Referenced by hal::Gate::add_boolean_function().

◆ get_output_pin_configs()

const std::unordered_map< std::string, LUTComponent::LUTOutputConfig > & hal::LUTComponent::get_output_pin_configs ( ) const

◆ get_type()

LUTComponent::ComponentType hal::LUTComponent::get_type ( ) const
overridevirtual

Get the type of the gate type component.

Returns
The type of the gate type component.

Implements hal::GateTypeComponent.

Definition at line 41 of file lut_component.cpp.

◆ is_class_of()

bool hal::LUTComponent::is_class_of ( const GateTypeComponent *  component)
static

Check whether a component is a LUTComponent.

Parameters
[in]component- The component to check.
Returns
true if component is a LUTComponent, false otherwise.

Definition at line 46 of file lut_component.cpp.

References hal::GateTypeComponent::get_type().

Referenced by hal::gate_type_components_init(), hal::verilator::converter::get_function_for_lut(), hal::LUTWizardPage::setData(), hal::GatelibraryFrameLut::update(), and hal::GatelibraryLutInit::update().

◆ set_init_string() [1/2]

Result< std::monostate > hal::LUTComponent::set_init_string ( Gate *  gate,
const GatePin *  pin,
const std::string &  hex 
) const

Set the INIT hex string for a specific LUT output pin on a gate instance.

Parameters
[in]gate- The gate instance.
[in]pin- The output pin.
[in]hex- Hex string (no prefix, uppercase or lowercase).
Returns
OK on success, an error otherwise.

Definition at line 233 of file lut_component.cpp.

References hal::LUTComponent::LUTOutputConfig::bit_count, hal::LUTComponent::LUTOutputConfig::bit_offset, ERR, hal::BasePin< T >::get_direction(), hal::Gate::get_name(), hal::BasePin< T >::get_name(), hal::BasePin< T >::get_type(), hal::LUTComponent::LUTOutputConfig::init_identifier, OK, and hal::DataContainer::set_parameter().

◆ set_init_string() [2/2]

Result< std::monostate > hal::LUTComponent::set_init_string ( Gate *  gate,
const std::string &  pin_name,
const std::string &  hex 
) const

Set the INIT hex string for a specific LUT output pin on a gate instance. The hex string must be exactly (bit_count + 3) / 4 hex digits with no prefix.

Parameters
[in]gate- The gate instance.
[in]pin_name- The output pin name.
[in]hex- Hex string (no prefix, uppercase or lowercase).
Returns
OK on success, an error otherwise.

Definition at line 219 of file lut_component.cpp.

References ERR, hal::GateType::get_name(), hal::GateType::get_pin_by_name(), and hal::Gate::get_type().

◆ splice_init_slice()

Result< std::string > hal::LUTComponent::splice_init_slice ( const std::string &  full_hex,
const std::string &  slice_hex,
u32  bit_offset,
u32  bit_count 
)
static

Splice a new slice value into a full INIT hex string at [bit_offset, bit_offset+bit_count). The output preserves the digit width of full_hex; if full_hex is empty the minimum width needed to hold the splice is used.

Parameters
[in]full_hex- Current full INIT value as a hex string (may be empty).
[in]slice_hex- New value for the bit slice.
[in]bit_offset- First bit (LSB = 0) of the slice.
[in]bit_count- Number of bits in the slice; must be non-zero.
Returns
OK with the updated full hex string on success, an error on parse failure.

Definition at line 111 of file lut_component.cpp.

References ERR, and OK.

Referenced by hal::gate_type_components_init().


The documentation for this class was generated from the following files: