Skip to content

Commit e5f2d07

Browse files
committed
netlist writer: handle triggering clock edge in post-impl SDF writer
Signed-off-by: Pawel Czarnecki <pczarnecki@antmicro.com>
1 parent 61f17e9 commit e5f2d07

File tree

1 file changed

+24
-9
lines changed

1 file changed

+24
-9
lines changed

vpr/src/base/netlist_writer.cpp

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -430,7 +430,15 @@ class LatchInst : public Instance {
430430
VTR_ASSERT(false);
431431
return is;
432432
}
433-
433+
private:
434+
std::string type_to_sdf_edge() {
435+
if (type_ == Type::RISING_EDGE)
436+
return "posedge";
437+
else if (type_ == Type::FALLING_EDGE)
438+
return "negedge";
439+
else
440+
VTR_ASSERT(false);
441+
}
434442
public:
435443
LatchInst(std::string inst_name, ///<Name of this instance
436444
std::map<std::string, std::string> port_conns, ///<Instance's port-to-net connections
@@ -474,7 +482,7 @@ class LatchInst : public Instance {
474482

475483
void print_verilog(std::ostream& os, size_t& /*unconn_count*/, int depth = 0) override {
476484
//Currently assume a standard DFF
477-
VTR_ASSERT(type_ == Type::RISING_EDGE);
485+
VTR_ASSERT(type_ == Type::RISING_EDGE || type_ == Type::FALLING_EDGE);
478486

479487
os << indent(depth) << "DFF"
480488
<< " #(\n";
@@ -505,7 +513,7 @@ class LatchInst : public Instance {
505513
}
506514

507515
void print_sdf(std::ostream& os, int depth = 0) override {
508-
VTR_ASSERT(type_ == Type::RISING_EDGE);
516+
VTR_ASSERT(type_ == Type::RISING_EDGE || type_ == Type::FALLING_EDGE);
509517

510518
os << indent(depth) << "(CELL\n";
511519
os << indent(depth + 1) << "(CELLTYPE \""
@@ -523,7 +531,7 @@ class LatchInst : public Instance {
523531
delay_triple << "(" << delay_ps << ":" << delay_ps << ":" << delay_ps << ")";
524532

525533
os << indent(depth + 3) << "(IOPATH "
526-
<< "(posedge clock) Q " << delay_triple.str() << " " << delay_triple.str() << ")\n";
534+
<< "(" << type_to_sdf_edge() << " clock) Q " << delay_triple.str() << " " << delay_triple.str() << ")\n";
527535
os << indent(depth + 2) << ")\n";
528536
os << indent(depth + 1) << ")\n";
529537
}
@@ -535,13 +543,13 @@ class LatchInst : public Instance {
535543
std::stringstream setup_triple;
536544
double setup_ps = get_delay_ps(tsu_);
537545
setup_triple << "(" << setup_ps << ":" << setup_ps << ":" << setup_ps << ")";
538-
os << indent(depth + 2) << "(SETUP D (posedge clock) " << setup_triple.str() << ")\n";
546+
os << indent(depth + 2) << "(SETUP D (" << type_to_sdf_edge() << " clock) " << setup_triple.str() << ")\n";
539547
}
540548
if (!std::isnan(thld_)) {
541549
std::stringstream hold_triple;
542550
double hold_ps = get_delay_ps(thld_);
543551
hold_triple << "(" << hold_ps << ":" << hold_ps << ":" << hold_ps << ")";
544-
os << indent(depth + 2) << "(HOLD D (posedge clock) " << hold_triple.str() << ")\n";
552+
os << indent(depth + 2) << "(HOLD D (" << type_to_sdf_edge() << " clock) " << hold_triple.str() << ")\n";
545553
}
546554
}
547555
os << indent(depth + 1) << ")\n";
@@ -1282,6 +1290,8 @@ class NetlistWriterVisitor : public NetlistVisitor {
12821290
VTR_ASSERT(pb_graph_node->num_output_pins[0] == 1);
12831291
VTR_ASSERT(pb_graph_node->num_clock_pins[0] == 1);
12841292

1293+
const t_pb_graph_pin* pb_graph_pin = &pb_graph_node->clock_pins[0][0];
1294+
12851295
//The connections
12861296
std::map<std::string, std::string> port_conns;
12871297

@@ -1310,9 +1320,14 @@ class NetlistWriterVisitor : public NetlistVisitor {
13101320
std::string control_net = make_inst_wire(control_atom_net_id, find_tnode(atom, control_cluster_pin_idx), inst_name, PortType::CLOCK, 0, 0);
13111321
port_conns["clock"] = control_net;
13121322

1313-
//VPR currently doesn't store enough information to determine these attributes,
1314-
//for now assume reasonable defaults.
1315-
LatchInst::Type type = LatchInst::Type::RISING_EDGE;
1323+
LatchInst::Type type;
1324+
if (pb_graph_pin->port->model_port->trigg_edge == TriggeringEdge::FALLING_EDGE) {
1325+
type = LatchInst::Type::FALLING_EDGE;
1326+
} else {
1327+
type = LatchInst::Type::RISING_EDGE;
1328+
}
1329+
1330+
//VPR currently doesn't store enough information to determine this attribute
13161331
vtr::LogicValue init_value = vtr::LogicValue::FALSE;
13171332

13181333
return std::make_shared<LatchInst>(inst_name, port_conns, type, init_value, tcq, tsu);

0 commit comments

Comments
 (0)