18
18
#include " vtr_version.h"
19
19
20
20
#include " vpr_error.h"
21
+ #include " vpr_types.h"
21
22
22
23
#include " netlist_walker.h"
23
24
#include " netlist_writer.h"
@@ -110,7 +111,7 @@ std::string indent(size_t depth);
110
111
double get_delay_ps (double delay_sec);
111
112
112
113
void print_blif_port (std::ostream& os, size_t & unconn_count, const std::string& port_name, const std::vector<std::string>& nets, int depth);
113
- void print_verilog_port (std::ostream& os, const std::string& port_name, const std::vector<std::string>& nets, PortType type, int depth);
114
+ void print_verilog_port (std::ostream& os, size_t & unconn_count, const std::string& port_name, const std::vector<std::string>& nets, PortType type, int depth, struct t_analysis_opts & opts );
114
115
115
116
std::string create_unconn_net (size_t & unconn_count);
116
117
std::string escape_verilog_identifier (const std::string id);
@@ -187,7 +188,7 @@ class Instance {
187
188
virtual void print_blif (std::ostream& os, size_t & unconn_count, int depth = 0 ) = 0;
188
189
189
190
// /@brief Print the current instanse in Verilog, see print_blif() for argument descriptions
190
- virtual void print_verilog (std::ostream& os, int depth = 0 ) = 0;
191
+ virtual void print_verilog (std::ostream& os, size_t & unconn_count, int depth = 0 ) = 0;
191
192
192
193
// /@brief Print the current instanse in SDF, see print_blif() for argument descriptions
193
194
virtual void print_sdf (std::ostream& os, int depth = 0 ) = 0;
@@ -200,13 +201,15 @@ class LutInst : public Instance {
200
201
LogicVec lut_mask, // /<The LUT mask representing the logic function
201
202
std::string inst_name, // /<The name of this instance
202
203
std::map<std::string, std::vector<std::string>> port_conns, // /<The port connections of this instance. Key: port name, Value: connected nets
203
- std::vector<Arc> timing_arc_values) // /<The timing arcs of this instance
204
+ std::vector<Arc> timing_arc_values, // /<The timing arcs of this instance
205
+ struct t_analysis_opts opts)
204
206
: type_(" LUT_K" )
205
207
, lut_size_(lut_size)
206
208
, lut_mask_(lut_mask)
207
209
, inst_name_(inst_name)
208
210
, port_conns_(port_conns)
209
- , timing_arcs_(timing_arc_values) {
211
+ , timing_arcs_(timing_arc_values)
212
+ , opts_(opts) {
210
213
}
211
214
212
215
// Accessors
@@ -215,7 +218,7 @@ class LutInst : public Instance {
215
218
std::string type () { return type_; }
216
219
217
220
public: // Instance interface method implementations
218
- void print_verilog (std::ostream& os, int depth) override {
221
+ void print_verilog (std::ostream& os, size_t & unconn_count, int depth) override {
219
222
// Instantiate the lut
220
223
os << indent (depth) << type_ << " #(\n " ;
221
224
@@ -231,10 +234,10 @@ class LutInst : public Instance {
231
234
VTR_ASSERT (port_conns_.count (" out" ));
232
235
VTR_ASSERT (port_conns_.size () == 2 );
233
236
234
- print_verilog_port (os, " in" , port_conns_[" in" ], PortType::INPUT, depth + 1 );
237
+ print_verilog_port (os, unconn_count, " in" , port_conns_[" in" ], PortType::INPUT, depth + 1 , opts_ );
235
238
os << " ,"
236
239
<< " \n " ;
237
- print_verilog_port (os, " out" , port_conns_[" out" ], PortType::OUTPUT, depth + 1 );
240
+ print_verilog_port (os, unconn_count, " out" , port_conns_[" out" ], PortType::OUTPUT, depth + 1 , opts_ );
238
241
os << " \n " ;
239
242
240
243
os << indent (depth) << " );\n\n " ;
@@ -376,6 +379,7 @@ class LutInst : public Instance {
376
379
std::string inst_name_;
377
380
std::map<std::string, std::vector<std::string>> port_conns_;
378
381
std::vector<Arc> timing_arcs_;
382
+ struct t_analysis_opts opts_;
379
383
};
380
384
381
385
class LatchInst : public Instance {
@@ -462,7 +466,7 @@ class LatchInst : public Instance {
462
466
os << " \n " ;
463
467
}
464
468
465
- void print_verilog (std::ostream& os, int depth = 0 ) override {
469
+ void print_verilog (std::ostream& os, size_t & /* unconn_count */ , int depth = 0 ) override {
466
470
// Currently assume a standard DFF
467
471
VTR_ASSERT (type_ == Type::RISING_EDGE);
468
472
@@ -560,7 +564,8 @@ class BlackBoxInst : public Instance {
560
564
std::vector<Arc> timing_arcs, // /<Combinational timing arcs
561
565
std::map<std::string, sequential_port_delay_pair> ports_tsu, // /<Port setup checks
562
566
std::map<std::string, sequential_port_delay_pair> ports_thld, // /<Port hold checks
563
- std::map<std::string, sequential_port_delay_pair> ports_tcq) // /<Port clock-to-q delays
567
+ std::map<std::string, sequential_port_delay_pair> ports_tcq, // /<Port clock-to-q delays
568
+ struct t_analysis_opts opts)
564
569
: type_name_(type_name)
565
570
, inst_name_(inst_name)
566
571
, params_(params)
@@ -570,7 +575,8 @@ class BlackBoxInst : public Instance {
570
575
, timing_arcs_(timing_arcs)
571
576
, ports_tsu_(ports_tsu)
572
577
, ports_thld_(ports_thld)
573
- , ports_tcq_(ports_tcq) {}
578
+ , ports_tcq_(ports_tcq)
579
+ , opts_(opts) {}
574
580
575
581
void print_blif (std::ostream& os, size_t & unconn_count, int depth = 0 ) override {
576
582
os << indent (depth) << " .subckt " << type_name_ << " \\ "
@@ -613,7 +619,7 @@ class BlackBoxInst : public Instance {
613
619
os << " \n " ;
614
620
}
615
621
616
- void print_verilog (std::ostream& os, int depth = 0 ) override {
622
+ void print_verilog (std::ostream& os, size_t & unconn_count, int depth = 0 ) override {
617
623
// Instance type
618
624
os << indent (depth) << type_name_ << " #(\n " ;
619
625
@@ -633,7 +639,7 @@ class BlackBoxInst : public Instance {
633
639
for (auto iter = input_port_conns_.begin (); iter != input_port_conns_.end (); ++iter) {
634
640
auto & port_name = iter->first ;
635
641
auto & nets = iter->second ;
636
- print_verilog_port (os, port_name, nets, PortType::INPUT, depth + 1 );
642
+ print_verilog_port (os, unconn_count, port_name, nets, PortType::INPUT, depth + 1 , opts_ );
637
643
if (!(iter == --input_port_conns_.end () && output_port_conns_.empty ())) {
638
644
os << " ," ;
639
645
}
@@ -644,7 +650,7 @@ class BlackBoxInst : public Instance {
644
650
for (auto iter = output_port_conns_.begin (); iter != output_port_conns_.end (); ++iter) {
645
651
auto & port_name = iter->first ;
646
652
auto & nets = iter->second ;
647
- print_verilog_port (os, port_name, nets, PortType::OUTPUT, depth + 1 );
653
+ print_verilog_port (os, unconn_count, port_name, nets, PortType::OUTPUT, depth + 1 , opts_ );
648
654
if (!(iter == --output_port_conns_.end ())) {
649
655
os << " ," ;
650
656
}
@@ -755,6 +761,7 @@ class BlackBoxInst : public Instance {
755
761
std::map<std::string, sequential_port_delay_pair> ports_tsu_;
756
762
std::map<std::string, sequential_port_delay_pair> ports_thld_;
757
763
std::map<std::string, sequential_port_delay_pair> ports_tcq_;
764
+ struct t_analysis_opts opts_;
758
765
};
759
766
760
767
/* *
@@ -793,11 +800,13 @@ class NetlistWriterVisitor : public NetlistVisitor {
793
800
NetlistWriterVisitor (std::ostream& verilog_os, // /<Output stream for verilog netlist
794
801
std::ostream& blif_os, // /<Output stream for blif netlist
795
802
std::ostream& sdf_os, // /<Output stream for SDF
796
- std::shared_ptr<const AnalysisDelayCalculator> delay_calc)
803
+ std::shared_ptr<const AnalysisDelayCalculator> delay_calc,
804
+ struct t_analysis_opts opts)
797
805
: verilog_os_(verilog_os)
798
806
, blif_os_(blif_os)
799
807
, sdf_os_(sdf_os)
800
- , delay_calc_(delay_calc) {
808
+ , delay_calc_(delay_calc)
809
+ , opts_(opts) {
801
810
auto & atom_ctx = g_vpr_ctx.atom ();
802
811
803
812
// Initialize the pin to tnode look-up
@@ -931,10 +940,11 @@ class NetlistWriterVisitor : public NetlistVisitor {
931
940
}
932
941
933
942
// All the cell instances
943
+ size_t unconn_count = 0 ;
934
944
verilog_os_ << " \n " ;
935
945
verilog_os_ << indent (depth + 1 ) << " //Cell instances\n " ;
936
946
for (auto & inst : cell_instances_) {
937
- inst->print_verilog (verilog_os_, depth + 1 );
947
+ inst->print_verilog (verilog_os_, unconn_count, depth + 1 );
938
948
}
939
949
940
950
verilog_os_ << " \n " ;
@@ -1213,7 +1223,7 @@ class NetlistWriterVisitor : public NetlistVisitor {
1213
1223
port_conns[" out" ].push_back (net);
1214
1224
}
1215
1225
1216
- auto inst = std::make_shared<LutInst>(lut_size, lut_mask, inst_name, port_conns, timing_arcs);
1226
+ auto inst = std::make_shared<LutInst>(lut_size, lut_mask, inst_name, port_conns, timing_arcs, opts_ );
1217
1227
1218
1228
return inst;
1219
1229
}
@@ -1413,7 +1423,7 @@ class NetlistWriterVisitor : public NetlistVisitor {
1413
1423
}
1414
1424
}
1415
1425
1416
- return std::make_shared<BlackBoxInst>(type, inst_name, params, attrs, input_port_conns, output_port_conns, timing_arcs, ports_tsu, ports_thld, ports_tcq);
1426
+ return std::make_shared<BlackBoxInst>(type, inst_name, params, attrs, input_port_conns, output_port_conns, timing_arcs, ports_tsu, ports_thld, ports_tcq, opts_ );
1417
1427
}
1418
1428
1419
1429
// /@brief Returns an Instance object representing a Multiplier
@@ -1509,7 +1519,7 @@ class NetlistWriterVisitor : public NetlistVisitor {
1509
1519
1510
1520
VTR_ASSERT (pb_graph_node->num_clock_ports == 0 ); // No clocks
1511
1521
1512
- return std::make_shared<BlackBoxInst>(type_name, inst_name, params, attrs, input_port_conns, output_port_conns, timing_arcs, ports_tsu, ports_thld, ports_tcq);
1522
+ return std::make_shared<BlackBoxInst>(type_name, inst_name, params, attrs, input_port_conns, output_port_conns, timing_arcs, ports_tsu, ports_thld, ports_tcq, opts_ );
1513
1523
}
1514
1524
1515
1525
// /@brief Returns an Instance object representing an Adder
@@ -1609,7 +1619,7 @@ class NetlistWriterVisitor : public NetlistVisitor {
1609
1619
}
1610
1620
}
1611
1621
1612
- return std::make_shared<BlackBoxInst>(type_name, inst_name, params, attrs, input_port_conns, output_port_conns, timing_arcs, ports_tsu, ports_thld, ports_tcq);
1622
+ return std::make_shared<BlackBoxInst>(type_name, inst_name, params, attrs, input_port_conns, output_port_conns, timing_arcs, ports_tsu, ports_thld, ports_tcq, opts_ );
1613
1623
}
1614
1624
1615
1625
std::shared_ptr<Instance> make_blackbox_instance (const t_pb* atom) {
@@ -1747,7 +1757,7 @@ class NetlistWriterVisitor : public NetlistVisitor {
1747
1757
attrs[attr.first ] = attr.second ;
1748
1758
}
1749
1759
1750
- return std::make_shared<BlackBoxInst>(type_name, inst_name, params, attrs, input_port_conns, output_port_conns, timing_arcs, ports_tsu, ports_thld, ports_tcq);
1760
+ return std::make_shared<BlackBoxInst>(type_name, inst_name, params, attrs, input_port_conns, output_port_conns, timing_arcs, ports_tsu, ports_thld, ports_tcq, opts_ );
1751
1761
}
1752
1762
1753
1763
// /@brief Returns the top level pb_route associated with the given pb
@@ -2067,14 +2077,15 @@ class NetlistWriterVisitor : public NetlistVisitor {
2067
2077
std::map<std::pair<ClusterBlockId, int >, tatum::NodeId> pin_id_to_tnode_lookup_;
2068
2078
2069
2079
std::shared_ptr<const AnalysisDelayCalculator> delay_calc_;
2080
+ struct t_analysis_opts opts_;
2070
2081
};
2071
2082
2072
2083
//
2073
2084
// Externally Accessible Functions
2074
2085
//
2075
2086
2076
2087
// /@brief Main routing for this file. See netlist_writer.h for details.
2077
- void netlist_writer (const std::string basename, std::shared_ptr<const AnalysisDelayCalculator> delay_calc) {
2088
+ void netlist_writer (const std::string basename, std::shared_ptr<const AnalysisDelayCalculator> delay_calc, struct t_analysis_opts opts ) {
2078
2089
std::string verilog_filename = basename + " _post_synthesis.v" ;
2079
2090
std::string blif_filename = basename + " _post_synthesis.blif" ;
2080
2091
std::string sdf_filename = basename + " _post_synthesis.sdf" ;
@@ -2087,7 +2098,7 @@ void netlist_writer(const std::string basename, std::shared_ptr<const AnalysisDe
2087
2098
std::ofstream blif_os (blif_filename);
2088
2099
std::ofstream sdf_os (sdf_filename);
2089
2100
2090
- NetlistWriterVisitor visitor (verilog_os, blif_os, sdf_os, delay_calc);
2101
+ NetlistWriterVisitor visitor (verilog_os, blif_os, sdf_os, delay_calc, opts );
2091
2102
2092
2103
NetlistWalker nl_walker (visitor);
2093
2104
@@ -2159,7 +2170,7 @@ void print_blif_port(std::ostream& os, size_t& unconn_count, const std::string&
2159
2170
*
2160
2171
* Handles special cases like multi-bit and disconnected ports
2161
2172
*/
2162
- void print_verilog_port (std::ostream& os, const std::string& port_name, const std::vector<std::string>& nets, PortType type, int depth) {
2173
+ void print_verilog_port (std::ostream& os, size_t & unconn_count, const std::string& port_name, const std::vector<std::string>& nets, PortType type, int depth, struct t_analysis_opts & opts ) {
2163
2174
// Port name
2164
2175
os << indent (depth) << " ." << port_name << " (" ;
2165
2176
@@ -2169,10 +2180,26 @@ void print_verilog_port(std::ostream& os, const std::string& port_name, const st
2169
2180
if (nets[0 ].empty ()) {
2170
2181
// Disconnected
2171
2182
if (type == PortType::INPUT || type == PortType::CLOCK) {
2172
- os << " 1'b0" ;
2183
+ switch (opts.post_synth_netlist_unconn_input_handling ) {
2184
+ case e_post_synth_netlist_unconn_handling::GND:
2185
+ os << " 1'b0" ; break ;
2186
+ case e_post_synth_netlist_unconn_handling::VCC:
2187
+ os << " 1'b1" ; break ;
2188
+ case e_post_synth_netlist_unconn_handling::NETS:
2189
+ os << create_unconn_net (unconn_count); break ;
2190
+ case e_post_synth_netlist_unconn_handling::UNCONNECTED:
2191
+ default :
2192
+ os << " 1'bX" ;;
2193
+ }
2173
2194
} else {
2174
2195
VTR_ASSERT (type == PortType::OUTPUT);
2175
- os << " DummyOut" ;
2196
+ switch (opts.post_synth_netlist_unconn_output_handling ) {
2197
+ case e_post_synth_netlist_unconn_handling::NETS:
2198
+ os << create_unconn_net (unconn_count); break ;
2199
+ case e_post_synth_netlist_unconn_handling::UNCONNECTED:
2200
+ default :
2201
+ os << " 1'bX" ;;
2202
+ }
2176
2203
}
2177
2204
} else {
2178
2205
// Connected
0 commit comments