@@ -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+
176192std::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 }
0 commit comments