1 /*****************************************************************************
3 * SOFTWARE LICENSE AGREEMENT
4 * Copyright 2012 Hewlett-Packard Development Company, L.P.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions are
9 * met: redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer;
11 * redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution;
14 * neither the name of the copyright holders nor the names of its
15 * contributors may be used to endorse or promote products derived from
16 * this software without specific prior written permission.
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.”
30 ***************************************************************************/
41 Subarray::Subarray(const DynamicParameter
& dp_
, bool is_fa_
):
42 dp(dp_
), num_rows(dp
.num_r_subarray
), num_cols(dp
.num_c_subarray
),
43 num_cols_fa_cam(dp
.tag_num_c_subarray
), num_cols_fa_ram(dp
.data_num_c_subarray
),
44 cell(dp
.cell
), cam_cell(dp
.cam_cell
), is_fa(is_fa_
)
47 //cout<<"num_cols ="<< num_cols <<endl;
48 if (!(is_fa
|| dp
.pure_cam
))
50 num_cols
+=(g_ip
->add_ecc_b_
? (int)ceil(num_cols
/ num_bits_per_ecc_b_
) : 0); // ECC overhead
51 uint32_t ram_num_cells_wl_stitching
=
52 (dp
.ram_cell_tech_type
== lp_dram
) ? dram_num_cells_wl_stitching_
:
53 (dp
.ram_cell_tech_type
== comm_dram
) ? comm_dram_num_cells_wl_stitching_
: sram_num_cells_wl_stitching_
;
55 area
.h
= cell
.h
* num_rows
;
57 area
.w
= cell
.w
* num_cols
+
58 ceil(num_cols
/ ram_num_cells_wl_stitching
) * g_tp
.ram_wl_stitching_overhead_
; // stitching overhead
63 //should not add dummy row here since the dummy row do not need decoder
64 if (is_fa
)// fully associative cache
66 num_cols_fa_cam
+= g_ip
->add_ecc_b_
? (int)ceil(num_cols_fa_cam
/ num_bits_per_ecc_b_
) : 0;
67 num_cols_fa_ram
+= (g_ip
->add_ecc_b_
? (int)ceil(num_cols_fa_ram
/ num_bits_per_ecc_b_
) : 0);
68 num_cols
= num_cols_fa_cam
+ num_cols_fa_ram
;
72 num_cols_fa_cam
+= g_ip
->add_ecc_b_
? (int)ceil(num_cols_fa_cam
/ num_bits_per_ecc_b_
) : 0;
74 num_cols
= num_cols_fa_cam
;
77 area
.h
= cam_cell
.h
* (num_rows
+ 1);//height of subarray is decided by CAM array. blank space in sram array are filled with dummy cells
78 area
.w
= cam_cell
.w
* num_cols_fa_cam
+ cell
.w
* num_cols_fa_ram
79 + ceil((num_cols_fa_cam
+ num_cols_fa_ram
) / sram_num_cells_wl_stitching_
)*g_tp
.ram_wl_stitching_overhead_
80 + 16*g_tp
.wire_local
.pitch
//the overhead for the NAND gate to connect the two halves
81 + 128*g_tp
.wire_local
.pitch
;//the overhead for the drivers from matchline to wordline of RAM
97 double Subarray::get_total_cell_area()
99 // return (is_fa==false? cell.get_area() * num_rows * num_cols
100 // //: cam_cell.h*(num_rows+1)*(num_cols_fa_cam + sram_cell.get_area()*num_cols_fa_ram));
101 // : cam_cell.get_area()*(num_rows+1)*(num_cols_fa_cam + num_cols_fa_ram));
102 // //: cam_cell.get_area()*(num_rows+1)*num_cols_fa_cam + sram_cell.get_area()*(num_rows+1)*num_cols_fa_ram);//for FA, this area does not include the dummy cells in SRAM arrays.
104 if (!(is_fa
|| dp
.pure_cam
))
105 return (cell
.get_area() * num_rows
* num_cols
);
107 { //for FA, this area includes the dummy cells in SRAM arrays.
108 //return (cam_cell.get_area()*(num_rows+1)*(num_cols_fa_cam + num_cols_fa_ram));
109 //cout<<"diff" <<cam_cell.get_area()*(num_rows+1)*(num_cols_fa_cam + num_cols_fa_ram)- cam_cell.h*(num_rows+1)*(cam_cell.w*num_cols_fa_cam + cell.w*num_cols_fa_ram)<<endl;
110 return (cam_cell
.h
*(num_rows
+1)*(cam_cell
.w
*num_cols_fa_cam
+ cell
.w
*num_cols_fa_ram
));
113 return (cam_cell
.get_area()*(num_rows
+1)*num_cols_fa_cam
);
120 void Subarray::compute_C()
122 double c_w_metal
= cell
.w
* g_tp
.wire_local
.C_per_um
;
123 double r_w_metal
= cell
.w
* g_tp
.wire_local
.R_per_um
;
124 double C_b_metal
= cell
.h
* g_tp
.wire_local
.C_per_um
;
125 double C_b_row_drain_C
;
129 C_wl
= (gate_C_pass(g_tp
.dram
.cell_a_w
, g_tp
.dram
.b_w
, true, true) + c_w_metal
) * num_cols
;
131 if (dp
.ram_cell_tech_type
== comm_dram
)
133 C_bl
= num_rows
* C_b_metal
;
137 C_b_row_drain_C
= drain_C_(g_tp
.dram
.cell_a_w
, NCH
, 1, 0, cell
.w
, true, true) / 2.0; // due to shared contact
138 C_bl
= num_rows
* (C_b_row_drain_C
+ C_b_metal
);
143 if (!(is_fa
||dp
.pure_cam
))
145 C_wl
= (gate_C_pass(g_tp
.sram
.cell_a_w
, (g_tp
.sram
.b_w
-2*g_tp
.sram
.cell_a_w
)/2.0, false, true)*2 +
146 c_w_metal
) * num_cols
;
147 C_b_row_drain_C
= drain_C_(g_tp
.sram
.cell_a_w
, NCH
, 1, 0, cell
.w
, false, true) / 2.0; // due to shared contact
148 C_bl
= num_rows
* (C_b_row_drain_C
+ C_b_metal
);
152 //Following is wordline not matchline
154 c_w_metal
= cam_cell
.w
* g_tp
.wire_local
.C_per_um
;
155 r_w_metal
= cam_cell
.w
* g_tp
.wire_local
.R_per_um
;
156 C_wl_cam
= (gate_C_pass(g_tp
.cam
.cell_a_w
, (g_tp
.cam
.b_w
-2*g_tp
.cam
.cell_a_w
)/2.0, false, true)*2 +
157 c_w_metal
) * num_cols_fa_cam
;
158 R_wl_cam
= (r_w_metal
) * num_cols_fa_cam
;
163 c_w_metal
= cell
.w
* g_tp
.wire_local
.C_per_um
;
164 r_w_metal
= cell
.w
* g_tp
.wire_local
.R_per_um
;
165 C_wl_ram
= (gate_C_pass(g_tp
.sram
.cell_a_w
, (g_tp
.sram
.b_w
-2*g_tp
.sram
.cell_a_w
)/2.0, false, true)*2 +
166 c_w_metal
) * num_cols_fa_ram
;
167 R_wl_ram
= (r_w_metal
) * num_cols_fa_ram
;
171 C_wl_ram
= R_wl_ram
=0;
173 C_wl
= C_wl_cam
+ C_wl_ram
;
174 C_wl
+= (16+128)*g_tp
.wire_local
.pitch
*g_tp
.wire_local
.C_per_um
;
176 R_wl
= R_wl_cam
+ R_wl_ram
;
177 R_wl
+= (16+128)*g_tp
.wire_local
.pitch
*g_tp
.wire_local
.R_per_um
;
179 //there are two ways to write to a FA,
180 //1) Write to CAM array then force a match on match line to active the corresponding wordline in RAM;
181 //2) using separate wordline for read/write and search in RAM.
182 //We are using the second approach.
184 //Bitline CAM portion This is bitline not searchline. We assume no sharing between bitline and searchline according to SUN's implementations.
185 C_b_metal
= cam_cell
.h
* g_tp
.wire_local
.C_per_um
;
186 C_b_row_drain_C
= drain_C_(g_tp
.cam
.cell_a_w
, NCH
, 1, 0, cam_cell
.w
, false, true) / 2.0; // due to shared contact
187 C_bl_cam
= (num_rows
+1) * (C_b_row_drain_C
+ C_b_metal
);
188 //height of subarray is decided by CAM array. blank space in sram array are filled with dummy cells
189 C_b_row_drain_C
= drain_C_(g_tp
.sram
.cell_a_w
, NCH
, 1, 0, cell
.w
, false, true) / 2.0; // due to shared contact
190 C_bl
= (num_rows
+1) * (C_b_row_drain_C
+ C_b_metal
);