subarray.cc revision 10234
110152Satgutier@umich.edu/***************************************************************************** 210152Satgutier@umich.edu * McPAT/CACTI 310152Satgutier@umich.edu * SOFTWARE LICENSE AGREEMENT 410152Satgutier@umich.edu * Copyright 2012 Hewlett-Packard Development Company, L.P. 510234Syasuko.eckert@amd.com * Copyright (c) 2010-2013 Advanced Micro Devices, Inc. 610152Satgutier@umich.edu * All Rights Reserved 710152Satgutier@umich.edu * 810152Satgutier@umich.edu * Redistribution and use in source and binary forms, with or without 910152Satgutier@umich.edu * modification, are permitted provided that the following conditions are 1010152Satgutier@umich.edu * met: redistributions of source code must retain the above copyright 1110152Satgutier@umich.edu * notice, this list of conditions and the following disclaimer; 1210152Satgutier@umich.edu * redistributions in binary form must reproduce the above copyright 1310152Satgutier@umich.edu * notice, this list of conditions and the following disclaimer in the 1410152Satgutier@umich.edu * documentation and/or other materials provided with the distribution; 1510152Satgutier@umich.edu * neither the name of the copyright holders nor the names of its 1610152Satgutier@umich.edu * contributors may be used to endorse or promote products derived from 1710152Satgutier@umich.edu * this software without specific prior written permission. 1810152Satgutier@umich.edu 1910152Satgutier@umich.edu * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 2010152Satgutier@umich.edu * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 2110152Satgutier@umich.edu * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 2210152Satgutier@umich.edu * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 2310152Satgutier@umich.edu * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 2410152Satgutier@umich.edu * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 2510152Satgutier@umich.edu * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 2610152Satgutier@umich.edu * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 2710152Satgutier@umich.edu * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 2810152Satgutier@umich.edu * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 2910234Syasuko.eckert@amd.com * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 3010152Satgutier@umich.edu * 3110152Satgutier@umich.edu ***************************************************************************/ 3210152Satgutier@umich.edu 3310152Satgutier@umich.edu 3410152Satgutier@umich.edu 3510152Satgutier@umich.edu 3610152Satgutier@umich.edu#include <cassert> 3710152Satgutier@umich.edu#include <cmath> 3810152Satgutier@umich.edu#include <iostream> 3910152Satgutier@umich.edu 4010152Satgutier@umich.edu#include "subarray.h" 4110152Satgutier@umich.edu 4210152Satgutier@umich.eduSubarray::Subarray(const DynamicParameter & dp_, bool is_fa_): 4310234Syasuko.eckert@amd.com dp(dp_), num_rows(dp.num_r_subarray), num_cols(dp.num_c_subarray), 4410234Syasuko.eckert@amd.com num_cols_fa_cam(dp.tag_num_c_subarray), num_cols_fa_ram(dp.data_num_c_subarray), 4510234Syasuko.eckert@amd.com cell(dp.cell), cam_cell(dp.cam_cell), is_fa(is_fa_) { 4610234Syasuko.eckert@amd.com //num_cols=7; 4710234Syasuko.eckert@amd.com //cout<<"num_cols ="<< num_cols <<endl; 4810234Syasuko.eckert@amd.com if (!(is_fa || dp.pure_cam)) { 4910234Syasuko.eckert@amd.com // ECC overhead 5010234Syasuko.eckert@amd.com num_cols += (g_ip->add_ecc_b_ ? (int)ceil(num_cols / 5110234Syasuko.eckert@amd.com num_bits_per_ecc_b_) : 0); 5210234Syasuko.eckert@amd.com uint32_t ram_num_cells_wl_stitching = 5310234Syasuko.eckert@amd.com (dp.ram_cell_tech_type == lp_dram) ? dram_num_cells_wl_stitching_ : 5410234Syasuko.eckert@amd.com (dp.ram_cell_tech_type == comm_dram) ? comm_dram_num_cells_wl_stitching_ : sram_num_cells_wl_stitching_; 5510152Satgutier@umich.edu 5610234Syasuko.eckert@amd.com area.h = cell.h * num_rows; 5710152Satgutier@umich.edu 5810234Syasuko.eckert@amd.com area.w = cell.w * num_cols + 5910234Syasuko.eckert@amd.com ceil(num_cols / ram_num_cells_wl_stitching) * g_tp.ram_wl_stitching_overhead_; // stitching overhead 6010234Syasuko.eckert@amd.com } else { //cam fa 6110152Satgutier@umich.edu 6210234Syasuko.eckert@amd.com //should not add dummy row here since the dummy row do not need decoder 6310234Syasuko.eckert@amd.com if (is_fa) { // fully associative cache 6410234Syasuko.eckert@amd.com num_cols_fa_cam += g_ip->add_ecc_b_ ? (int)ceil(num_cols_fa_cam / num_bits_per_ecc_b_) : 0; 6510234Syasuko.eckert@amd.com num_cols_fa_ram += (g_ip->add_ecc_b_ ? (int)ceil(num_cols_fa_ram / num_bits_per_ecc_b_) : 0); 6610234Syasuko.eckert@amd.com num_cols = num_cols_fa_cam + num_cols_fa_ram; 6710234Syasuko.eckert@amd.com } else { 6810234Syasuko.eckert@amd.com num_cols_fa_cam += g_ip->add_ecc_b_ ? (int)ceil(num_cols_fa_cam / num_bits_per_ecc_b_) : 0; 6910234Syasuko.eckert@amd.com num_cols_fa_ram = 0; 7010234Syasuko.eckert@amd.com num_cols = num_cols_fa_cam; 7110234Syasuko.eckert@amd.com } 7210152Satgutier@umich.edu 7310234Syasuko.eckert@amd.com 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 7410234Syasuko.eckert@amd.com area.w = cam_cell.w * num_cols_fa_cam + cell.w * num_cols_fa_ram 7510234Syasuko.eckert@amd.com + ceil((num_cols_fa_cam + num_cols_fa_ram) / 7610234Syasuko.eckert@amd.com sram_num_cells_wl_stitching_) * 7710234Syasuko.eckert@amd.com g_tp.ram_wl_stitching_overhead_ 7810234Syasuko.eckert@amd.com //the overhead for the NAND gate to connect the two halves 7910234Syasuko.eckert@amd.com + 16 * g_tp.wire_local.pitch 8010234Syasuko.eckert@amd.com //the overhead for the drivers from matchline to wordline of RAM 8110234Syasuko.eckert@amd.com + 128 * g_tp.wire_local.pitch; 8210234Syasuko.eckert@amd.com } 8310152Satgutier@umich.edu 8410234Syasuko.eckert@amd.com assert(area.h > 0); 8510234Syasuko.eckert@amd.com assert(area.w > 0); 8610234Syasuko.eckert@amd.com compute_C(); 8710152Satgutier@umich.edu} 8810152Satgutier@umich.edu 8910152Satgutier@umich.edu 9010152Satgutier@umich.edu 9110234Syasuko.eckert@amd.comSubarray::~Subarray() { 9210152Satgutier@umich.edu} 9310152Satgutier@umich.edu 9410152Satgutier@umich.edu 9510152Satgutier@umich.edu 9610234Syasuko.eckert@amd.comdouble Subarray::get_total_cell_area() { 9710152Satgutier@umich.edu// return (is_fa==false? cell.get_area() * num_rows * num_cols 9810152Satgutier@umich.edu// //: cam_cell.h*(num_rows+1)*(num_cols_fa_cam + sram_cell.get_area()*num_cols_fa_ram)); 9910152Satgutier@umich.edu// : cam_cell.get_area()*(num_rows+1)*(num_cols_fa_cam + num_cols_fa_ram)); 10010152Satgutier@umich.edu// //: 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. 10110152Satgutier@umich.edu 10210152Satgutier@umich.edu if (!(is_fa || dp.pure_cam)) 10310234Syasuko.eckert@amd.com return (cell.get_area() * num_rows * num_cols); 10410234Syasuko.eckert@amd.com else if (is_fa) { 10510234Syasuko.eckert@amd.com //for FA, this area includes the dummy cells in SRAM arrays. 10610234Syasuko.eckert@amd.com //return (cam_cell.get_area()*(num_rows+1)*(num_cols_fa_cam + num_cols_fa_ram)); 10710234Syasuko.eckert@amd.com //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; 10810234Syasuko.eckert@amd.com return (cam_cell.h * (num_rows + 1) * 10910234Syasuko.eckert@amd.com (cam_cell.w*num_cols_fa_cam + cell.w*num_cols_fa_ram)); 11010234Syasuko.eckert@amd.com } else { 11110234Syasuko.eckert@amd.com return (cam_cell.get_area() * (num_rows + 1) * num_cols_fa_cam ); 11210152Satgutier@umich.edu } 11310152Satgutier@umich.edu 11410152Satgutier@umich.edu 11510152Satgutier@umich.edu} 11610152Satgutier@umich.edu 11710152Satgutier@umich.edu 11810152Satgutier@umich.edu 11910234Syasuko.eckert@amd.comvoid Subarray::compute_C() { 12010234Syasuko.eckert@amd.com double c_w_metal = cell.w * g_tp.wire_local.C_per_um; 12110234Syasuko.eckert@amd.com double r_w_metal = cell.w * g_tp.wire_local.R_per_um; 12210234Syasuko.eckert@amd.com double C_b_metal = cell.h * g_tp.wire_local.C_per_um; 12310234Syasuko.eckert@amd.com double C_b_row_drain_C; 12410152Satgutier@umich.edu 12510234Syasuko.eckert@amd.com if (dp.is_dram) { 12610234Syasuko.eckert@amd.com C_wl = (gate_C_pass(g_tp.dram.cell_a_w, g_tp.dram.b_w, true, true) + c_w_metal) * num_cols; 12710152Satgutier@umich.edu 12810234Syasuko.eckert@amd.com if (dp.ram_cell_tech_type == comm_dram) { 12910234Syasuko.eckert@amd.com C_bl = num_rows * C_b_metal; 13010234Syasuko.eckert@amd.com } else { 13110234Syasuko.eckert@amd.com 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 13210234Syasuko.eckert@amd.com C_bl = num_rows * (C_b_row_drain_C + C_b_metal); 13310234Syasuko.eckert@amd.com } 13410234Syasuko.eckert@amd.com } else { 13510234Syasuko.eckert@amd.com if (!(is_fa || dp.pure_cam)) { 13610234Syasuko.eckert@amd.com C_wl = (gate_C_pass(g_tp.sram.cell_a_w, 13710234Syasuko.eckert@amd.com (g_tp.sram.b_w - 2 * g_tp.sram.cell_a_w) / 2.0, 13810234Syasuko.eckert@amd.com false, true) * 2 + 13910234Syasuko.eckert@amd.com c_w_metal) * num_cols; 14010234Syasuko.eckert@amd.com 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 14110234Syasuko.eckert@amd.com C_bl = num_rows * (C_b_row_drain_C + C_b_metal); 14210234Syasuko.eckert@amd.com } else { 14310234Syasuko.eckert@amd.com //Following is wordline not matchline 14410234Syasuko.eckert@amd.com //CAM portion 14510234Syasuko.eckert@amd.com c_w_metal = cam_cell.w * g_tp.wire_local.C_per_um; 14610234Syasuko.eckert@amd.com r_w_metal = cam_cell.w * g_tp.wire_local.R_per_um; 14710234Syasuko.eckert@amd.com C_wl_cam = (gate_C_pass(g_tp.cam.cell_a_w, 14810234Syasuko.eckert@amd.com (g_tp.cam.b_w - 2 * g_tp.cam.cell_a_w) / 14910234Syasuko.eckert@amd.com 2.0, false, true) * 2 + 15010234Syasuko.eckert@amd.com c_w_metal) * num_cols_fa_cam; 15110234Syasuko.eckert@amd.com R_wl_cam = (r_w_metal) * num_cols_fa_cam; 15210234Syasuko.eckert@amd.com 15310234Syasuko.eckert@amd.com if (!dp.pure_cam) { 15410234Syasuko.eckert@amd.com //RAM portion 15510234Syasuko.eckert@amd.com c_w_metal = cell.w * g_tp.wire_local.C_per_um; 15610234Syasuko.eckert@amd.com r_w_metal = cell.w * g_tp.wire_local.R_per_um; 15710234Syasuko.eckert@amd.com C_wl_ram = (gate_C_pass(g_tp.sram.cell_a_w, 15810234Syasuko.eckert@amd.com (g_tp.sram.b_w - 2 * 15910234Syasuko.eckert@amd.com g_tp.sram.cell_a_w) / 2.0, false, 16010234Syasuko.eckert@amd.com true) * 2 + 16110234Syasuko.eckert@amd.com c_w_metal) * num_cols_fa_ram; 16210234Syasuko.eckert@amd.com R_wl_ram = (r_w_metal) * num_cols_fa_ram; 16310234Syasuko.eckert@amd.com } else { 16410234Syasuko.eckert@amd.com C_wl_ram = R_wl_ram = 0; 16510234Syasuko.eckert@amd.com } 16610234Syasuko.eckert@amd.com C_wl = C_wl_cam + C_wl_ram; 16710234Syasuko.eckert@amd.com C_wl += (16 + 128) * g_tp.wire_local.pitch * 16810234Syasuko.eckert@amd.com g_tp.wire_local.C_per_um; 16910234Syasuko.eckert@amd.com 17010234Syasuko.eckert@amd.com R_wl = R_wl_cam + R_wl_ram; 17110234Syasuko.eckert@amd.com R_wl += (16 + 128) * g_tp.wire_local.pitch * 17210234Syasuko.eckert@amd.com g_tp.wire_local.R_per_um; 17310234Syasuko.eckert@amd.com 17410234Syasuko.eckert@amd.com //there are two ways to write to a FA, 17510234Syasuko.eckert@amd.com //1) Write to CAM array then force a match on match line to active the corresponding wordline in RAM; 17610234Syasuko.eckert@amd.com //2) using separate wordline for read/write and search in RAM. 17710234Syasuko.eckert@amd.com //We are using the second approach. 17810234Syasuko.eckert@amd.com 17910234Syasuko.eckert@amd.com //Bitline CAM portion This is bitline not searchline. We assume no sharing between bitline and searchline according to SUN's implementations. 18010234Syasuko.eckert@amd.com C_b_metal = cam_cell.h * g_tp.wire_local.C_per_um; 18110234Syasuko.eckert@amd.com 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 18210234Syasuko.eckert@amd.com C_bl_cam = (num_rows + 1) * (C_b_row_drain_C + C_b_metal); 18310234Syasuko.eckert@amd.com //height of subarray is decided by CAM array. blank space in sram array are filled with dummy cells 18410234Syasuko.eckert@amd.com 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 18510234Syasuko.eckert@amd.com C_bl = (num_rows + 1) * (C_b_row_drain_C + C_b_metal); 18610234Syasuko.eckert@amd.com 18710234Syasuko.eckert@amd.com } 18810152Satgutier@umich.edu } 18910152Satgutier@umich.edu} 19010152Satgutier@umich.edu 19110152Satgutier@umich.edu 192