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
@@ -903,8 +912,6 @@ class NetlistWriterVisitor : public NetlistVisitor {
903
912
}
904
913
}
905
914
906
- verilog_os_ << indent (depth + 1 ) << " wire DummyOut;\n " ;
907
-
908
915
// connections between primary I/Os and their internal wires
909
916
verilog_os_ << " \n " ;
910
917
verilog_os_ << indent (depth + 1 ) << " //IO assignments\n " ;
@@ -931,10 +938,11 @@ class NetlistWriterVisitor : public NetlistVisitor {
931
938
}
932
939
933
940
// All the cell instances
941
+ size_t unconn_count = 0 ;
934
942
verilog_os_ << " \n " ;
935
943
verilog_os_ << indent (depth + 1 ) << " //Cell instances\n " ;
936
944
for (auto & inst : cell_instances_) {
937
- inst->print_verilog (verilog_os_, depth + 1 );
945
+ inst->print_verilog (verilog_os_, unconn_count, depth + 1 );
938
946
}
939
947
940
948
verilog_os_ << " \n " ;
@@ -1213,7 +1221,7 @@ class NetlistWriterVisitor : public NetlistVisitor {
1213
1221
port_conns[" out" ].push_back (net);
1214
1222
}
1215
1223
1216
- auto inst = std::make_shared<LutInst>(lut_size, lut_mask, inst_name, port_conns, timing_arcs);
1224
+ auto inst = std::make_shared<LutInst>(lut_size, lut_mask, inst_name, port_conns, timing_arcs, opts_ );
1217
1225
1218
1226
return inst;
1219
1227
}
@@ -1413,7 +1421,7 @@ class NetlistWriterVisitor : public NetlistVisitor {
1413
1421
}
1414
1422
}
1415
1423
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);
1424
+ 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
1425
}
1418
1426
1419
1427
// /@brief Returns an Instance object representing a Multiplier
@@ -1509,7 +1517,7 @@ class NetlistWriterVisitor : public NetlistVisitor {
1509
1517
1510
1518
VTR_ASSERT (pb_graph_node->num_clock_ports == 0 ); // No clocks
1511
1519
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);
1520
+ 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
1521
}
1514
1522
1515
1523
// /@brief Returns an Instance object representing an Adder
@@ -1609,7 +1617,7 @@ class NetlistWriterVisitor : public NetlistVisitor {
1609
1617
}
1610
1618
}
1611
1619
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);
1620
+ 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
1621
}
1614
1622
1615
1623
std::shared_ptr<Instance> make_blackbox_instance (const t_pb* atom) {
@@ -1747,7 +1755,7 @@ class NetlistWriterVisitor : public NetlistVisitor {
1747
1755
attrs[attr.first ] = attr.second ;
1748
1756
}
1749
1757
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);
1758
+ 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
1759
}
1752
1760
1753
1761
// /@brief Returns the top level pb_route associated with the given pb
@@ -2067,14 +2075,15 @@ class NetlistWriterVisitor : public NetlistVisitor {
2067
2075
std::map<std::pair<ClusterBlockId, int >, tatum::NodeId> pin_id_to_tnode_lookup_;
2068
2076
2069
2077
std::shared_ptr<const AnalysisDelayCalculator> delay_calc_;
2078
+ struct t_analysis_opts opts_;
2070
2079
};
2071
2080
2072
2081
//
2073
2082
// Externally Accessible Functions
2074
2083
//
2075
2084
2076
2085
// /@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) {
2086
+ void netlist_writer (const std::string basename, std::shared_ptr<const AnalysisDelayCalculator> delay_calc, struct t_analysis_opts opts ) {
2078
2087
std::string verilog_filename = basename + " _post_synthesis.v" ;
2079
2088
std::string blif_filename = basename + " _post_synthesis.blif" ;
2080
2089
std::string sdf_filename = basename + " _post_synthesis.sdf" ;
@@ -2087,7 +2096,7 @@ void netlist_writer(const std::string basename, std::shared_ptr<const AnalysisDe
2087
2096
std::ofstream blif_os (blif_filename);
2088
2097
std::ofstream sdf_os (sdf_filename);
2089
2098
2090
- NetlistWriterVisitor visitor (verilog_os, blif_os, sdf_os, delay_calc);
2099
+ NetlistWriterVisitor visitor (verilog_os, blif_os, sdf_os, delay_calc, opts );
2091
2100
2092
2101
NetlistWalker nl_walker (visitor);
2093
2102
@@ -2159,7 +2168,7 @@ void print_blif_port(std::ostream& os, size_t& unconn_count, const std::string&
2159
2168
*
2160
2169
* Handles special cases like multi-bit and disconnected ports
2161
2170
*/
2162
- void print_verilog_port (std::ostream& os, const std::string& port_name, const std::vector<std::string>& nets, PortType type, int depth) {
2171
+ 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
2172
// Port name
2164
2173
os << indent (depth) << " ." << port_name << " (" ;
2165
2174
@@ -2169,10 +2178,30 @@ void print_verilog_port(std::ostream& os, const std::string& port_name, const st
2169
2178
if (nets[0 ].empty ()) {
2170
2179
// Disconnected
2171
2180
if (type == PortType::INPUT || type == PortType::CLOCK) {
2172
- os << " 1'b0" ;
2181
+ switch (opts.post_synth_netlist_unconn_input_handling ) {
2182
+ case e_post_synth_netlist_unconn_handling::GND:
2183
+ os << " 1'b0" ;
2184
+ break ;
2185
+ case e_post_synth_netlist_unconn_handling::VCC:
2186
+ os << " 1'b1" ;
2187
+ break ;
2188
+ case e_post_synth_netlist_unconn_handling::NETS:
2189
+ os << create_unconn_net (unconn_count);
2190
+ break ;
2191
+ case e_post_synth_netlist_unconn_handling::UNCONNECTED:
2192
+ default :
2193
+ os << " 1'bX" ;
2194
+ }
2173
2195
} else {
2174
2196
VTR_ASSERT (type == PortType::OUTPUT);
2175
- os << " DummyOut" ;
2197
+ switch (opts.post_synth_netlist_unconn_output_handling ) {
2198
+ case e_post_synth_netlist_unconn_handling::NETS:
2199
+ os << create_unconn_net (unconn_count);
2200
+ break ;
2201
+ case e_post_synth_netlist_unconn_handling::UNCONNECTED:
2202
+ default :
2203
+ os << " 1'bX" ;
2204
+ }
2176
2205
}
2177
2206
} else {
2178
2207
// Connected
@@ -2191,7 +2220,7 @@ void print_verilog_port(std::ostream& os, const std::string& port_name, const st
2191
2220
os << " 1'b0" ;
2192
2221
} else {
2193
2222
VTR_ASSERT (type == PortType::OUTPUT);
2194
- os << " DummyOut " ;
2223
+ os << " " ;
2195
2224
}
2196
2225
} else {
2197
2226
// Connected
0 commit comments