start refactoring bitstream generation

This commit is contained in:
tangxifan 2019-10-23 17:34:21 -06:00
parent a18f1305cd
commit 2787a07f0d
3 changed files with 92 additions and 19 deletions

View File

@ -0,0 +1,46 @@
/******************************************************************************
* This file includes member functions for data structure BitstreamContext
******************************************************************************/
#include "vtr_assert.h"
#include "bitstream_context.h"
/**************************************************
* Public Accessors : Aggregates
*************************************************/
/* Find all the configuration bits */
BitstreamContext::config_bit_range BitstreamContext::bits() const {
return vtr::make_range(bit_ids_.begin(), bit_ids_.end());
}
/******************************************************************************
* Public Accessors
******************************************************************************/
bool BitstreamContext::bit_value(const ConfigBitId& bit_id) const {
/* Ensure a valid id */
VTR_ASSERT(true == valid_bit_id(bit_id));
return bit_values_[bit_id];
}
/******************************************************************************
* Public Mutators
******************************************************************************/
ConfigBitId BitstreamContext::add_bit(const bool& bit_value) {
ConfigBitId bit = ConfigBitId(bit_ids_.size());
/* Add a new bit, and allocate associated data structures */
bit_ids_.push_back(bit);
bit_values_.push_back(bit_value);
shared_config_bit_values_.emplace_back();
bit_parent_modules_.emplace_back();
bit_parent_instances_.emplace_back();
return bit;
}
/******************************************************************************
* Public Validators
******************************************************************************/
bool BitstreamContext::valid_bit_id(const ConfigBitId& bit_id) const {
return (size_t(bit_id) < bit_ids_.size()) && (bit_id == bit_ids_[bit_id]);
}

View File

@ -4,27 +4,54 @@
#ifndef BITSTREAM_CONTEXT_H #ifndef BITSTREAM_CONTEXT_H
#define BITSTREAM_CONTEXT_H #define BITSTREAM_CONTEXT_H
#include <vector>
#include "vtr_vector.h" #include "vtr_vector.h"
#include "module_manager.h"
#include "bitstream_context_fwd.h" #include "bitstream_context_fwd.h"
class BitstreamContext { class BitstreamContext {
private: /* Internal data */ public: /* Types and ranges */
enum e_sram_orgz config_scheme_; /* The type of configuration protocol */ typedef vtr::vector<ConfigBitId, ConfigBitId>::const_iterator config_bit_iterator;
CircuitModelId& sram_model_; /* The memory circuit model used by the Bitstream generation */
size_t num_memory_bits_; /* Number of memory bits */ typedef vtr::Range<config_bit_iterator> config_bit_range;
size_t num_bls_; /* Number of Bit Lines */
size_t num_wls_; /* Number of Word Lines */ public: /* Public aggregators */
/* Find all the configuration bits */
config_bit_range bits() const;
public: /* Public Accessors */
bool bit_value(const ConfigBitId& bit_id) const;
public: /* Public Mutators */
ConfigBitId add_bit(const bool& bit_value);
public: /* Public Validators */
bool valid_bit_id(const ConfigBitId& bit_id) const;
private: /* Internal data */
size_t num_shared_bits_; /* Number of reserved Bit/WL Lines, ONLY applicable to RRAM-based FPGA */
size_t num_reserved_bls_; /* Number of reserved Bit Lines, ONLY applicable to RRAM-based FPGA */
size_t num_reserved_wls_; /* Number of reserved Word Lines, ONLY applicable to RRAM-based FPGA */
/* Unique id of a bit in the Bitstream */ /* Unique id of a bit in the Bitstream */
vtr::vector<ConfigBitId, ConfigBitId> bit_ids_; vtr::vector<ConfigBitId, ConfigBitId> bit_ids_;
/* Bit line address of a bit in the Bitream: ONLY applicable to memory-decoders */ /* value of a bit in the Bitstream */
vtr::vector<ConfigBitId, size_t> bl_addr_; vtr::vector<ConfigBitId, bool> bit_values_;
/* Word line address of a bit in the Bitream: ONLY applicable to memory-decoders */ /* value of a shared configuration bits in the Bitstream */
vtr::vector<ConfigBitId, size_t> wl_addr_; vtr::vector<ConfigBitId, std::vector<bool>> shared_config_bit_values_;
/* value of a bit in the Bitream */
vtr::vector<ConfigBitId, bool> bit_val_; /* Back-annotation for the bits */
/* Parent Module of a bit in the Bitstream
* For each bit, the list of ModuleId and instance ids reflect its position in the module tree
* The first ModuleId/Instance is the direct parent module/instance of the bit
* while the last ModuleId/instance is the top-level module/instance of the bit
* For example: a bit could be back traced by
* <LastModuleId>[<LastInstanceId>]/.../<FirstModuleId>[<FirstInstanceId>]
*/
vtr::vector<ConfigBitId, std::vector<ModuleId>> bit_parent_modules_;
vtr::vector<ConfigBitId, std::vector<size_t>> bit_parent_instances_;
/* Fast lookup for bitstream */
std::map<std::string, ConfigBitId> bit_lookup_;
}; };
#endif #endif

View File

@ -1,14 +1,14 @@
/************************************************** /**************************************************
* This file includes only declarations for * This file includes only declarations for
* the data structures for module managers * the data structures for bitstream database
* Please refer to module_manager.h for more details * Please refer to bitstream_context.h for more details
*************************************************/ *************************************************/
#ifndef MODULE_MANAGER_FWD_H #ifndef BITSTREAM_CONTEXT_FWD_H
#define MODULE_MANAGER_FWD_H #define BITSTREAM_CONTEXT_MANAGER_FWD_H
#include "vtr_strong_id.h" #include "vtr_strong_id.h"
/* Strong Ids for ModuleManager */ /* Strong Ids for BitstreamContext */
struct config_bit_id_tag; struct config_bit_id_tag;
typedef vtr::StrongId<config_bit_id_tag> ConfigBitId; typedef vtr::StrongId<config_bit_id_tag> ConfigBitId;