subarray.cc revision 10152
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. 510152Satgutier@umich.edu * All Rights Reserved 610152Satgutier@umich.edu * 710152Satgutier@umich.edu * Redistribution and use in source and binary forms, with or without 810152Satgutier@umich.edu * modification, are permitted provided that the following conditions are 910152Satgutier@umich.edu * met: redistributions of source code must retain the above copyright 1010152Satgutier@umich.edu * notice, this list of conditions and the following disclaimer; 1110152Satgutier@umich.edu * redistributions in binary form must reproduce the above copyright 1210152Satgutier@umich.edu * notice, this list of conditions and the following disclaimer in the 1310152Satgutier@umich.edu * documentation and/or other materials provided with the distribution; 1410152Satgutier@umich.edu * neither the name of the copyright holders nor the names of its 1510152Satgutier@umich.edu * contributors may be used to endorse or promote products derived from 1610152Satgutier@umich.edu * this software without specific prior written permission. 1710152Satgutier@umich.edu 1810152Satgutier@umich.edu * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 1910152Satgutier@umich.edu * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 2010152Satgutier@umich.edu * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 2110152Satgutier@umich.edu * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 2210152Satgutier@umich.edu * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 2310152Satgutier@umich.edu * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 2410152Satgutier@umich.edu * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 2510152Satgutier@umich.edu * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 2610152Satgutier@umich.edu * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 2710152Satgutier@umich.edu * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 2810152Satgutier@umich.edu * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.” 2910152Satgutier@umich.edu * 3010152Satgutier@umich.edu ***************************************************************************/ 3110152Satgutier@umich.edu 3210152Satgutier@umich.edu 3310152Satgutier@umich.edu 3410152Satgutier@umich.edu 3510152Satgutier@umich.edu#include <cassert> 3610152Satgutier@umich.edu#include <cmath> 3710152Satgutier@umich.edu#include <iostream> 3810152Satgutier@umich.edu 3910152Satgutier@umich.edu#include "subarray.h" 4010152Satgutier@umich.edu 4110152Satgutier@umich.eduSubarray::Subarray(const DynamicParameter & dp_, bool is_fa_): 4210152Satgutier@umich.edu dp(dp_), num_rows(dp.num_r_subarray), num_cols(dp.num_c_subarray), 4310152Satgutier@umich.edu num_cols_fa_cam(dp.tag_num_c_subarray), num_cols_fa_ram(dp.data_num_c_subarray), 4410152Satgutier@umich.edu cell(dp.cell), cam_cell(dp.cam_cell), is_fa(is_fa_) 4510152Satgutier@umich.edu{ 4610152Satgutier@umich.edu //num_cols=7; 4710152Satgutier@umich.edu //cout<<"num_cols ="<< num_cols <<endl; 4810152Satgutier@umich.edu if (!(is_fa || dp.pure_cam)) 4910152Satgutier@umich.edu { 5010152Satgutier@umich.edu num_cols +=(g_ip->add_ecc_b_ ? (int)ceil(num_cols / num_bits_per_ecc_b_) : 0); // ECC overhead 5110152Satgutier@umich.edu uint32_t ram_num_cells_wl_stitching = 5210152Satgutier@umich.edu (dp.ram_cell_tech_type == lp_dram) ? dram_num_cells_wl_stitching_ : 5310152Satgutier@umich.edu (dp.ram_cell_tech_type == comm_dram) ? comm_dram_num_cells_wl_stitching_ : sram_num_cells_wl_stitching_; 5410152Satgutier@umich.edu 5510152Satgutier@umich.edu area.h = cell.h * num_rows; 5610152Satgutier@umich.edu 5710152Satgutier@umich.edu area.w = cell.w * num_cols + 5810152Satgutier@umich.edu ceil(num_cols / ram_num_cells_wl_stitching) * g_tp.ram_wl_stitching_overhead_; // stitching overhead 5910152Satgutier@umich.edu } 6010152Satgutier@umich.edu else //cam fa 6110152Satgutier@umich.edu { 6210152Satgutier@umich.edu 6310152Satgutier@umich.edu //should not add dummy row here since the dummy row do not need decoder 6410152Satgutier@umich.edu if (is_fa)// fully associative cache 6510152Satgutier@umich.edu { 6610152Satgutier@umich.edu num_cols_fa_cam += g_ip->add_ecc_b_ ? (int)ceil(num_cols_fa_cam / num_bits_per_ecc_b_) : 0; 6710152Satgutier@umich.edu num_cols_fa_ram += (g_ip->add_ecc_b_ ? (int)ceil(num_cols_fa_ram / num_bits_per_ecc_b_) : 0); 6810152Satgutier@umich.edu num_cols = num_cols_fa_cam + num_cols_fa_ram; 6910152Satgutier@umich.edu } 7010152Satgutier@umich.edu else 7110152Satgutier@umich.edu { 7210152Satgutier@umich.edu num_cols_fa_cam += g_ip->add_ecc_b_ ? (int)ceil(num_cols_fa_cam / num_bits_per_ecc_b_) : 0; 7310152Satgutier@umich.edu num_cols_fa_ram = 0; 7410152Satgutier@umich.edu num_cols = num_cols_fa_cam; 7510152Satgutier@umich.edu } 7610152Satgutier@umich.edu 7710152Satgutier@umich.edu 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 7810152Satgutier@umich.edu area.w = cam_cell.w * num_cols_fa_cam + cell.w * num_cols_fa_ram 7910152Satgutier@umich.edu + ceil((num_cols_fa_cam + num_cols_fa_ram) / sram_num_cells_wl_stitching_)*g_tp.ram_wl_stitching_overhead_ 8010152Satgutier@umich.edu + 16*g_tp.wire_local.pitch //the overhead for the NAND gate to connect the two halves 8110152Satgutier@umich.edu + 128*g_tp.wire_local.pitch;//the overhead for the drivers from matchline to wordline of RAM 8210152Satgutier@umich.edu } 8310152Satgutier@umich.edu 8410152Satgutier@umich.edu assert(area.h>0); 8510152Satgutier@umich.edu assert(area.w>0); 8610152Satgutier@umich.edu compute_C(); 8710152Satgutier@umich.edu} 8810152Satgutier@umich.edu 8910152Satgutier@umich.edu 9010152Satgutier@umich.edu 9110152Satgutier@umich.eduSubarray::~Subarray() 9210152Satgutier@umich.edu{ 9310152Satgutier@umich.edu} 9410152Satgutier@umich.edu 9510152Satgutier@umich.edu 9610152Satgutier@umich.edu 9710152Satgutier@umich.edudouble Subarray::get_total_cell_area() 9810152Satgutier@umich.edu{ 9910152Satgutier@umich.edu// return (is_fa==false? cell.get_area() * num_rows * num_cols 10010152Satgutier@umich.edu// //: cam_cell.h*(num_rows+1)*(num_cols_fa_cam + sram_cell.get_area()*num_cols_fa_ram)); 10110152Satgutier@umich.edu// : cam_cell.get_area()*(num_rows+1)*(num_cols_fa_cam + num_cols_fa_ram)); 10210152Satgutier@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. 10310152Satgutier@umich.edu 10410152Satgutier@umich.edu if (!(is_fa || dp.pure_cam)) 10510152Satgutier@umich.edu return (cell.get_area() * num_rows * num_cols); 10610152Satgutier@umich.edu else if (is_fa) 10710152Satgutier@umich.edu { //for FA, this area includes the dummy cells in SRAM arrays. 10810152Satgutier@umich.edu //return (cam_cell.get_area()*(num_rows+1)*(num_cols_fa_cam + num_cols_fa_ram)); 10910152Satgutier@umich.edu //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; 11010152Satgutier@umich.edu return (cam_cell.h*(num_rows+1)*(cam_cell.w*num_cols_fa_cam + cell.w*num_cols_fa_ram)); 11110152Satgutier@umich.edu } 11210152Satgutier@umich.edu else 11310152Satgutier@umich.edu return (cam_cell.get_area()*(num_rows+1)*num_cols_fa_cam ); 11410152Satgutier@umich.edu 11510152Satgutier@umich.edu 11610152Satgutier@umich.edu} 11710152Satgutier@umich.edu 11810152Satgutier@umich.edu 11910152Satgutier@umich.edu 12010152Satgutier@umich.eduvoid Subarray::compute_C() 12110152Satgutier@umich.edu{ 12210152Satgutier@umich.edu double c_w_metal = cell.w * g_tp.wire_local.C_per_um; 12310152Satgutier@umich.edu double r_w_metal = cell.w * g_tp.wire_local.R_per_um; 12410152Satgutier@umich.edu double C_b_metal = cell.h * g_tp.wire_local.C_per_um; 12510152Satgutier@umich.edu double C_b_row_drain_C; 12610152Satgutier@umich.edu 12710152Satgutier@umich.edu if (dp.is_dram) 12810152Satgutier@umich.edu { 12910152Satgutier@umich.edu C_wl = (gate_C_pass(g_tp.dram.cell_a_w, g_tp.dram.b_w, true, true) + c_w_metal) * num_cols; 13010152Satgutier@umich.edu 13110152Satgutier@umich.edu if (dp.ram_cell_tech_type == comm_dram) 13210152Satgutier@umich.edu { 13310152Satgutier@umich.edu C_bl = num_rows * C_b_metal; 13410152Satgutier@umich.edu } 13510152Satgutier@umich.edu else 13610152Satgutier@umich.edu { 13710152Satgutier@umich.edu 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 13810152Satgutier@umich.edu C_bl = num_rows * (C_b_row_drain_C + C_b_metal); 13910152Satgutier@umich.edu } 14010152Satgutier@umich.edu } 14110152Satgutier@umich.edu else 14210152Satgutier@umich.edu { 14310152Satgutier@umich.edu if (!(is_fa ||dp.pure_cam)) 14410152Satgutier@umich.edu { 14510152Satgutier@umich.edu 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 + 14610152Satgutier@umich.edu c_w_metal) * num_cols; 14710152Satgutier@umich.edu 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 14810152Satgutier@umich.edu C_bl = num_rows * (C_b_row_drain_C + C_b_metal); 14910152Satgutier@umich.edu } 15010152Satgutier@umich.edu else 15110152Satgutier@umich.edu { 15210152Satgutier@umich.edu //Following is wordline not matchline 15310152Satgutier@umich.edu //CAM portion 15410152Satgutier@umich.edu c_w_metal = cam_cell.w * g_tp.wire_local.C_per_um; 15510152Satgutier@umich.edu r_w_metal = cam_cell.w * g_tp.wire_local.R_per_um; 15610152Satgutier@umich.edu 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 + 15710152Satgutier@umich.edu c_w_metal) * num_cols_fa_cam; 15810152Satgutier@umich.edu R_wl_cam = (r_w_metal) * num_cols_fa_cam; 15910152Satgutier@umich.edu 16010152Satgutier@umich.edu if (!dp.pure_cam) 16110152Satgutier@umich.edu { 16210152Satgutier@umich.edu //RAM portion 16310152Satgutier@umich.edu c_w_metal = cell.w * g_tp.wire_local.C_per_um; 16410152Satgutier@umich.edu r_w_metal = cell.w * g_tp.wire_local.R_per_um; 16510152Satgutier@umich.edu 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 + 16610152Satgutier@umich.edu c_w_metal) * num_cols_fa_ram; 16710152Satgutier@umich.edu R_wl_ram = (r_w_metal) * num_cols_fa_ram; 16810152Satgutier@umich.edu } 16910152Satgutier@umich.edu else 17010152Satgutier@umich.edu { 17110152Satgutier@umich.edu C_wl_ram = R_wl_ram =0; 17210152Satgutier@umich.edu } 17310152Satgutier@umich.edu C_wl = C_wl_cam + C_wl_ram; 17410152Satgutier@umich.edu C_wl += (16+128)*g_tp.wire_local.pitch*g_tp.wire_local.C_per_um; 17510152Satgutier@umich.edu 17610152Satgutier@umich.edu R_wl = R_wl_cam + R_wl_ram; 17710152Satgutier@umich.edu R_wl += (16+128)*g_tp.wire_local.pitch*g_tp.wire_local.R_per_um; 17810152Satgutier@umich.edu 17910152Satgutier@umich.edu //there are two ways to write to a FA, 18010152Satgutier@umich.edu //1) Write to CAM array then force a match on match line to active the corresponding wordline in RAM; 18110152Satgutier@umich.edu //2) using separate wordline for read/write and search in RAM. 18210152Satgutier@umich.edu //We are using the second approach. 18310152Satgutier@umich.edu 18410152Satgutier@umich.edu //Bitline CAM portion This is bitline not searchline. We assume no sharing between bitline and searchline according to SUN's implementations. 18510152Satgutier@umich.edu C_b_metal = cam_cell.h * g_tp.wire_local.C_per_um; 18610152Satgutier@umich.edu 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 18710152Satgutier@umich.edu C_bl_cam = (num_rows+1) * (C_b_row_drain_C + C_b_metal); 18810152Satgutier@umich.edu //height of subarray is decided by CAM array. blank space in sram array are filled with dummy cells 18910152Satgutier@umich.edu 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 19010152Satgutier@umich.edu C_bl = (num_rows +1) * (C_b_row_drain_C + C_b_metal); 19110152Satgutier@umich.edu 19210152Satgutier@umich.edu } 19310152Satgutier@umich.edu } 19410152Satgutier@umich.edu} 19510152Satgutier@umich.edu 19610152Satgutier@umich.edu 197