Skip to content

Commit

Permalink
write_verilog -include_pwr_gnd
Browse files Browse the repository at this point in the history
  • Loading branch information
jjcherry56 committed Oct 20, 2020
1 parent 0d73b5b commit fc279f0
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 9 deletions.
1 change: 1 addition & 0 deletions include/sta/VerilogWriter.hh
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ class LibertyCell;
void
writeVerilog(const char *filename,
bool sort,
bool include_pwr_gnd,
vector<LibertyCell*> *remove_cells,
Network *network);

Expand Down
3 changes: 2 additions & 1 deletion verilog/Verilog.i
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,14 @@ delete_verilog_reader()
void
write_verilog_cmd(const char *filename,
bool sort,
bool include_pwr_gnd,
vector<LibertyCell*> *remove_cells)
{
// This does NOT want the SDC (cmd) network because it wants
// to see the sta internal names.
Sta *sta = Sta::sta();
Network *network = sta->network();
writeVerilog(filename, sort, remove_cells, network);
writeVerilog(filename, sort, include_pwr_gnd, remove_cells, network);
}

%} // inline
9 changes: 6 additions & 3 deletions verilog/Verilog.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,22 @@ namespace eval sta {
# Defined by SWIG interface Verilog.i.
define_cmd_args "read_verilog" {filename}

define_cmd_args "write_verilog" {[-sort] [-remove_cells cells] filename}
define_cmd_args "write_verilog" {[-sort] [-include_pwr_gnd]\
[-remove_cells cells] filename}

proc write_verilog { args } {
parse_key_args "write_verilog" args keys {-remove_cells} flags {-sort}
parse_key_args "write_verilog" args keys {-remove_cells} \
flags {-sort -include_pwr_gnd}

set remove_cells {}
if { [info exists keys(-remove_cells)] } {
set remove_cells [sta::parse_libcell_arg $keys(-remove_cells)]
}
set sort [info exists flags(-sort)]
set include_pwr_gnd [info exists flags(-include_pwr_gnd)]
check_argc_eq1 "write_verilog" $args
set filename $args
write_verilog_cmd $filename $sort $remove_cells
write_verilog_cmd $filename $sort $include_pwr_gnd $remove_cells
}

# sta namespace end
Expand Down
19 changes: 14 additions & 5 deletions verilog/VerilogWriter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ class VerilogWriter
public:
VerilogWriter(const char *filename,
bool sort,
bool include_pwr_gnd_pins,
vector<LibertyCell*> *remove_cells,
FILE *stream,
Network *network);
Expand All @@ -55,6 +56,7 @@ class VerilogWriter

const char *filename_;
bool sort_;
bool include_pwr_gnd_;
CellSet remove_cells_;
FILE *stream_;
Network *network_;
Expand All @@ -67,13 +69,15 @@ class VerilogWriter
void
writeVerilog(const char *filename,
bool sort,
bool include_pwr_gnd_pins,
vector<LibertyCell*> *remove_cells,
Network *network)
{
if (network->topInstance()) {
FILE *stream = fopen(filename, "w");
if (stream) {
VerilogWriter writer(filename, sort, remove_cells, stream, network);
VerilogWriter writer(filename, sort, include_pwr_gnd_pins,
remove_cells, stream, network);
writer.writeModule(network->topInstance());
fclose(stream);
}
Expand All @@ -84,11 +88,13 @@ writeVerilog(const char *filename,

VerilogWriter::VerilogWriter(const char *filename,
bool sort,
bool include_pwr_gnd_pins,
vector<LibertyCell*> *remove_cells,
FILE *stream,
Network *network) :
filename_(filename),
sort_(sort),
include_pwr_gnd_(include_pwr_gnd_pins),
stream_(stream),
network_(network),
unconnected_net_index_(1)
Expand Down Expand Up @@ -224,10 +230,13 @@ VerilogWriter::writeChild(Instance *child)
CellPortIterator *port_iter = network_->portIterator(child_cell);
while (port_iter->hasNext()) {
Port *port = port_iter->next();
if (network_->hasMembers(port))
writeInstBusPin(child, port, first_port);
else
writeInstPin(child, port, first_port);
if (include_pwr_gnd_
|| !network_->direction(port)->isPowerGround()) {
if (network_->hasMembers(port))
writeInstBusPin(child, port, first_port);
else
writeInstPin(child, port, first_port);
}
}
delete port_iter;
fprintf(stream_, ");\n");
Expand Down

0 comments on commit fc279f0

Please sign in to comment.