Change none-fabric to non-fabric

This commit is contained in:
chungshien 2024-02-20 21:05:13 -08:00
parent 654a3b2e96
commit 49cdb4e9c8
8 changed files with 76 additions and 76 deletions

View File

@ -13,9 +13,9 @@ This can define a hard-coded bitstream for a reconfigurable resource in FPGA fab
<openfpga_bitstream_setting>
<pb_type name="<string>" source="eblif" content=".param LUT" is_mode_select_bistream="true" bitstream_offset="1"/>
<interconnect name="<string>" default_path="<string>"/>
<none_fabric name="<string>" file="<string>">
<non_fabric name="<string>" file="<string>">
<pb name="<string>" type="<string>" content="<string>"/>
</none_fabric>
</non_fabric>
</openfpga_bitstream_setting>
pb_type-related Settings
@ -74,12 +74,12 @@ The following syntax are applicable to the XML definition tagged by ``interconne
The default path can be either ``iopad.inpad`` or ``ff.Q`` which corresponds to the first input and the second input respectively.
none_fabric-related Settings
non_fabric-related Settings
^^^^^^^^^^^^^^^^^^^^^^^^
This is special syntax to extract PB defined parameter or attribute and save the data into dedicated JSON file outside of fabric bitstream
The following syntax are applicable to the XML definition tagged by ``none-fabric`` in bitstream setting files.
The following syntax are applicable to the XML definition tagged by ``non_fabric`` in bitstream setting files.
.. option:: name="<string: pb_type top level name>"
@ -106,9 +106,9 @@ The following syntax are applicable to the XML definition tagged by ``none-fabri
For example,
.. code-block:: xml
<none_fabric name="bram" file="bram_bitstream.json">
<non_fabric name="bram" file="bram_bitstream.json">
<pb name=".bram_lr[mem_36K_tdp].mem_36K" content=".param INIT_i"/>
</none_fabric>
</non_fabric>
The final ``pb_type`` name is "bram.bram_lr[mem_36K_tdp].mem_36K"

View File

