Make `is_memory` property more sensitive for cells and libcells by also matching on `memory` groups (#129)

* Add `has_memory` property

* Whitespace fixes

* Remove unused argument name

* Review fixes

* Move gf180mcu_sram.lib.gz from examples/ to test/

* Fix tcl script

* Switch to is_memory

* Remove is_memory_cell
This commit is contained in:
Akash Levy 2024-11-20 15:10:12 -08:00 committed by GitHub
parent 3c461f2d35
commit 70d52c2fe0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
10 changed files with 76 additions and 1 deletions

Binary file not shown.

Binary file not shown.

View File

@ -373,6 +373,10 @@ LibertyReader::defineVisitors()
&LibertyReader::visitLevelShifterDataPin);
defineAttrVisitor("switch_pin", &LibertyReader::visitSwitchPin);
// Memory
defineGroupVisitor("memory", &LibertyReader::beginMemory,
&LibertyReader::endMemory);
// Register/latch
defineGroupVisitor("ff", &LibertyReader::beginFF, &LibertyReader::endFF);
defineGroupVisitor("ff_bank", &LibertyReader::beginFFBank,
@ -3851,6 +3855,21 @@ LibertyReader::visitPortBoolAttr(LibertyAttr *attr,
////////////////////////////////////////////////////////////////
void
LibertyReader::beginMemory(LibertyGroup *)
{
if (cell_) {
cell_->setIsMemory(true);
}
}
void
LibertyReader::endMemory(LibertyGroup *)
{
}
////////////////////////////////////////////////////////////////
void
LibertyReader::beginFF(LibertyGroup *group)
{

View File

@ -291,6 +291,9 @@ public:
virtual void endWireloadSelection(LibertyGroup *group);
virtual void visitWireloadFromArea(LibertyAttr *attr);
virtual void beginMemory(LibertyGroup *group);
virtual void endMemory(LibertyGroup *group);
virtual void beginFF(LibertyGroup *group);
virtual void endFF(LibertyGroup *group);
virtual void beginFFBank(LibertyGroup *group);

View File

@ -726,6 +726,8 @@ getProperty(const LibertyCell *cell,
return PropertyValue(cell->isBuffer());
else if (stringEqual(property, "is_inverter"))
return PropertyValue(cell->isInverter());
else if (stringEqual(property, "is_memory"))
return PropertyValue(cell->isMemory());
else if (stringEqual(property, "dont_use"))
return PropertyValue(cell->dontUse());
else if (stringEqual(property, "area"))
@ -957,7 +959,7 @@ getProperty(const Instance *inst,
return PropertyValue(liberty_cell && liberty_cell->isInverter());
else if (stringEqual(property, "is_macro"))
return PropertyValue(liberty_cell && liberty_cell->isMacro());
else if (stringEqual(property, "is_memory_cell"))
else if (stringEqual(property, "is_memory"))
return PropertyValue(liberty_cell && liberty_cell->isMemory());
else
throw PropertyUnknown("instance", property);

4
test/get_is_memory.ok Normal file
View File

@ -0,0 +1,4 @@
[get_cells -filter is_memory]
sram_inst
[get_lib_cells -filter is_memory]
gf180mcu_fd_ip_sram__sram128x8m8wm1__ff_125C_1v98/gf180mcu_fd_ip_sram__sram128x8m8wm1

11
test/get_is_memory.tcl Normal file
View File

@ -0,0 +1,11 @@
# Tests whether the is_memory attribute works for cells and libcells
read_liberty gf180mcu_sram.lib.gz
read_liberty asap7_small.lib.gz
read_verilog get_is_memory.v
link get_is_memory
# Test that the is_memory attribute is set correctly for cells
puts {[get_cells -filter is_memory]}
report_object_full_names [get_cells -filter is_memory]
puts {[get_lib_cells -filter is_memory]}
report_object_full_names [get_lib_cells -filter is_memory]

35
test/get_is_memory.v Normal file
View File

@ -0,0 +1,35 @@
module get_is_memory (
input CLK,
input CEN,
input GWEN,
input [7:0] WEN,
input [6:0] A,
input [7:0] D,
output [7:0] Q
);
wire CEN_buf;
wire GWEN_reg;
BUFx2_ASAP7_75t_R buf_inst (
.A(CEN),
.Y(CEN_buf)
);
DFFHQx4_ASAP7_75t_R dff_inst (
.CLK(CLK),
.D(GWEN),
.Q(GWEN_reg)
);
gf180mcu_fd_ip_sram__sram128x8m8wm1 sram_inst (
.CLK(CLK),
.CEN(CEN_buf),
.GWEN(GWEN_reg),
.WEN(WEN),
.A(A),
.D(D),
.Q(Q)
);
endmodule

BIN
test/gf180mcu_sram.lib.gz Normal file

Binary file not shown.

View File

@ -126,6 +126,7 @@ record_sta_tests {
verilog_attribute
liberty_arcs_one2one_1
liberty_arcs_one2one_2
get_is_memory
get_filter
get_noargs
get_objrefs