1
1
#include " fasm.h"
2
2
3
3
#include < algorithm>
4
- #include < fstream>
5
- #include < iomanip>
6
4
#include < iostream>
7
- #include < iterator>
8
5
#include < set>
9
6
#include < sstream>
10
7
#include < string>
11
- #include < unordered_map>
12
8
13
9
#include " globals.h"
14
10
15
11
#include " rr_metadata.h"
16
12
17
13
#include " vtr_assert.h"
18
14
#include " vtr_logic.h"
19
- #include " vtr_version.h"
20
15
#include " vpr_error.h"
21
16
22
17
#include " atom_netlist_utils.h"
23
- #include " netlist_writer.h"
24
- #include " vpr_utils.h"
25
18
26
19
#include " fasm_utils.h"
27
20
@@ -77,7 +70,7 @@ void FasmWriterVisitor::visit_clb_impl(ClusterBlockId blk_id, const t_pb* clb) {
77
70
std::vector<std::string> tag_defs = vtr::split (value->front ().as_string ().get (strings_), " \n " );
78
71
for (auto & tag_def: tag_defs) {
79
72
auto parts = split_fasm_entry (tag_def, " =:" , " \t " );
80
- if (parts.size () == 0 ) {
73
+ if (parts.empty () ) {
81
74
continue ;
82
75
}
83
76
@@ -86,7 +79,7 @@ void FasmWriterVisitor::visit_clb_impl(ClusterBlockId blk_id, const t_pb* clb) {
86
79
VTR_ASSERT (tags_.count (parts.at (0 )) == 0 );
87
80
88
81
// When the value is "NULL" then substitute empty string
89
- if (! parts.at (1 ). compare ( " NULL" ) ) {
82
+ if (parts.at (1 ) == " NULL" ) {
90
83
tags_[parts.at (0 )] = " " ;
91
84
}
92
85
else {
@@ -179,7 +172,7 @@ std::string FasmWriterVisitor::handle_fasm_prefix(const t_metadata_dict *meta,
179
172
}
180
173
181
174
std::string FasmWriterVisitor::build_clb_prefix (const t_pb *pb, const t_pb_graph_node* pb_graph_node, bool * is_parent_pb_null) const {
182
- std::string clb_prefix = " " ;
175
+ std::string clb_prefix;
183
176
184
177
const t_pb *pb_for_graph_node = nullptr ;
185
178
@@ -272,7 +265,7 @@ void FasmWriterVisitor::visit_all_impl(const t_pb_routes &pb_routes, const t_pb*
272
265
std::string clb_prefix = build_clb_prefix (pb, pb_graph_node, &is_parent_pb_null);
273
266
clb_prefix_map_.insert (std::make_pair (pb_graph_node, clb_prefix));
274
267
clb_prefix_ = clb_prefix;
275
- if (is_parent_pb_null == true ) {
268
+ if (is_parent_pb_null) {
276
269
return ;
277
270
}
278
271
@@ -365,7 +358,7 @@ static LogicVec lut_outputs(const t_pb* atom_pb, size_t num_inputs, const t_pb_r
365
358
if (truth_table.size () == 1 ) {
366
359
VTR_ASSERT (truth_table[0 ].size () == 1 );
367
360
lut.SetConstant (truth_table[0 ][0 ]);
368
- } else if (truth_table.size () == 0 ) {
361
+ } else if (truth_table.empty () ) {
369
362
lut.SetConstant (vtr::LogicValue::FALSE );
370
363
} else {
371
364
vpr_throw (VPR_ERROR_OTHER, __FILE__, __LINE__, " LUT truth table unexpected size is %d" , truth_table.size ());
@@ -420,7 +413,7 @@ static LogicVec lut_outputs(const t_pb* atom_pb, size_t num_inputs, const t_pb_r
420
413
return lut.table ();
421
414
}
422
415
423
- const t_metadata_dict *FasmWriterVisitor::get_fasm_type (const t_pb_graph_node* pb_graph_node, std::string target_type) const {
416
+ const t_metadata_dict *FasmWriterVisitor::get_fasm_type (const t_pb_graph_node* pb_graph_node, const std::string& target_type) const {
424
417
if (pb_graph_node == nullptr ) {
425
418
return nullptr ;
426
419
}
@@ -470,9 +463,8 @@ const LutOutputDefinition* FasmWriterVisitor::find_lut(const t_pb_graph_node* pb
470
463
VTR_ASSERT (value != nullptr );
471
464
472
465
std::vector<std::pair<std::string, LutOutputDefinition>> luts;
473
- luts.push_back (std::make_pair (
474
- vtr::string_fmt (" %s[0]" , pb_graph_node->pb_type ->name ),
475
- LutOutputDefinition (value->as_string ().get (strings_))));
466
+ luts.emplace_back (vtr::string_fmt (" %s[0]" , pb_graph_node->pb_type ->name ),
467
+ LutOutputDefinition (value->as_string ().get (strings_)));
476
468
477
469
auto insert_result = lut_definitions_.insert (
478
470
std::make_pair (pb_graph_node->pb_type , luts));
@@ -505,8 +497,7 @@ const LutOutputDefinition* FasmWriterVisitor::find_lut(const t_pb_graph_node* pb
505
497
fasm_lut_str.c_str ());
506
498
}
507
499
508
- luts.push_back (std::make_pair (
509
- parts[1 ], LutOutputDefinition (parts[0 ])));
500
+ luts.emplace_back (parts[1 ], LutOutputDefinition (parts[0 ]));
510
501
}
511
502
512
503
auto insert_result = lut_definitions_.insert (
@@ -569,9 +560,9 @@ void FasmWriterVisitor::check_for_param(const t_pb *atom) {
569
560
VTR_ASSERT (value != nullptr );
570
561
571
562
std::string fasm_params_str = value->as_string ().get (strings_);
572
- for (const auto param : vtr::split (fasm_params_str, " \n " )) {
563
+ for (const auto & param : vtr::split (fasm_params_str, " \n " )) {
573
564
auto param_parts = split_fasm_entry (param, " =" , " \t " );
574
- if (param_parts.size () == 0 ) {
565
+ if (param_parts.empty () ) {
575
566
continue ;
576
567
}
577
568
VTR_ASSERT (param_parts.size () == 2 );
@@ -589,10 +580,10 @@ void FasmWriterVisitor::check_for_param(const t_pb *atom) {
589
580
590
581
auto ¶ms = iter->second ;
591
582
592
- for (auto param : atom_ctx.nlist .block_params (atom_blk_id)) {
583
+ for (const auto & param : atom_ctx.nlist .block_params (atom_blk_id)) {
593
584
auto feature = params.EmitFasmFeature (param.first , param.second );
594
585
595
- if (feature.size () > 0 ) {
586
+ if (! feature.empty () ) {
596
587
output_fasm_features (feature);
597
588
}
598
589
}
@@ -668,7 +659,7 @@ void FasmWriterVisitor::find_clb_prefix(const t_pb_graph_node *node,
668
659
}
669
660
}
670
661
671
- void FasmWriterVisitor::output_fasm_mux (std::string fasm_mux_str,
662
+ void FasmWriterVisitor::output_fasm_mux (const std::string& fasm_mux_str,
672
663
t_interconnect *interconnect,
673
664
const t_pb_graph_pin *mux_input_pin) {
674
665
auto *pb_name = mux_input_pin->parent_node ->pb_type ->name ;
@@ -697,7 +688,7 @@ void FasmWriterVisitor::output_fasm_mux(std::string fasm_mux_str,
697
688
for (const auto &mux_input : mux_inputs) {
698
689
auto mux_parts = split_fasm_entry (mux_input, " =:" , " \t " );
699
690
700
- if (mux_parts.size () == 0 ) {
691
+ if (mux_parts.empty () ) {
701
692
// Swallow whitespace.
702
693
continue ;
703
694
}
@@ -753,11 +744,11 @@ void FasmWriterVisitor::output_fasm_mux(std::string fasm_mux_str,
753
744
pb_name, pb_index, port_name, pin_index, fasm_mux_str.c_str ());
754
745
}
755
746
756
- void FasmWriterVisitor::output_fasm_features (const std::string features) const {
747
+ void FasmWriterVisitor::output_fasm_features (const std::string& features) const {
757
748
output_fasm_features (features, clb_prefix_, blk_prefix_);
758
749
}
759
750
760
- void FasmWriterVisitor::output_fasm_features (const std::string features, const std::string clb_prefix, const std::string blk_prefix) const {
751
+ void FasmWriterVisitor::output_fasm_features (const std::string& features, const std::string& clb_prefix, const std::string& blk_prefix) const {
761
752
std::stringstream os (features);
762
753
763
754
while (os) {
0 commit comments