Skip to content

Commit a9d47b4

Browse files
committed
ram: condensed tapcell insertion, ram.tcl cleanup
Signed-off-by: braydenl9988 <[email protected]>
1 parent f9d78c9 commit a9d47b4

File tree

4 files changed

+32
-24
lines changed

4 files changed

+32
-24
lines changed

src/ram/include/ram/ram.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,9 @@ class RamGen
8686

8787
odb::dbBTerm* makeBTerm(const std::string& name, odb::dbIoType io_type);
8888

89+
std::unique_ptr<Layout> generateTapColumn(int word_count,
90+
int tapcell_col);
91+
8992
std::unique_ptr<Cell> makeDecoder(const std::string& prefix,
9093
int num_word,
9194
int read_ports,

src/ram/src/ram.cpp

Lines changed: 25 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,22 @@ void RamGen::makeCellByte(Grid& ram_grid,
173173
ram_grid.addCell(std::move(sel_cell), (byte_number * 9) + 8);
174174
}
175175

176+
std::unique_ptr<Layout> RamGen::generateTapColumn(const int word_count,
177+
const int tapcell_col)
178+
{
179+
auto tapcell_layout = std::make_unique<Layout>(odb::vertical);
180+
for (int i = 0; i < word_count; ++i) {
181+
auto tapcell_cell = std::make_unique<Cell>();
182+
makeCellInst(tapcell_cell.get(),
183+
"tapcell",
184+
fmt::format("cell{}_{}", tapcell_col, i),
185+
tapcell_,
186+
{});
187+
tapcell_layout->addCell(std::move(tapcell_cell));
188+
}
189+
return tapcell_layout;
190+
}
191+
176192
std::unique_ptr<Cell> RamGen::makeDecoder(
177193
const std::string& prefix,
178194
const int num_word,
@@ -389,7 +405,6 @@ void RamGen::generate(const int bytes_per_word,
389405
clock_gate_cell_ = nullptr;
390406
buffer_cell_ = nullptr;
391407
findMasters();
392-
max_tap_dist *= 10;
393408

394409
auto chip = db_->getChip();
395410
if (!chip) {
@@ -551,35 +566,22 @@ void RamGen::generate(const int bytes_per_word,
551566
ram_grid.gridInit();
552567

553568
if (tapcell_) {
569+
// max tap distance specified is greater than the length of ram
554570
if (ram_grid.getRowWidth() <= max_tap_dist) {
555-
auto tapcell_layout = std::make_unique<Layout>(odb::vertical);
556-
for (int i = 0; i < word_count; ++i) {
557-
auto tapcell_cell = std::make_unique<Cell>();
558-
makeCellInst(tapcell_cell.get(),
559-
"tapcell",
560-
fmt::format("cell_{}", i),
561-
tapcell_,
562-
{});
563-
tapcell_layout->addCell(std::move(tapcell_cell));
564-
}
571+
auto tapcell_layout = generateTapColumn(word_count, 0);
565572
ram_grid.insertLayout(std::move(tapcell_layout), 0);
566573
} else {
567574
int nearest_tap = 0;
575+
int tapcell_count = 0;
576+
// iterates through each of the columns
568577
for (int col = 0; col < ram_grid.numLayouts(); ++col) {
569-
if (nearest_tap >= max_tap_dist) {
570-
auto tapcell_layout = std::make_unique<Layout>(odb::vertical);
571-
for (int i = 0; i < word_count; ++i) {
572-
auto tapcell_cell = std::make_unique<Cell>();
573-
makeCellInst(tapcell_cell.get(),
574-
"tapcell",
575-
fmt::format("cell{}_{}", col, i),
576-
tapcell_,
577-
{});
578-
tapcell_layout->addCell(std::move(tapcell_cell));
579-
}
578+
if (nearest_tap >= max_tap_dist) {
579+
//if the nearest_tap is too far, generate tap column
580+
auto tapcell_layout = generateTapColumn(word_count, tapcell_count);
580581
ram_grid.insertLayout(std::move(tapcell_layout), col);
581-
++col;
582+
++col; // col adjustment after insertion
582583
nearest_tap = 0;
584+
++tapcell_count;
583585
}
584586
nearest_tap += ram_grid.getLayoutWidth(col);
585587
}

src/ram/src/ram.tcl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,13 @@ proc generate_ram_netlist { args } {
5252
if { [info exists keys(-tapcell)] } {
5353
if { [info exists keys(-max_tap_dist)] } {
5454
set max_tap_dist $keys(-max_tap_dist)
55+
set max_tap_dist [expr $max_tap_dist * 1000]
5556
} else {
5657
utl::error RAM 21 "The -max_tap_dist argument must be specified with tapcell."
5758
}
5859
set tapcell $keys(-tapcell)
60+
} else {
61+
utl::info RAM 22 "No tapcell is specified. The generated layout may not pass Design Rule Checks."
5962
}
6063

6164
ram::generate_ram_netlist_cmd $bytes_per_word $word_count $storage_cell \

src/ram/test/make_8x8.tcl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ generate_ram \
2020
-filler_cells {sky130_fd_sc_hd__fill_1 sky130_fd_sc_hd__fill_2 \
2121
sky130_fd_sc_hd__fill_4 sky130_fd_sc_hd__fill_8} \
2222
-tapcell sky130_fd_sc_hd__tap_1 \
23-
-max_tap_dist 3000
23+
-max_tap_dist 30
2424

2525
set lef_file [make_result_file make_8x8.lef]
2626
write_abstract_lef $lef_file

0 commit comments

Comments
 (0)