@@ -77,6 +77,53 @@ def test_memory(self):
7777 self .assertEqual (timing_data .cycle_time_ns , 0.1566 )
7878 self .assertEqual (timing_data .fo4_ps , 9.0632 )
7979
80+ def _create_sp_ram (self , process , width , depth ):
81+ mem_config = MemoryConfig .from_json (
82+ {"name" : "sample" , "width" : width , "depth" : depth , "banks" : 1 }
83+ )
84+ return MemoryFactory .create (mem_config , "RAM" , "SP" , process , TimingData ())
85+
86+ def _pin_height (self , process , memory ):
87+ return 2 * process .y_offset + memory .get_num_pins () * process .pin_pitch_um
88+
89+ def test_shallow_memory_is_tall_enough_for_its_pins (self ):
90+ """
91+ A 4x25 RAM's bitcells are 1.296 um tall, too short for its 55 pins;
92+ it is made as tall as its pins need, snapped up to 2.8 um
93+ """
94+
95+ memory = self ._create_sp_ram (self ._process , 25 , 4 )
96+ physical = memory .get_physical_data ()
97+ self .assertEqual (memory .get_num_pins (), 55 )
98+ self .assertGreaterEqual (
99+ physical .get_height (), self ._pin_height (self ._process , memory )
100+ )
101+ self .assertAlmostEqual (physical .get_height (), 2.8 , delta = self ._delta )
102+
103+ def test_deep_memory_keeps_bitcell_height (self ):
104+ """A memory whose bitcells already fit its pins is not made taller"""
105+
106+ memory = self ._create_sp_ram (self ._process , 32 , 64 )
107+ _ , height = self ._process .get_macro_dimensions (32 , 64 , 1 , 0 )
108+ self .assertGreater (height , self ._pin_height (self ._process , memory ))
109+ self .assertAlmostEqual (
110+ memory .get_physical_data ().get_height (), 21.0 , delta = self ._delta
111+ )
112+
113+ def test_pins_fit_exactly_without_snapping (self ):
114+ """
115+ With a 1 nm snap the height is exactly what the pins need, and
116+ every pin still gets a track
117+ """
118+
119+ process_data = TestUtils .get_base_process_data ().copy ()
120+ process_data ["snap_height_nm" ] = 1
121+ process = Process (process_data )
122+ for width in range (1 , 300 ):
123+ # constructing the memory raises if its pins do not fit
124+ memory = self ._create_sp_ram (process , width , 4 )
125+ self .assertGreaterEqual (memory .get_physical_data ().get_pin_pitch (), 0 )
126+
80127
81128if __name__ == "__main__" :
82129 unittest .main ()
0 commit comments