Skip to content

ram: Check PDN parameters #9961

Closed
Closed

Description

@rovinski

If the provided PDN width/pitch are too large, calling RamGen::ramPdngen() can result in a segfault.

The pitch and width parameters should be checked to make sure that they are not larger than the die size. Otherwise, error.

There may be error checking already done in the PDN module which we aren't calling. Or the error checking might be in Tcl so we are circumventing it by calling it in C++. There may be some slight code duplication but ram needs to not segfault.

Activity

  1. added
    bugSomething isn't working
    pdnPower Grid Generation
    ramDFF Ram Generator
    on Mar 26, 2026
  2. added theissue type on Mar 26, 2026
  3. gadfort commented on Mar 26, 2026

    @gadfort
    Contributor

    @rovinski these checks are handled inside PDN, so it should not be possible to bypass (unless there is a bug in PDN). Can you share a testcase?

  4. rovinski commented on Mar 26, 2026

    @rovinski
    CollaboratorAuthor

    @tnguy19 Can you open a PR with the code changes that caused the segfault and point @gadfort to them?

  5. tnguy19 commented on Mar 26, 2026

    @tnguy19
    Contributor

    @gadfort Hi, so I ran into this while working on implementing column/mux support where if you set a ratio value that causes the RAM to be smaller than the provided PDN width/pitch it will result in a segmentation fault. You can get a similar result by creating a RAM that is small enough. For example if you create a 4x8 RAM using:

    source "helpers.tcl"
    
    read_liberty sky130hd/sky130_fd_sc_hd__tt_025C_1v80.lib
    read_lef sky130hd/sky130hd.tlef
    read_lef sky130hd/sky130_fd_sc_hd_merged.lef
    
    generate_ram \
      -mask_size 8 \
      -word_size 8 \
      -num_words 4 \
      -read_ports 1 \
      -storage_cell sky130_fd_sc_hd__dfxtp_1 \
      -power_pin VPWR \
      -ground_pin VGND \
      -routing_layer {met1 0.48} \
      -ver_layer {met2 0.48 40} \
      -hor_layer {met3 0.48 20} \
      -filler_cells {sky130_fd_sc_hd__fill_1 sky130_fd_sc_hd__fill_2 \
        sky130_fd_sc_hd__fill_4 sky130_fd_sc_hd__fill_8} \
      -tapcell sky130_fd_sc_hd__tap_1 \
      -max_tap_dist 15
    

    You will run into a segmentation fault with the output:

    [INFO PDN-0001] Inserting grid: ram_grid
    Signal 11 received
    Stack trace:
    (...)
    2# odb::dbTrackGrid::getGridY() in openroad 
    3# pdn::TechLayer::populateGrid(odb::dbBlock*, odb::dbTechLayerDir) in openroad 
    4# pdn::Straps::makeShapes(...) in openroad 8# pdn::PdnGen::buildGrids(bool) in openroad 
    (...)
    9# ram::RamGen::ramPdngen(...) in openroad 
    (...)
    Segmentation fault (core dumped)
    

    But if you change the command to:

     -ver_layer {met2 0.48 10} \
     -hor_layer {met3 0.48 10}
    

    It will run succesfully without error. I have a fix that checks the die dimension against the size of the width and pitch and gives an error instead of outputing the segmentation fault at the top of the ramPdngen() function that I'll open a PR for.

  6. rovinski commented on Mar 27, 2026

    @rovinski
    CollaboratorAuthor

    @tnguy19 thanks, let's let @gadfort take a look at it first to determine whether it's something that should be fixed in pdn or something that should be fixed in ram.

  7. gadfort commented on Mar 27, 2026

    @gadfort
    Contributor

    @tnguy19 the issue here is that PDN is assuming the tracks have been created (which they have not), so it blindly accesses the grid but it's a nullptr.

    
      ram::ram_pdngen $power_pin $ground_pin $route_name $route_width \
        $ver_name $ver_width $ver_pitch $hor_name $hor_width $hor_pitch
    
      make_tracks -x_offset 0 -y_offset 0
    
      ram::ram_pinplacer $ver_name $hor_name
    

    should be

      make_tracks -x_offset 0 -y_offset 0
    
      ram::ram_pdngen $power_pin $ground_pin $route_name $route_width \
        $ver_name $ver_width $ver_pitch $hor_name $hor_width $hor_pitch
    
      ram::ram_pinplacer $ver_name $hor_name
    
  8. rovinski commented on Mar 27, 2026

    @rovinski
    CollaboratorAuthor

    Thanks!

    @tnguy19 can you merge the latest master into your fork and check to make sure that it doesn't segfault anymore (i.e. without your error checking)?

  9. rovinski commented on Apr 6, 2026

    @rovinski
    CollaboratorAuthor

    Closed in #9968

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingpdnPower Grid GenerationramDFF Ram Generator

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions