write_verilog -remove_cells
This commit is contained in:
parent
d296a3405d
commit
4fa9e46235
BIN
doc/OpenSTA.odt
BIN
doc/OpenSTA.odt
Binary file not shown.
|
|
@ -16,6 +16,8 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include "LibertyClass.hh"
|
||||||
|
|
||||||
namespace sta {
|
namespace sta {
|
||||||
|
|
||||||
class Network;
|
class Network;
|
||||||
|
|
@ -23,6 +25,7 @@ class Network;
|
||||||
void
|
void
|
||||||
writeVerilog(const char *filename,
|
writeVerilog(const char *filename,
|
||||||
bool sort,
|
bool sort,
|
||||||
|
LibertyCellSeq *remove_cells,
|
||||||
Network *network);
|
Network *network);
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
|
||||||
|
|
@ -1145,6 +1145,12 @@ proc parse_libcell_libport_inst_port_pin_edge_timing_arc_set_arg { objects \
|
||||||
edges timing_arc_sets
|
edges timing_arc_sets
|
||||||
}
|
}
|
||||||
|
|
||||||
|
proc parse_libcell_arg { objects } {
|
||||||
|
set libcells {}
|
||||||
|
get_object_args $objects {} libcells {} {} {} {} {} {} {} {}
|
||||||
|
return $libcells
|
||||||
|
}
|
||||||
|
|
||||||
proc parse_libcell_inst_arg { objects libcells_var insts_var } {
|
proc parse_libcell_inst_arg { objects libcells_var insts_var } {
|
||||||
upvar 1 $libcells_var libcells
|
upvar 1 $libcells_var libcells
|
||||||
upvar 1 $insts_var insts
|
upvar 1 $insts_var insts
|
||||||
|
|
|
||||||
|
|
@ -429,6 +429,10 @@ using namespace sta;
|
||||||
Tcl_SetObjResult(interp, list);
|
Tcl_SetObjResult(interp, list);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
%typemap(in) LibertyCellSeq* {
|
||||||
|
$1 = tclListSeqLibertyCell($input, interp);
|
||||||
|
}
|
||||||
|
|
||||||
%typemap(out) TmpCellSeq* {
|
%typemap(out) TmpCellSeq* {
|
||||||
Tcl_Obj *list = Tcl_NewListObj(0, nullptr);
|
Tcl_Obj *list = Tcl_NewListObj(0, nullptr);
|
||||||
CellSeq *cells = $1;
|
CellSeq *cells = $1;
|
||||||
|
|
|
||||||
|
|
@ -25,6 +25,7 @@
|
||||||
using sta::Sta;
|
using sta::Sta;
|
||||||
using sta::NetworkReader;
|
using sta::NetworkReader;
|
||||||
using sta::readVerilogFile;
|
using sta::readVerilogFile;
|
||||||
|
using sta::LibertyCellSeq;
|
||||||
|
|
||||||
%}
|
%}
|
||||||
|
|
||||||
|
|
@ -51,13 +52,14 @@ delete_verilog_reader()
|
||||||
|
|
||||||
void
|
void
|
||||||
write_verilog_cmd(const char *filename,
|
write_verilog_cmd(const char *filename,
|
||||||
bool sort)
|
bool sort,
|
||||||
|
LibertyCellSeq *remove_cells)
|
||||||
{
|
{
|
||||||
// This does NOT want the SDC (cmd) network because it wants
|
// This does NOT want the SDC (cmd) network because it wants
|
||||||
// to see the sta internal names.
|
// to see the sta internal names.
|
||||||
Sta *sta = Sta::sta();
|
Sta *sta = Sta::sta();
|
||||||
Network *network = sta->network();
|
Network *network = sta->network();
|
||||||
writeVerilog(filename, sort, network);
|
writeVerilog(filename, sort, remove_cells, network);
|
||||||
}
|
}
|
||||||
|
|
||||||
%} // inline
|
%} // inline
|
||||||
|
|
|
||||||
|
|
@ -19,15 +19,19 @@ namespace eval sta {
|
||||||
# Defined by SWIG interface Verilog.i.
|
# Defined by SWIG interface Verilog.i.
|
||||||
define_cmd_args "read_verilog" {filename}
|
define_cmd_args "read_verilog" {filename}
|
||||||
|
|
||||||
define_cmd_args "write_verilog" {[-sort] filename}
|
define_cmd_args "write_verilog" {[-sort] [-remove_cells cells] filename}
|
||||||
|
|
||||||
proc write_verilog { args } {
|
proc write_verilog { args } {
|
||||||
parse_key_args "write_verilog" args keys {} flags {-sort}
|
parse_key_args "write_verilog" args keys {-remove_cells} flags {-sort}
|
||||||
|
|
||||||
|
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 sort [info exists flags(-sort)]
|
||||||
check_argc_eq1 "write_verilog" $args
|
check_argc_eq1 "write_verilog" $args
|
||||||
set filename $args
|
set filename $args
|
||||||
write_verilog_cmd $filename $sort
|
write_verilog_cmd $filename $sort $remove_cells
|
||||||
}
|
}
|
||||||
|
|
||||||
# sta namespace end
|
# sta namespace end
|
||||||
|
|
|
||||||
|
|
@ -32,6 +32,7 @@ class VerilogWriter
|
||||||
public:
|
public:
|
||||||
VerilogWriter(const char *filename,
|
VerilogWriter(const char *filename,
|
||||||
bool sort,
|
bool sort,
|
||||||
|
LibertyCellSeq *remove_cells,
|
||||||
FILE *stream,
|
FILE *stream,
|
||||||
Network *network);
|
Network *network);
|
||||||
void writeModule(Instance *inst);
|
void writeModule(Instance *inst);
|
||||||
|
|
@ -54,6 +55,7 @@ protected:
|
||||||
|
|
||||||
const char *filename_;
|
const char *filename_;
|
||||||
bool sort_;
|
bool sort_;
|
||||||
|
CellSet remove_cells_;
|
||||||
FILE *stream_;
|
FILE *stream_;
|
||||||
Network *network_;
|
Network *network_;
|
||||||
|
|
||||||
|
|
@ -65,12 +67,13 @@ protected:
|
||||||
void
|
void
|
||||||
writeVerilog(const char *filename,
|
writeVerilog(const char *filename,
|
||||||
bool sort,
|
bool sort,
|
||||||
|
LibertyCellSeq *remove_cells,
|
||||||
Network *network)
|
Network *network)
|
||||||
{
|
{
|
||||||
if (network->topInstance()) {
|
if (network->topInstance()) {
|
||||||
FILE *stream = fopen(filename, "w");
|
FILE *stream = fopen(filename, "w");
|
||||||
if (stream) {
|
if (stream) {
|
||||||
VerilogWriter writer(filename, sort, stream, network);
|
VerilogWriter writer(filename, sort, remove_cells, stream, network);
|
||||||
writer.writeModule(network->topInstance());
|
writer.writeModule(network->topInstance());
|
||||||
fclose(stream);
|
fclose(stream);
|
||||||
}
|
}
|
||||||
|
|
@ -81,6 +84,7 @@ writeVerilog(const char *filename,
|
||||||
|
|
||||||
VerilogWriter::VerilogWriter(const char *filename,
|
VerilogWriter::VerilogWriter(const char *filename,
|
||||||
bool sort,
|
bool sort,
|
||||||
|
LibertyCellSeq *remove_cells,
|
||||||
FILE *stream,
|
FILE *stream,
|
||||||
Network *network) :
|
Network *network) :
|
||||||
filename_(filename),
|
filename_(filename),
|
||||||
|
|
@ -89,6 +93,8 @@ VerilogWriter::VerilogWriter(const char *filename,
|
||||||
network_(network),
|
network_(network),
|
||||||
unconnected_net_index_(1)
|
unconnected_net_index_(1)
|
||||||
{
|
{
|
||||||
|
for(LibertyCell *lib_cell : *remove_cells)
|
||||||
|
remove_cells_.insert(network->cell(lib_cell));
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
@ -205,23 +211,25 @@ void
|
||||||
VerilogWriter::writeChild(Instance *child)
|
VerilogWriter::writeChild(Instance *child)
|
||||||
{
|
{
|
||||||
Cell *child_cell = network_->cell(child);
|
Cell *child_cell = network_->cell(child);
|
||||||
const char *child_name = network_->name(child);
|
if (!remove_cells_.hasKey(child_cell)) {
|
||||||
const char *child_vname = instanceVerilogName(child_name,
|
const char *child_name = network_->name(child);
|
||||||
network_->pathEscape());
|
const char *child_vname = instanceVerilogName(child_name,
|
||||||
fprintf(stream_, " %s %s (",
|
network_->pathEscape());
|
||||||
network_->name(child_cell),
|
fprintf(stream_, " %s %s (",
|
||||||
child_vname);
|
network_->name(child_cell),
|
||||||
bool first_port = true;
|
child_vname);
|
||||||
CellPortIterator *port_iter = network_->portIterator(child_cell);
|
bool first_port = true;
|
||||||
while (port_iter->hasNext()) {
|
CellPortIterator *port_iter = network_->portIterator(child_cell);
|
||||||
Port *port = port_iter->next();
|
while (port_iter->hasNext()) {
|
||||||
if (network_->hasMembers(port))
|
Port *port = port_iter->next();
|
||||||
writeInstBusPin(child, port, first_port);
|
if (network_->hasMembers(port))
|
||||||
else
|
writeInstBusPin(child, port, first_port);
|
||||||
writeInstPin(child, port, first_port);
|
else
|
||||||
|
writeInstPin(child, port, first_port);
|
||||||
|
}
|
||||||
|
delete port_iter;
|
||||||
|
fprintf(stream_, ");\n");
|
||||||
}
|
}
|
||||||
delete port_iter;
|
|
||||||
fprintf(stream_, ");\n");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue