|
| 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