@@ -275,7 +275,7 @@ class LutInst : public Instance {
275
275
std::map<std::string, std::vector<std::string>> port_conns, // /<The port connections of this instance. Key: port name, Value: connected nets
276
276
std::vector<Arc> timing_arc_values, // /<The timing arcs of this instance
277
277
struct t_analysis_opts opts)
278
- : type_(" LUT_K" )
278
+ : type_(opts.post_synth_netlist_module_parameters ? " LUT_K" : " LUT_ " + std::to_string(lut_size) )
279
279
, lut_size_(lut_size)
280
280
, lut_mask_(lut_mask)
281
281
, inst_name_(inst_name)
@@ -292,20 +292,33 @@ class LutInst : public Instance {
292
292
public: // Instance interface method implementations
293
293
void print_verilog (std::ostream& os, size_t & unconn_count, int depth) override {
294
294
// Instantiate the lut
295
- os << indent (depth) << type_ << " #( \n " ;
295
+ os << indent (depth) << type_;
296
296
297
- os << indent (depth + 1 ) << " .K(" << lut_size_ << " ),\n " ;
297
+ // If module parameters are on, pass the lut size and the lut mask as parameters.
298
+ if (opts_.post_synth_netlist_module_parameters ) {
299
+ os << " #(\n " ;
298
300
299
- std::stringstream param_ss;
300
- param_ss << lut_mask_;
301
- os << indent (depth + 1 ) << " .LUT_MASK(" << param_ss.str () << " )\n " ;
301
+ os << indent (depth + 1 ) << " .K(" << lut_size_ << " ),\n " ;
302
302
303
- os << indent (depth) << " ) " << escape_verilog_identifier (inst_name_) << " (\n " ;
303
+ std::stringstream param_ss;
304
+ param_ss << lut_mask_;
305
+ os << indent (depth + 1 ) << " .LUT_MASK(" << param_ss.str () << " )\n " ;
306
+
307
+ os << indent (depth) << " )" ;
308
+ }
309
+
310
+ os << " " << escape_verilog_identifier (inst_name_) << " (\n " ;
304
311
305
312
VTR_ASSERT (port_conns_.count (" in" ));
306
313
VTR_ASSERT (port_conns_.count (" out" ));
307
314
VTR_ASSERT (port_conns_.size () == 2 );
308
315
316
+ // If module parameters are not on, the mask of the lut will be passed
317
+ // as input to the module.
318
+ if (!opts_.post_synth_netlist_module_parameters ) {
319
+ os << indent (depth + 1 ) << " .mask(" << lut_mask_ << " ),\n " ;
320
+ }
321
+
309
322
print_verilog_port (os, unconn_count, " in" , port_conns_[" in" ], PortType::INPUT, depth + 1 , opts_);
310
323
os << " ,"
311
324
<< " \n " ;
@@ -497,16 +510,18 @@ class LatchInst : public Instance {
497
510
std::map<std::string, std::string> port_conns, // /<Instance's port-to-net connections
498
511
Type type, // /<Type of this latch
499
512
vtr::LogicValue init_value, // /<Initial value of the latch
500
- DelayTriple tcq = DelayTriple(), // /<Clock-to-Q delay
501
- DelayTriple tsu = DelayTriple(), // /<Setup time
502
- DelayTriple thld = DelayTriple()) // /<Hold time
513
+ DelayTriple tcq, // /<Clock-to-Q delay
514
+ DelayTriple tsu, // /<Setup time
515
+ DelayTriple thld, // /<Hold time
516
+ t_analysis_opts opts)
503
517
: instance_name_(inst_name)
504
518
, port_connections_(port_conns)
505
519
, type_(type)
506
520
, initial_value_(init_value)
507
521
, tcq_delay_triple_(tcq)
508
522
, tsu_delay_triple_(tsu)
509
- , thld_delay_triple_(thld) {}
523
+ , thld_delay_triple_(thld)
524
+ , opts_(opts) {}
510
525
511
526
void print_blif (std::ostream& os, size_t & /* unconn_count*/ , int depth = 0 ) override {
512
527
os << indent (depth) << " .latch"
@@ -537,21 +552,29 @@ class LatchInst : public Instance {
537
552
// Currently assume a standard DFF
538
553
VTR_ASSERT (type_ == Type::RISING_EDGE);
539
554
540
- os << indent (depth) << " DFF"
541
- << " #(\n " ;
542
- os << indent (depth + 1 ) << " .INITIAL_VALUE(" ;
543
- if (initial_value_ == vtr::LogicValue::TRUE )
544
- os << " 1'b1" ;
545
- else if (initial_value_ == vtr::LogicValue::FALSE )
546
- os << " 1'b0" ;
547
- else if (initial_value_ == vtr::LogicValue::DONT_CARE)
548
- os << " 1'bx" ;
549
- else if (initial_value_ == vtr::LogicValue::UNKOWN)
550
- os << " 1'bx" ;
551
- else
552
- VTR_ASSERT (false );
553
- os << " )\n " ;
554
- os << indent (depth) << " ) " << escape_verilog_identifier (instance_name_) << " (\n " ;
555
+ os << indent (depth) << " DFF" ;
556
+
557
+ // If module parameters are turned on, pass in the initial value of the
558
+ // register as a parameter.
559
+ // Note: This initial value is only used for simulation.
560
+ if (opts_.post_synth_netlist_module_parameters ) {
561
+ os << " #(\n " ;
562
+ os << indent (depth + 1 ) << " .INITIAL_VALUE(" ;
563
+ if (initial_value_ == vtr::LogicValue::TRUE )
564
+ os << " 1'b1" ;
565
+ else if (initial_value_ == vtr::LogicValue::FALSE )
566
+ os << " 1'b0" ;
567
+ else if (initial_value_ == vtr::LogicValue::DONT_CARE)
568
+ os << " 1'bx" ;
569
+ else if (initial_value_ == vtr::LogicValue::UNKOWN)
570
+ os << " 1'bx" ;
571
+ else
572
+ VTR_ASSERT (false );
573
+ os << " )\n " ;
574
+ os << indent (depth) << " )" ;
575
+ }
576
+
577
+ os << " " << escape_verilog_identifier (instance_name_) << " (\n " ;
555
578
556
579
for (auto iter = port_connections_.begin (); iter != port_connections_.end (); ++iter) {
557
580
os << indent (depth + 1 ) << " ." << iter->first << " (" << escape_verilog_identifier (iter->second ) << " )" ;
@@ -607,6 +630,7 @@ class LatchInst : public Instance {
607
630
DelayTriple tcq_delay_triple_; // /<Clock delay + tcq
608
631
DelayTriple tsu_delay_triple_; // /<Setup time
609
632
DelayTriple thld_delay_triple_; // /<Hold time
633
+ t_analysis_opts opts_;
610
634
};
611
635
612
636
class BlackBoxInst : public Instance {
@@ -677,25 +701,40 @@ class BlackBoxInst : public Instance {
677
701
678
702
void print_verilog (std::ostream& os, size_t & unconn_count, int depth = 0 ) override {
679
703
// Instance type
680
- os << indent (depth) << type_name_ << " #(\n " ;
681
-
682
- // Verilog parameters
683
- for (auto iter = params_.begin (); iter != params_.end (); ++iter) {
684
- /* Prepend a prefix if needed */
685
- std::stringstream prefix;
686
- if (is_binary_param (iter->second )) {
687
- prefix << iter->second .length () << " 'b" ;
688
- }
704
+ os << indent (depth) << type_name_;
705
+
706
+ // Print the parameters if any are provided.
707
+ if (params_.size () > 0 ) {
708
+ if (opts_.post_synth_netlist_module_parameters ) {
709
+ os << " #(\n " ;
710
+
711
+ // Verilog parameters
712
+ for (auto iter = params_.begin (); iter != params_.end (); ++iter) {
713
+ /* Prepend a prefix if needed */
714
+ std::stringstream prefix;
715
+ if (is_binary_param (iter->second )) {
716
+ prefix << iter->second .length () << " 'b" ;
717
+ }
689
718
690
- os << indent (depth + 1 ) << " ." << iter->first << " (" << prefix.str () << iter->second << " )" ;
691
- if (iter != --params_.end ()) {
692
- os << " ," ;
719
+ os << indent (depth + 1 ) << " ." << iter->first << " (" << prefix.str () << iter->second << " )" ;
720
+ if (iter != --params_.end ()) {
721
+ os << " ," ;
722
+ }
723
+ os << " \n " ;
724
+ }
725
+ os << indent (depth) << " )" ;
726
+ } else {
727
+ // TODO: RAMs are considered black box instructions. These can
728
+ // probably be handled similar to LUTs.
729
+ VPR_FATAL_ERROR (VPR_ERROR_IMPL_NETLIST_WRITER,
730
+ " Cannot generate black box instruction of type %s "
731
+ " without using parameters." ,
732
+ type_name_.c_str ());
693
733
}
694
- os << " \n " ;
695
734
}
696
735
697
736
// Instance name
698
- os << indent (depth) << " ) " << escape_verilog_identifier (inst_name_) << " (\n " ;
737
+ os << " " << escape_verilog_identifier (inst_name_) << " (\n " ;
699
738
700
739
// Input Port connections
701
740
for (auto iter = input_port_conns_.begin (); iter != input_port_conns_.end (); ++iter) {
@@ -1325,6 +1364,9 @@ class NetlistWriterVisitor : public NetlistVisitor {
1325
1364
double tsu = pb_graph_node->input_pins [0 ][0 ].tsu ;
1326
1365
DelayTriple tsu_triple (tsu, tsu, tsu);
1327
1366
1367
+ double thld = pb_graph_node->input_pins [0 ][0 ].thld ;
1368
+ DelayTriple thld_triple (thld, thld, thld);
1369
+
1328
1370
// Output (Q)
1329
1371
int output_cluster_pin_idx = pb_graph_node->output_pins [0 ][0 ].pin_count_in_cluster ; // Unique pin index in cluster
1330
1372
VTR_ASSERT (top_pb_route.count (output_cluster_pin_idx));
@@ -1346,7 +1388,7 @@ class NetlistWriterVisitor : public NetlistVisitor {
1346
1388
LatchInst::Type type = LatchInst::Type::RISING_EDGE;
1347
1389
vtr::LogicValue init_value = vtr::LogicValue::FALSE ;
1348
1390
1349
- return std::make_shared<LatchInst>(inst_name, port_conns, type, init_value, tcq_triple, tsu_triple);
1391
+ return std::make_shared<LatchInst>(inst_name, port_conns, type, init_value, tcq_triple, tsu_triple, thld_triple, opts_ );
1350
1392
}
1351
1393
1352
1394
/* *
0 commit comments