2020-02-21 18:47:27 -06:00
|
|
|
#ifndef PHYSICAL_PB_H
|
|
|
|
#define PHYSICAL_PB_H
|
|
|
|
|
|
|
|
/********************************************************************
|
|
|
|
* Include header files required by the data structure definition
|
|
|
|
*******************************************************************/
|
|
|
|
/* Headers from vtrutil library */
|
|
|
|
#include "vtr_geometry.h"
|
|
|
|
#include "vtr_vector.h"
|
|
|
|
|
|
|
|
/* Headers from readarch library */
|
|
|
|
#include "physical_types.h"
|
|
|
|
|
|
|
|
/* Headers from vpr library */
|
2020-02-25 14:34:13 -06:00
|
|
|
#include "atom_netlist.h"
|
2020-02-21 18:47:27 -06:00
|
|
|
|
|
|
|
#include "physical_pb_fwd.h"
|
|
|
|
|
|
|
|
/* Begin namespace openfpga */
|
|
|
|
namespace openfpga {
|
|
|
|
|
|
|
|
/********************************************************************
|
|
|
|
* PhysicalPb object aims to store the mapped result for a programmable
|
|
|
|
* logical block like the VPR data structure t_pb does.
|
|
|
|
* Differently, it is tailored for the physical implementation of a
|
|
|
|
* programmable block.
|
|
|
|
* - It does not contain multi-mode for each child physical_pb while
|
|
|
|
* VPR t_pb does have multi-mode. This is because that the hardware
|
|
|
|
* implementation is unique
|
|
|
|
* - It contains mode-selection bits for each primitive physical_pb
|
|
|
|
* This is used to help bitstream generator to configure a primitive
|
|
|
|
* circuit in the correct mode
|
|
|
|
* - A primitive LUT can be mapped to various truth tables.
|
|
|
|
* This is true for any fracturable LUTs.
|
|
|
|
*******************************************************************/
|
|
|
|
class PhysicalPb {
|
|
|
|
public: /* Types and ranges */
|
|
|
|
typedef vtr::vector<PhysicalPbId, PhysicalPbId>::const_iterator physical_pb_iterator;
|
|
|
|
typedef vtr::Range<physical_pb_iterator> physical_pb_range;
|
|
|
|
public: /* Public aggregators */
|
|
|
|
physical_pb_range pbs() const;
|
|
|
|
std::string name(const PhysicalPbId& pb) const;
|
|
|
|
PhysicalPbId find_pb(const t_pb_graph_node* name) const;
|
|
|
|
PhysicalPbId parent(const PhysicalPbId& pb) const;
|
2020-02-24 20:38:02 -06:00
|
|
|
PhysicalPbId child(const PhysicalPbId& pb,
|
|
|
|
const t_pb_type* pb_type,
|
|
|
|
const size_t& index) const;
|
|
|
|
std::vector<AtomBlockId> atom_blocks(const PhysicalPbId& pb) const;
|
2020-02-21 21:39:49 -06:00
|
|
|
AtomNetId pb_graph_pin_atom_net(const PhysicalPbId& pb,
|
|
|
|
const t_pb_graph_pin* pb_graph_pin) const;
|
2020-02-25 14:34:13 -06:00
|
|
|
AtomNetlist::TruthTable truth_table(const PhysicalPbId& pb) const;
|
2020-02-24 20:38:02 -06:00
|
|
|
std::vector<size_t> mode_bits(const PhysicalPbId& pb) const;
|
2020-02-21 18:47:27 -06:00
|
|
|
public: /* Public mutators */
|
|
|
|
PhysicalPbId create_pb(const t_pb_graph_node* pb_graph_node);
|
|
|
|
void add_child(const PhysicalPbId& parent,
|
|
|
|
const PhysicalPbId& child,
|
|
|
|
const t_pb_type* child_type);
|
2020-02-21 21:39:49 -06:00
|
|
|
void add_atom_block(const PhysicalPbId& pb,
|
|
|
|
const AtomBlockId& atom_block);
|
2020-02-25 14:34:13 -06:00
|
|
|
void set_truth_table(const PhysicalPbId& pb,
|
|
|
|
const AtomNetlist::TruthTable& truth_table);
|
2020-02-21 21:39:49 -06:00
|
|
|
void set_mode_bits(const PhysicalPbId& pb,
|
|
|
|
const std::vector<size_t>& mode_bits);
|
|
|
|
void set_pb_graph_pin_atom_net(const PhysicalPbId& pb,
|
|
|
|
const t_pb_graph_pin* pb_graph_pin,
|
|
|
|
const AtomNetId& atom_net);
|
2020-02-21 18:47:27 -06:00
|
|
|
public: /* Public validators/invalidators */
|
|
|
|
bool valid_pb_id(const PhysicalPbId& pb_id) const;
|
|
|
|
bool empty() const;
|
|
|
|
private: /* Internal Data */
|
|
|
|
vtr::vector<PhysicalPbId, PhysicalPbId> pb_ids_;
|
|
|
|
vtr::vector<PhysicalPbId, const t_pb_graph_node*> pb_graph_nodes_;
|
|
|
|
vtr::vector<PhysicalPbId, std::string> names_;
|
2020-02-21 21:39:49 -06:00
|
|
|
vtr::vector<PhysicalPbId, std::vector<AtomBlockId>> atom_blocks_;
|
|
|
|
vtr::vector<PhysicalPbId, std::map<const t_pb_graph_pin*, AtomNetId>> pin_atom_nets_;
|
2020-02-21 18:47:27 -06:00
|
|
|
|
|
|
|
/* Child pbs are organized as [0..num_child_pb_types-1][0..child_pb_type->num_pb-1] */
|
|
|
|
vtr::vector<PhysicalPbId, std::map<const t_pb_type*, std::vector<PhysicalPbId>>> child_pbs_;
|
|
|
|
vtr::vector<PhysicalPbId, PhysicalPbId> parent_pbs_;
|
|
|
|
|
2020-02-25 14:34:13 -06:00
|
|
|
/* configuration bits
|
|
|
|
* Truth tables and mode selection
|
|
|
|
*/
|
|
|
|
vtr::vector<PhysicalPbId, AtomNetlist::TruthTable> truth_tables_;
|
|
|
|
|
2020-02-21 18:47:27 -06:00
|
|
|
vtr::vector<PhysicalPbId, std::vector<size_t>> mode_bits_;
|
|
|
|
|
|
|
|
/* Fast lookup */
|
|
|
|
std::map<const t_pb_graph_node*, PhysicalPbId> type2id_map_;
|
|
|
|
};
|
|
|
|
|
|
|
|
} /* End namespace openfpga*/
|
|
|
|
|
|
|
|
#endif
|