Skip to content

Commit 346855b

Browse files
authored
Merge pull request #8124 from braydenlouie/grid-branch
ram: initial complete version
2 parents d300307 + 3879419 commit 346855b

29 files changed

+1978
-1
lines changed

.clang-tidy

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ CheckOptions:
6565

6666
# All modules but sta
6767
# Exclude build as there is too much noise from swig generated code
68-
HeaderFilterRegex: "(?!build/.*)/(ant|cts|dbSta|dft|dpl|drt|dst|est|exa|fin|gpl|grt|gui|ifp|mpl|odb|ord|pad|par|pdn|ppl|psm|rcx|rmp|rsz|stt|tap|upf|utl)/.*"
68+
HeaderFilterRegex: "(?!build/.*)/(ant|cgt|cts|cut|dbSta|dft|dpl|drt|dst|est|exa|fin|gpl|grt|gui|ifp|mpl|odb|ord|pad|par|pdn|ppl|psm|rcx|ram|rmp|rsz|stt|tap|upf|utl)/.*"
6969

7070
# Not currently handling identifier naming
7171
# WarningsAsErrors: "*"

BUILD.bazel

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ OPENROAD_LIBRARY_DEPS = [
9090
"//src/pdn",
9191
"//src/ppl",
9292
"//src/psm",
93+
"//src/ram",
9394
"//src/rcx",
9495
"//src/rcx:ui",
9596
"//src/rmp",

include/ord/OpenRoad.hh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,10 @@ namespace fin {
6464
class Finale;
6565
}
6666

67+
namespace ram {
68+
class RamGen;
69+
}
70+
6771
namespace exa {
6872
class Example;
6973
}
@@ -156,6 +160,7 @@ class OpenRoad
156160
dbVerilogNetwork* getVerilogNetwork() { return verilog_network_; }
157161
dpl::Opendp* getOpendp() { return opendp_; }
158162
fin::Finale* getFinale() { return finale_; }
163+
ram::RamGen* getRamGen() { return ram_gen_; }
159164
tap::Tapcell* getTapcell() { return tapcell_; }
160165
mpl::MacroPlacer* getMacroPlacer() { return macro_placer_; }
161166
exa::Example* getExample() { return example_; }
@@ -255,6 +260,7 @@ class OpenRoad
255260
ppl::IOPlacer* ioPlacer_ = nullptr;
256261
dpl::Opendp* opendp_ = nullptr;
257262
fin::Finale* finale_ = nullptr;
263+
ram::RamGen* ram_gen_ = nullptr;
258264
mpl::MacroPlacer* macro_placer_ = nullptr;
259265
exa::Example* example_ = nullptr;
260266
grt::GlobalRouter* global_router_ = nullptr;

src/CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,7 @@ add_subdirectory(gpl)
263263
add_subdirectory(dpl)
264264
add_subdirectory(exa)
265265
add_subdirectory(fin)
266+
add_subdirectory(ram)
266267
add_subdirectory(ppl)
267268
add_subdirectory(rmp)
268269
add_subdirectory(cgt)
@@ -326,6 +327,7 @@ target_link_libraries(openroad
326327
dpl
327328
exa
328329
fin
330+
ram
329331
rsz
330332
ppl
331333
stt
@@ -422,6 +424,7 @@ if (Python3_FOUND AND BUILD_PYTHON)
422424
cts_py
423425
drt_py
424426
fin_py
427+
# ram_py
425428
rcx_py
426429
rmp_py
427430
stt_py

src/OpenRoad.cc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,8 @@
6767
#include "ppl/MakeIoplacer.h"
6868
#include "psm/MakePDNSim.hh"
6969
#include "psm/pdnsim.h"
70+
#include "ram/MakeRam.h"
71+
#include "ram/ram.h"
7072
#include "rcx/MakeOpenRCX.h"
7173
#include "rcx/ext.h"
7274
#include "rmp/MakeRestructure.h"
@@ -135,6 +137,7 @@ OpenRoad::~OpenRoad()
135137
delete replace_;
136138
delete pdnsim_;
137139
delete finale_;
140+
delete ram_gen_;
138141
delete antenna_checker_;
139142
odb::dbDatabase::destroy(db_);
140143
delete partitionMgr_;
@@ -220,6 +223,7 @@ void OpenRoad::init(Tcl_Interp* tcl_interp,
220223
opendp_,
221224
estimate_parasitics_);
222225
finale_ = new fin::Finale(db_, logger_);
226+
ram_gen_ = new ram::RamGen(getDbNetwork(), db_, logger_);
223227
restructure_ = new rmp::Restructure(
224228
logger_, sta_, db_, resizer_, estimate_parasitics_);
225229
clock_gating_ = new cgt::ClockGating(logger_, sta_);
@@ -253,6 +257,7 @@ void OpenRoad::init(Tcl_Interp* tcl_interp,
253257
utl::evalTclInit(tcl_interp, ord::ord_tcl_inits);
254258

255259
utl::initLogger(tcl_interp);
260+
256261
// GUI first so we can register our sink with the logger
257262
gui::initGui(tcl_interp, db_, sta_, logger_);
258263
odb::initOdb(tcl_interp);
@@ -264,6 +269,7 @@ void OpenRoad::init(Tcl_Interp* tcl_interp,
264269
gpl::initReplace(tcl_interp);
265270
dpl::initOpendp(tcl_interp);
266271
fin::initFinale(tcl_interp);
272+
ram::initRamGen(tcl_interp);
267273
grt::initTcl(tcl_interp);
268274
cts::initTritonCts(tcl_interp);
269275
tap::initTapcell(tcl_interp);

src/ram/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
test/results
2+
*~

src/ram/BUILD

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
# SPDX-License-Identifier: BSD-3-Clause
2+
# Copyright (c) 2025, The OpenROAD Authors
3+
4+
load("@rules_cc//cc:cc_library.bzl", "cc_library")
5+
load("//bazel:python_wrap_cc.bzl", "python_wrap_cc")
6+
load("//bazel:tcl_encode_or.bzl", "tcl_encode")
7+
load("//bazel:tcl_wrap_cc.bzl", "tcl_wrap_cc")
8+
9+
package(
10+
default_visibility = ["//:__subpackages__"],
11+
features = ["layering_check"],
12+
)
13+
14+
cc_library(
15+
name = "ram",
16+
srcs = [
17+
"src/MakeRam.cpp",
18+
"src/layout.cpp",
19+
"src/layout.h",
20+
"src/ram.cpp",
21+
":swig",
22+
":tcl",
23+
],
24+
hdrs = [
25+
"include/ram/MakeRam.h",
26+
"include/ram/ram.h",
27+
],
28+
includes = [
29+
"include",
30+
],
31+
deps = [
32+
"//:ord",
33+
"//src/dbSta:dbNetwork",
34+
"//src/odb",
35+
"//src/sta:opensta_lib",
36+
"//src/utl",
37+
"@boost.stacktrace",
38+
"@tk_tcl//:tcl",
39+
],
40+
)
41+
42+
tcl_encode(
43+
name = "tcl",
44+
srcs = [
45+
"src/ram.tcl",
46+
],
47+
char_array_name = "ram_tcl_inits",
48+
namespace = "ram",
49+
)
50+
51+
tcl_wrap_cc(
52+
name = "swig",
53+
srcs = [
54+
"src/ram.i",
55+
"//:error_swig",
56+
],
57+
module = "ram",
58+
namespace_prefix = "ram",
59+
root_swig_src = "src/ram.i",
60+
swig_includes = [
61+
"src/ram/src",
62+
],
63+
deps = [
64+
"//src/odb:swig",
65+
],
66+
)
67+
68+
python_wrap_cc(
69+
name = "swig-py",
70+
srcs = [
71+
"include/ram/ram.h",
72+
"src/ram-py.i",
73+
"//:error_swig-py",
74+
],
75+
module = "ram_py",
76+
root_swig_src = "src/ram-py.i",
77+
swig_includes = [
78+
"include",
79+
],
80+
deps = [
81+
"//src/odb:swig-py",
82+
],
83+
)

src/ram/CMakeLists.txt

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
###########################################################################
2+
## BSD 3-Clause License
3+
##
4+
## Copyright (c) 2023, Precision Innovations Inc.
5+
## All rights reserved.
6+
##
7+
## Redistribution and use in source and binary forms, with or without
8+
## modification, are permitted provided that the following conditions are met:
9+
##
10+
## * Redistributions of source code must retain the above copyright notice, this
11+
## list of conditions and the following disclaimer.
12+
##
13+
## * Redistributions in binary form must reproduce the above copyright notice,
14+
## this list of conditions and the following disclaimer in the documentation
15+
## and/or other materials provided with the distribution.
16+
##
17+
## * Neither the name of the copyright holder nor the names of its
18+
## contributors may be used to endorse or promote products derived from
19+
## this software without specific prior written permission.
20+
##
21+
## THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22+
## AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23+
## IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24+
## ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
25+
## LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
26+
## CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27+
## SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28+
## INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29+
## CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30+
## ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31+
## POSSIBILITY OF SUCH DAMAGE.
32+
###########################################################################
33+
34+
include("openroad")
35+
36+
swig_lib(NAME ram
37+
NAMESPACE ram
38+
I_FILE src/ram.i
39+
SCRIPTS src/ram.tcl
40+
)
41+
42+
target_sources(ram
43+
PRIVATE
44+
src/ram.cpp
45+
src/layout.cpp
46+
src/MakeRam.cpp
47+
)
48+
49+
target_include_directories(ram
50+
PUBLIC
51+
include
52+
)
53+
54+
target_link_libraries(ram
55+
PRIVATE
56+
odb
57+
dbSta
58+
OpenSTA
59+
)
60+
61+
messages(
62+
TARGET ram
63+
)
64+
65+
#if (Python3_FOUND AND BUILD_PYTHON)
66+
# swig_lib(NAME ram_py
67+
# NAMESPACE ram
68+
# LANGUAGE python
69+
# I_FILE src/ram-py.i
70+
# SWIG_INCLUDES ${PROJECT_SOURCE_DIR}/include/ram
71+
# SCRIPTS ${CMAKE_CURRENT_BINARY_DIR}/ram_py.py
72+
# )
73+
#
74+
# target_link_libraries(ram_py
75+
# PUBLIC
76+
# ram
77+
# odb
78+
# )
79+
#
80+
#endif()
81+
82+
add_subdirectory(test)

src/ram/include/ram/MakeRam.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// SPDX-License-Identifier: BSD-3-Clause
2+
// Copyright (c) 2024-2025, The OpenROAD Authors
3+
4+
#pragma once
5+
6+
#include <tcl.h>
7+
8+
namespace ram {
9+
10+
void initRamGen(Tcl_Interp* tcl_interp);
11+
12+
} // namespace ram

src/ram/include/ram/ram.h

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
// SPDX-License-Identifier: BSD-3-Clause
2+
// Copyright (c) 2024-2025, The OpenROAD Authors
3+
4+
#pragma once
5+
6+
#include <functional>
7+
#include <memory>
8+
9+
#include "odb/db.h"
10+
11+
namespace odb {
12+
class dbMaster;
13+
}
14+
15+
namespace sta {
16+
class dbNetwork;
17+
class LibertyPort;
18+
} // namespace sta
19+
20+
namespace utl {
21+
class Logger;
22+
}
23+
24+
namespace ram {
25+
26+
using utl::Logger;
27+
28+
////////////////////////////////////////////////////////////////
29+
class Cell;
30+
class Layout;
31+
class Grid;
32+
33+
class RamGen
34+
{
35+
public:
36+
RamGen(sta::dbNetwork* network, odb::dbDatabase* db, Logger* logger);
37+
~RamGen() = default;
38+
39+
void generate(int bytes_per_word,
40+
int word_count,
41+
int read_ports,
42+
odb::dbMaster* storage_cell,
43+
odb::dbMaster* tristate_cell,
44+
odb::dbMaster* inv_cell);
45+
46+
private:
47+
void findMasters();
48+
odb::dbMaster* findMaster(const std::function<bool(sta::LibertyPort*)>& match,
49+
const char* name);
50+
odb::dbNet* makeNet(const std::string& prefix, const std::string& name);
51+
odb::dbInst* makeInst(
52+
Layout* layout,
53+
const std::string& prefix,
54+
const std::string& name,
55+
odb::dbMaster* master,
56+
const std::vector<std::pair<std::string, odb::dbNet*>>& connections);
57+
odb::dbInst* makeCellInst(
58+
Cell* cell,
59+
const std::string& prefix,
60+
const std::string& name,
61+
odb::dbMaster* master,
62+
const std::vector<std::pair<std::string, odb::dbNet*>>& connections);
63+
std::unique_ptr<Cell> makeCellBit(const std::string& prefix,
64+
int read_ports,
65+
odb::dbNet* clock,
66+
std::vector<odb::dbNet*>& select,
67+
odb::dbNet* data_input,
68+
std::vector<odb::dbNet*>& data_output);
69+
void makeCellByte(
70+
Grid& ram_grid,
71+
int byte_number,
72+
const std::string& prefix,
73+
int read_ports,
74+
odb::dbNet* clock,
75+
odb::dbNet* write_enable,
76+
const std::vector<odb::dbNet*>& selects,
77+
const std::array<odb::dbNet*, 8>& data_input,
78+
const std::vector<std::array<odb::dbBTerm*, 8>>& data_output);
79+
80+
odb::dbBTerm* makeBTerm(const std::string& name, odb::dbIoType io_type);
81+
82+
std::unique_ptr<Cell> makeDecoder(const std::string& prefix,
83+
int num_word,
84+
int read_ports,
85+
const std::vector<odb::dbNet*>& selects,
86+
const std::vector<odb::dbNet*>& addr_nets);
87+
88+
std::vector<odb::dbNet*> selectNets(const std::string& prefix,
89+
int read_ports);
90+
91+
sta::dbNetwork* network_;
92+
odb::dbDatabase* db_;
93+
odb::dbBlock* block_;
94+
Logger* logger_;
95+
96+
odb::dbMaster* storage_cell_;
97+
odb::dbMaster* tristate_cell_;
98+
odb::dbMaster* inv_cell_;
99+
odb::dbMaster* and2_cell_;
100+
odb::dbMaster* clock_gate_cell_;
101+
odb::dbMaster* buffer_cell_;
102+
};
103+
104+
} // namespace ram

0 commit comments

Comments
 (0)