Skip to content

Commit 73ab739

Browse files
authored
Merge pull request #10567 from tnguy19/optional-mask-size
ram: Optional mask size
2 parents e98fb4f + 79f8a06 commit 73ab739

2 files changed

Lines changed: 16 additions & 11 deletions

File tree

src/ram/README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,10 @@ Standard cell libraries must be loaded before running this command.
3333
The module will create a new design, therefore a design should not be loaded before running the command.
3434

3535
```tcl
36-
generate_ram -mask_size bits
36+
generate_ram [-mask_size bits]
3737
-word_size bits
3838
-num_words words
39+
[-column_mux_ratio ratio]
3940
[-read_ports count]
4041
[-storage_cell name]
4142
[-tristate_cell name]
@@ -55,9 +56,10 @@ generate_ram -mask_size bits
5556

5657
| Switch Name | Description |
5758
| ----- | ----- |
58-
| `-mask_size` | Determines the number of bits which are grouped together for masking during writes. For example, a mask size of `8` will enable each 8 bits of the word to be masked when writing (commonly known as byte masking). A mask size of `1` will enable each bit to be individually masked. The write enable signal for each port will be `(word_size / mask_size)` bits wide. The word size must be a multiple of the mask size. |
59+
| `-mask_size` | Determines the number of bits which are grouped together for masking during writes. For example, a mask size of `8` will enable each 8 bits of the word to be masked when writing (commonly known as byte masking). A mask size of `1` will enable each bit to be individually masked. The write enable signal for each port will be `(word_size / mask_size)` bits wide. The word size must be a multiple of the mask size. Default: equal to `-word_size`. |
5960
| `-word_size` | Size of each word in bits. |
6061
| `-num_words` | Number of words in the array. |
62+
| `-column_mux_ratio` | Number of words sharing a physical column. Must be `1`, `2`, or `4`. The number of words must be divisible by the column mux ratio. Default: `1` (no column muxing). |
6163
| `-read_ports` | Number of read ports for the array. Default: 1. |
6264
| `-storage_cell` | Name of the master to use for the storage device (i.e. a flip-flop). Must be positive-edge triggered. Default: auto-select from the loaded cell library. |
6365
| `-tristate_cell` | Name of the master to use for the tristate device (i.e. a tristate inverter). It is currently assumed that the device is inverting. Default: auto-select from the loaded cell library. |

src/ram/src/ram.tcl

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# SPDX-License-Identifier: BSD-3-Clause
22
# Copyright (c) 2024-2025, The OpenROAD Authors
33

4-
sta::define_cmd_args "generate_ram_netlist" {-mask_size bits
4+
sta::define_cmd_args "generate_ram_netlist" {[-mask_size bits]
55
-word_size bits
66
-num_words words
77
[-column_mux_ratio ratio]
@@ -23,18 +23,18 @@ proc generate_ram_netlist { args } {
2323
set column_mux_ratio $keys(-column_mux_ratio)
2424
}
2525

26-
if { [info exists keys(-mask_size)] } {
27-
set mask_size $keys(-mask_size)
28-
} else {
29-
utl::error RAM 1 "The -mask_size argument must be specified."
30-
}
31-
3226
if { [info exists keys(-word_size)] } {
3327
set word_size $keys(-word_size)
3428
} else {
3529
utl::error RAM 2 "The -word_size argument must be specified."
3630
}
3731

32+
if { [info exists keys(-mask_size)] } {
33+
set mask_size $keys(-mask_size)
34+
} else {
35+
set mask_size $word_size
36+
}
37+
3838
if { $word_size % $mask_size != 0 } {
3939
utl::error RAM 26 "The -word_size ($word_size) must be divisible by -mask_size ($mask_size)."
4040
}
@@ -93,7 +93,7 @@ proc generate_ram_netlist { args } {
9393
$tristate_cell $inv_cell $read_ports $use_latch $tapcell $max_tap_dist
9494
}
9595

96-
sta::define_cmd_args "generate_ram" {-mask_size bits
96+
sta::define_cmd_args "generate_ram" {[-mask_size bits]
9797
-word_size bits
9898
-num_words words
9999
[-column_mux_ratio ratio]
@@ -129,10 +129,13 @@ proc generate_ram { args } {
129129
}
130130

131131
set ram_netlist_args [list \
132-
-mask_size $keys(-mask_size) \
133132
-word_size $keys(-word_size) \
134133
-num_words $keys(-num_words)]
135134

135+
if { [info exists keys(-mask_size)] } {
136+
lappend ram_netlist_args -mask_size $keys(-mask_size)
137+
}
138+
136139
if { [info exists keys(-read_ports)] } {
137140
lappend ram_netlist_args -read_ports $keys(-read_ports)
138141
}

0 commit comments

Comments
 (0)