@ -102,8 +102,8 @@ std::string BitstreamSetting::default_path(
return interconnect_default_paths_[interconnect_setting_id];
}
std::vector<NoneFabricBitstreamSetting> BitstreamSetting::none_fabric() const {
return none_fabric_;
std::vector<NonFabricBitstreamSetting> BitstreamSetting::non_fabric() const {
return non_fabric_;
}
/************************************************************************
@ -158,23 +158,23 @@ BitstreamSetting::add_bitstream_interconnect_setting(
return interc_setting_id;
}
void BitstreamSetting::add_none_fabric(const std::string& name,
const std::string& file) {
void BitstreamSetting::add_non_fabric(const std::string& name,
const std::string& file) {
VTR_ASSERT(name.size());
VTR_ASSERT(file.size());
none_fabric_.push_back(NoneFabricBitstreamSetting(name, file));
non_fabric_.push_back(NonFabricBitstreamSetting(name, file));
}
void BitstreamSetting::add_none_fabric_pb(const std::string& pb,
const std::string& content) {
VTR_ASSERT(none_fabric_.size());
void BitstreamSetting::add_non_fabric_pb(const std::string& pb,
const std::string& content) {
VTR_ASSERT(non_fabric_.size());
VTR_ASSERT(content.find(".param ") == 0 || content.find(".attr ") == 0);
if (content.find(".param ") == 0) {
VTR_ASSERT(content.size() > 7);
none_fabric_.back().add_pb(pb, "param", content.substr(7));
non_fabric_.back().add_pb(pb, "param", content.substr(7));
} else {
VTR_ASSERT(content.size() > 6);
none_fabric_.back().add_pb(pb, "attr", content.substr(6));
non_fabric_.back().add_pb(pb, "attr", content.substr(6));
}
}

View File

@ -14,27 +14,27 @@
/* namespace openfpga begins */
namespace openfpga {
struct NoneFabricBitstreamPBSetting {
NoneFabricBitstreamPBSetting(const std::string& p = "",
const std::string& t = "",
const std::string& c = "")
struct NonFabricBitstreamPBSetting {
NonFabricBitstreamPBSetting(const std::string& p = "",
const std::string& t = "",
const std::string& c = "")
: pb(p), type(t), content(c) {}
const std::string pb = "";
const std::string type = "";
const std::string content = "";
};
struct NoneFabricBitstreamSetting {
NoneFabricBitstreamSetting(const std::string& n = "",
const std::string& f = "")
struct NonFabricBitstreamSetting {
NonFabricBitstreamSetting(const std::string& n = "",
const std::string& f = "")
: name(n), file(f) {}
void add_pb(const std::string& p, const std::string& t,
const std::string& c) {
pbs.push_back(NoneFabricBitstreamPBSetting(p, t, c));
pbs.push_back(NonFabricBitstreamPBSetting(p, t, c));
}
const std::string name = "";
const std::string file = "";
std::vector<NoneFabricBitstreamPBSetting> pbs;
std::vector<NonFabricBitstreamPBSetting> pbs;
};
/********************************************************************
@ -97,7 +97,7 @@ class BitstreamSetting {
const BitstreamInterconnectSettingId& interconnect_setting_id) const;
std::string default_path(
const BitstreamInterconnectSettingId& interconnect_setting_id) const;
std::vector<NoneFabricBitstreamSetting> none_fabric() const;
std::vector<NonFabricBitstreamSetting> non_fabric() const;
public: /* Public Mutators */
BitstreamPbTypeSettingId add_bitstream_pb_type_setting(
@ -117,8 +117,8 @@ class BitstreamSetting {
const std::vector<std::string>& parent_mode_names,
const std::string& default_path);
void add_none_fabric(const std::string& name, const std::string& file);
void add_none_fabric_pb(const std::string& pb, const std::string& content);
void add_non_fabric(const std::string& name, const std::string& file);
void add_non_fabric_pb(const std::string& pb, const std::string& content);
public: /* Public Validators */
bool valid_bitstream_pb_type_setting_id(
@ -161,7 +161,7 @@ class BitstreamSetting {
interconnect_parent_mode_names_;
vtr::vector<BitstreamInterconnectSettingId, std::string>
interconnect_default_paths_;
std::vector<NoneFabricBitstreamSetting> none_fabric_;
std::vector<NonFabricBitstreamSetting> non_fabric_;
};
} // namespace openfpga

View File

@ -77,28 +77,28 @@ static void read_xml_bitstream_interconnect_setting(
}
/********************************************************************
* Parse XML description for a none_fabric annotation under a <none_fabric> XML
* Parse XML description for a non_fabric annotation under a <non_fabric> XML
*node
*******************************************************************/
static void read_xml_none_fabric_bitstream_setting(
pugi::xml_node& xml_none_fabric, const pugiutil::loc_data& loc_data,
static void read_xml_non_fabric_bitstream_setting(
pugi::xml_node& xml_non_fabric, const pugiutil::loc_data& loc_data,
openfpga::BitstreamSetting& bitstream_setting) {
const std::string& name_attr =
get_attribute(xml_none_fabric, "name", loc_data).as_string();
get_attribute(xml_non_fabric, "name", loc_data).as_string();
const std::string& file_attr =
get_attribute(xml_none_fabric, "file", loc_data).as_string();
/* Add to none fabric */
bitstream_setting.add_none_fabric(name_attr, file_attr);
for (pugi::xml_node xml_child : xml_none_fabric.children()) {
get_attribute(xml_non_fabric, "file", loc_data).as_string();
/* Add to non-fabric */
bitstream_setting.add_non_fabric(name_attr, file_attr);
for (pugi::xml_node xml_child : xml_non_fabric.children()) {
if (xml_child.name() != std::string("pb")) {
bad_tag(xml_child, loc_data, xml_none_fabric, {"pb"});
bad_tag(xml_child, loc_data, xml_non_fabric, {"pb"});
}
const std::string& pb_name_attr =
get_attribute(xml_child, "name", loc_data).as_string();
const std::string& content_attr =
get_attribute(xml_child, "content", loc_data).as_string();
/* Add PB to none fabric */
bitstream_setting.add_none_fabric_pb(pb_name_attr, content_attr);
/* Add PB to non-fabric */
bitstream_setting.add_non_fabric_pb(pb_name_attr, content_attr);
}
}
@ -116,9 +116,9 @@ openfpga::BitstreamSetting read_xml_bitstream_setting(
/* Error out if the XML child has an invalid name! */
if ((xml_child.name() != std::string("pb_type")) &&
(xml_child.name() != std::string("interconnect")) &&
(xml_child.name() != std::string("none_fabric"))) {
(xml_child.name() != std::string("non_fabric"))) {
bad_tag(xml_child, loc_data, Node,
{"pb_type | interconnect | none_fabric"});
{"pb_type | interconnect | non_fabric"});
}
if (xml_child.name() == std::string("pb_type")) {
@ -128,9 +128,9 @@ openfpga::BitstreamSetting read_xml_bitstream_setting(
read_xml_bitstream_interconnect_setting(xml_child, loc_data,
bitstream_setting);
} else {
VTR_ASSERT_SAFE(xml_child.name() == std::string("none_fabric"));
read_xml_none_fabric_bitstream_setting(xml_child, loc_data,
bitstream_setting);
VTR_ASSERT_SAFE(xml_child.name() == std::string("non_fabric"));
read_xml_non_fabric_bitstream_setting(xml_child, loc_data,
bitstream_setting);
}
}

View File

@ -11,7 +11,7 @@
#include "command.h"
#include "command_context.h"
#include "command_exit_codes.h"
#include "extract_device_none_fabric_bitstream.h"
#include "extract_device_non_fabric_bitstream.h"
#include "globals.h"
#include "openfpga_digest.h"
#include "openfpga_naming.h"
@ -60,7 +60,7 @@ int fpga_bitstream_template(T& openfpga_ctx, const Command& cmd,
!cmd_context.option_enable(cmd, opt_no_time_stamp));
}
extract_device_none_fabric_bitstream(
extract_device_non_fabric_bitstream(
g_vpr_ctx, openfpga_ctx, cmd_context.option_enable(cmd, opt_verbose));
/* TODO: should identify the error code from internal function execution */

View File

@ -9,7 +9,7 @@
#include <vector>
/* Headers from vtrutil library */
#include "extract_device_none_fabric_bitstream.h"
#include "extract_device_non_fabric_bitstream.h"
#include "openfpga_pb_parser.h"
#include "pb_type_utils.h"
#include "vtr_assert.h"
@ -31,7 +31,7 @@ namespace openfpga {
*******************************************************************/
static bool extract_pb_data(std::fstream& fp, const AtomContext& atom_ctx,
const t_pb* op_pb, const t_pb_type* target_pb_type,
const NoneFabricBitstreamPBSetting& setting) {
const NonFabricBitstreamPBSetting& setting) {
t_pb_graph_node* pb_graph_node = op_pb->pb_graph_node;
t_pb_type* pb_type = pb_graph_node->pb_type;
bool found_pb = false;
@ -84,10 +84,10 @@ static bool extract_pb_data(std::fstream& fp, const AtomContext& atom_ctx,
/********************************************************************
* Extract data from the targetted PB (from that particular grid)
*******************************************************************/
static void extract_grid_none_fabric_bitstream(
static void extract_grid_non_fabric_bitstream(
std::fstream& fp, const VprContext& vpr_ctx,
const ClusterBlockId& cluster_block_id, const t_pb_type* target_pb_type,
const NoneFabricBitstreamPBSetting setting) {
const NonFabricBitstreamPBSetting setting) {
const ClusteringContext& clustering_ctx = vpr_ctx.clustering();
const AtomContext& atom_ctx = vpr_ctx.atom();
@ -102,8 +102,8 @@ static void extract_grid_none_fabric_bitstream(
/********************************************************************
* Extract data from the targetted PB (from the device)
*******************************************************************/
static void extract_device_none_fabric_pb_bitstream(
std::fstream& fp, const NoneFabricBitstreamPBSetting setting,
static void extract_device_non_fabric_pb_bitstream(
std::fstream& fp, const NonFabricBitstreamPBSetting setting,
const std::string& target_parent_pb_name, const t_pb_type* target_pb_type,
const VprContext& vpr_ctx) {
const DeviceContext& device_ctx = vpr_ctx.device();
@ -163,8 +163,8 @@ static void extract_device_none_fabric_pb_bitstream(
fp << " {\n";
fp << " \"x\" : " << (uint32_t)(ix) << ",\n";
fp << " \"y\" : " << (uint32_t)(iy);
extract_grid_none_fabric_bitstream(fp, vpr_ctx, cluster_blk_id,
target_pb_type, setting);
extract_grid_non_fabric_bitstream(fp, vpr_ctx, cluster_blk_id,
target_pb_type, setting);
fp << "\n }";
grid_count++;
}
@ -212,31 +212,31 @@ static t_pb_type* find_pb_type(const DeviceContext& device_ctx,
}
/********************************************************************
* A top-level function to extract data based on none-fabric bitstream setting
* A top-level function to extract data based on non-fabric bitstream setting
*******************************************************************/
void extract_device_none_fabric_bitstream(const VprContext& vpr_ctx,
const OpenfpgaContext& openfpga_ctx,
const bool& verbose) {
void extract_device_non_fabric_bitstream(const VprContext& vpr_ctx,
const OpenfpgaContext& openfpga_ctx,
const bool& verbose) {
std::string timer_message =
std::string("\nBuild none-fabric bitstream for implementation '") +
std::string("\nBuild non-fabric bitstream for implementation '") +
vpr_ctx.atom().nlist.netlist_name() + std::string("'\n");
vtr::ScopedStartFinishTimer timer(timer_message);
const openfpga::BitstreamSetting& bitstream_setting =
openfpga_ctx.bitstream_setting();
std::vector<NoneFabricBitstreamSetting> none_fabric_setting =
bitstream_setting.none_fabric();
std::vector<NonFabricBitstreamSetting> non_fabric_setting =
bitstream_setting.non_fabric();
// Only proceed if it is defined in bitstream_setting.xml
if (none_fabric_setting.size()) {
// Go through each none_fabric settting
for (auto setting : none_fabric_setting) {
if (non_fabric_setting.size()) {
// Go through each non_fabric settting
for (auto setting : non_fabric_setting) {
std::fstream fp;
fp.open(setting.file.c_str(), std::fstream::out);
fp << "{\n";
fp << " \"" << setting.name.c_str() << "\" : [\n";
if (setting.name == PRINT_LAYOUT_NAME) {
extract_device_none_fabric_pb_bitstream(
fp, NoneFabricBitstreamPBSetting{}, setting.name, nullptr, vpr_ctx);
extract_device_non_fabric_pb_bitstream(
fp, NonFabricBitstreamPBSetting{}, setting.name, nullptr, vpr_ctx);
} else {
int pb_count = 0;
// Extract each needed PB data
@ -262,8 +262,8 @@ void extract_device_none_fabric_bitstream(const VprContext& vpr_ctx,
fp << " \"content\" : \"" << pb_setting.content.c_str() << "\"";
if (target_pb_type != nullptr &&
is_primitive_pb_type(target_pb_type)) {
extract_device_none_fabric_pb_bitstream(
fp, pb_setting, setting.name, target_pb_type, vpr_ctx);
extract_device_non_fabric_pb_bitstream(fp, pb_setting, setting.name,
target_pb_type, vpr_ctx);
}
fp << "\n }";
pb_count++;

View File

@ -1,5 +1,5 @@
#ifndef EXTRACT_DEVICE_NONE_FABRIC_BITSTREAM_H
#define EXTRACT_DEVICE_NONE_FABRIC_BITSTREAM_H
#ifndef EXTRACT_DEVICE_NON_FABRIC_BITSTREAM_H
#define EXTRACT_DEVICE_NON_FABRIC_BITSTREAM_H
/********************************************************************
* Include header files that are required by function declaration
@ -16,9 +16,9 @@
/* begin namespace openfpga */
namespace openfpga {
void extract_device_none_fabric_bitstream(const VprContext& vpr_ctx,
const OpenfpgaContext& openfpga_ctx,
const bool& verbose);
void extract_device_non_fabric_bitstream(const VprContext& vpr_ctx,
const OpenfpgaContext& openfpga_ctx,
const bool& verbose);
} /* end namespace openfpga */

View File

@ -1,7 +1,7 @@
<openfpga_bitstream_setting>
<pb_type name="mult_16[mult_16x16].mult_16x16_slice.mult_16x16" source="eblif" content=".param MODE" is_mode_select_bitstream="true"/>
<pb_type name="mult_16[mult_8x8].mult_8x8_slice.mult_8x8" source="eblif" content=".param MODE" is_mode_select_bitstream="true"/>
<none_fabric name="mult_16" file="dsp.json">
<non_fabric name="mult_16" file="dsp.json">
<pb name="[mult_8x8].mult_8x8_slice.mult_8x8" content=".param MODE"/>
</none_fabric>
</non_fabric>
</openfpga_bitstream_setting>