HAL  v4.5.0-232-g8053ac4b3
The Hardware Analyzer - a comprehensive reverse engineering and manipulation framework for gate-level netlists.
hal::hgl_upgrade Namespace Reference

Functions

Result< std::vector< std::string > > upgrade_document (rapidjson::Document &document)
 
std::filesystem::path get_backup_path (const std::filesystem::path &file_path)
 
Result< std::filesystem::path > replace_file (const rapidjson::Document &document, const std::filesystem::path &file_path)
 

Variables

const u32 TARGET_VERSION = 6
 

Detailed Description

Upgrade of gate library files in HGL format from an older format version to version 6.

What changed in version 6:

  1. The flat LUT configuration {data_identifier, data_category, bit_order} is replaced by an output_pins array, where each entry specifies the output pin, its data_identifier, bit_offset, bit_count, is_ascending and input_pins.
  2. Each cell that carries init data gets a parameters section, so that INIT identifiers can be resolved by name and size: one bit_vector parameter of size 2^n per LUT identifier, of size 1 per flip-flop or latch identifier, and of size bit_size / count per RAM identifier.
  3. Legacy gate type properties without the c_ prefix (buffer, carry, mux, lut) are renamed to their canonical forms.

Function Documentation

◆ get_backup_path()

std::filesystem::path hal::hgl_upgrade::get_backup_path ( const std::filesystem::path &  file_path)

Get the file name the original gate library is kept under after its upgrade.

The .hgl extension is replaced by .json, so that the original file does not get selected as a gate library by accident.

Parameters
[in]file_path- The path of the gate library file.
Returns
The path of the backup file.

Definition at line 316 of file upgrade_hgl.cpp.

Referenced by replace_file().

◆ replace_file()

Result< std::filesystem::path > hal::hgl_upgrade::replace_file ( const rapidjson::Document &  document,
const std::filesystem::path &  file_path 
)

Replace a gate library file by an upgraded document.

The original file is renamed as given by get_backup_path and the document is written under the original name, so that projects referring to the gate library need no changes. If writing fails, the original file is restored.

Parameters
[in]document- The upgraded HGL document.
[in]file_path- The path of the gate library file to replace.
Returns
The path of the backup file on success, an error otherwise.

Definition at line 323 of file upgrade_hgl.cpp.

References ERR, get_backup_path(), OK, and hal::gate_library_manager::remove().

◆ upgrade_document()

Result< std::vector< std::string > > hal::hgl_upgrade::upgrade_document ( rapidjson::Document &  document)

Upgrade a parsed HGL document in place.

A document that is already at the target version is left unchanged. Cells that cannot be migrated automatically are left unchanged as well and reported by a warning.

Parameters
[in,out]document- The parsed HGL document.
Returns
A list of warnings, one per cell that requires manual migration, or an error if the document cannot be upgraded at all.

Definition at line 261 of file upgrade_hgl.cpp.

References ERR, OK, and TARGET_VERSION.

Variable Documentation

◆ TARGET_VERSION

const u32 hal::hgl_upgrade::TARGET_VERSION = 6

The format version gate libraries are upgraded to.

Definition at line 58 of file upgrade_hgl.h.

Referenced by upgrade_document().