cacti_interface.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#include <pthread.h> 3310152Satgutier@umich.edu 3410152Satgutier@umich.edu#include <algorithm> 3510152Satgutier@umich.edu#include <cmath> 3610152Satgutier@umich.edu#include <ctime> 3710152Satgutier@umich.edu#include <iostream> 3810152Satgutier@umich.edu 3910152Satgutier@umich.edu#include "Ucache.h" 4010152Satgutier@umich.edu#include "area.h" 4110152Satgutier@umich.edu#include "basic_circuit.h" 4210152Satgutier@umich.edu#include "cacti_interface.h" 4310152Satgutier@umich.edu#include "component.h" 4410152Satgutier@umich.edu#include "const.h" 4510152Satgutier@umich.edu#include "parameter.h" 4610152Satgutier@umich.edu 4710152Satgutier@umich.eduusing namespace std; 4810152Satgutier@umich.edu 4910152Satgutier@umich.edu 5010152Satgutier@umich.edubool mem_array::lt(const mem_array * m1, const mem_array * m2) 5110152Satgutier@umich.edu{ 5210152Satgutier@umich.edu if (m1->Nspd < m2->Nspd) return true; 5310152Satgutier@umich.edu else if (m1->Nspd > m2->Nspd) return false; 5410152Satgutier@umich.edu else if (m1->Ndwl < m2->Ndwl) return true; 5510152Satgutier@umich.edu else if (m1->Ndwl > m2->Ndwl) return false; 5610152Satgutier@umich.edu else if (m1->Ndbl < m2->Ndbl) return true; 5710152Satgutier@umich.edu else if (m1->Ndbl > m2->Ndbl) return false; 5810152Satgutier@umich.edu else if (m1->deg_bl_muxing < m2->deg_bl_muxing) return true; 5910152Satgutier@umich.edu else if (m1->deg_bl_muxing > m2->deg_bl_muxing) return false; 6010152Satgutier@umich.edu else if (m1->Ndsam_lev_1 < m2->Ndsam_lev_1) return true; 6110152Satgutier@umich.edu else if (m1->Ndsam_lev_1 > m2->Ndsam_lev_1) return false; 6210152Satgutier@umich.edu else if (m1->Ndsam_lev_2 < m2->Ndsam_lev_2) return true; 6310152Satgutier@umich.edu else return false; 6410152Satgutier@umich.edu} 6510152Satgutier@umich.edu 6610152Satgutier@umich.edu 6710152Satgutier@umich.edu 6810152Satgutier@umich.eduvoid uca_org_t::find_delay() 6910152Satgutier@umich.edu{ 7010152Satgutier@umich.edu mem_array * data_arr = data_array2; 7110152Satgutier@umich.edu mem_array * tag_arr = tag_array2; 7210152Satgutier@umich.edu 7310152Satgutier@umich.edu // check whether it is a regular cache or scratch ram 7410152Satgutier@umich.edu if (g_ip->pure_ram|| g_ip->pure_cam || g_ip->fully_assoc) 7510152Satgutier@umich.edu { 7610152Satgutier@umich.edu access_time = data_arr->access_time; 7710152Satgutier@umich.edu } 7810152Satgutier@umich.edu // Both tag and data lookup happen in parallel 7910152Satgutier@umich.edu // and the entire set is sent over the data array h-tree without 8010152Satgutier@umich.edu // waiting for the way-select signal --TODO add the corresponding 8110152Satgutier@umich.edu // power overhead Nav 8210152Satgutier@umich.edu else if (g_ip->fast_access == true) 8310152Satgutier@umich.edu { 8410152Satgutier@umich.edu access_time = MAX(tag_arr->access_time, data_arr->access_time); 8510152Satgutier@umich.edu } 8610152Satgutier@umich.edu // Tag is accessed first. On a hit, way-select signal along with the 8710152Satgutier@umich.edu // address is sent to read/write the appropriate block in the data 8810152Satgutier@umich.edu // array 8910152Satgutier@umich.edu else if (g_ip->is_seq_acc == true) 9010152Satgutier@umich.edu { 9110152Satgutier@umich.edu access_time = tag_arr->access_time + data_arr->access_time; 9210152Satgutier@umich.edu } 9310152Satgutier@umich.edu // Normal access: tag array access and data array access happen in parallel. 9410152Satgutier@umich.edu // But, the data array will wait for the way-select and transfer only the 9510152Satgutier@umich.edu // appropriate block over the h-tree. 9610152Satgutier@umich.edu else 9710152Satgutier@umich.edu { 9810152Satgutier@umich.edu access_time = MAX(tag_arr->access_time + data_arr->delay_senseamp_mux_decoder, 9910152Satgutier@umich.edu data_arr->delay_before_subarray_output_driver) + 10010152Satgutier@umich.edu data_arr->delay_from_subarray_output_driver_to_output; 10110152Satgutier@umich.edu } 10210152Satgutier@umich.edu} 10310152Satgutier@umich.edu 10410152Satgutier@umich.edu 10510152Satgutier@umich.edu 10610152Satgutier@umich.eduvoid uca_org_t::find_energy() 10710152Satgutier@umich.edu{ 10810152Satgutier@umich.edu if (!(g_ip->pure_ram|| g_ip->pure_cam || g_ip->fully_assoc))//(g_ip->is_cache) 10910152Satgutier@umich.edu power = data_array2->power + tag_array2->power; 11010152Satgutier@umich.edu else 11110152Satgutier@umich.edu power = data_array2->power; 11210152Satgutier@umich.edu} 11310152Satgutier@umich.edu 11410152Satgutier@umich.edu 11510152Satgutier@umich.edu 11610152Satgutier@umich.eduvoid uca_org_t::find_area() 11710152Satgutier@umich.edu{ 11810152Satgutier@umich.edu if (g_ip->pure_ram|| g_ip->pure_cam || g_ip->fully_assoc)//(g_ip->is_cache == false) 11910152Satgutier@umich.edu { 12010152Satgutier@umich.edu cache_ht = data_array2->height; 12110152Satgutier@umich.edu cache_len = data_array2->width; 12210152Satgutier@umich.edu } 12310152Satgutier@umich.edu else 12410152Satgutier@umich.edu { 12510152Satgutier@umich.edu cache_ht = MAX(tag_array2->height, data_array2->height); 12610152Satgutier@umich.edu cache_len = tag_array2->width + data_array2->width; 12710152Satgutier@umich.edu } 12810152Satgutier@umich.edu area = cache_ht * cache_len; 12910152Satgutier@umich.edu} 13010152Satgutier@umich.edu 13110152Satgutier@umich.eduvoid uca_org_t::adjust_area() 13210152Satgutier@umich.edu{ 13310152Satgutier@umich.edu double area_adjust; 13410152Satgutier@umich.edu if (g_ip->pure_ram|| g_ip->pure_cam || g_ip->fully_assoc) 13510152Satgutier@umich.edu { 13610152Satgutier@umich.edu if (data_array2->area_efficiency/100.0<0.2) 13710152Satgutier@umich.edu { 13810152Satgutier@umich.edu //area_adjust = sqrt(area/(area*(data_array2->area_efficiency/100.0)/0.2)); 13910152Satgutier@umich.edu area_adjust = sqrt(0.2/(data_array2->area_efficiency/100.0)); 14010152Satgutier@umich.edu cache_ht = cache_ht/area_adjust; 14110152Satgutier@umich.edu cache_len = cache_len/area_adjust; 14210152Satgutier@umich.edu } 14310152Satgutier@umich.edu } 14410152Satgutier@umich.edu area = cache_ht * cache_len; 14510152Satgutier@umich.edu} 14610152Satgutier@umich.edu 14710152Satgutier@umich.eduvoid uca_org_t::find_cyc() 14810152Satgutier@umich.edu{ 14910152Satgutier@umich.edu if ((g_ip->pure_ram|| g_ip->pure_cam || g_ip->fully_assoc))//(g_ip->is_cache == false) 15010152Satgutier@umich.edu { 15110152Satgutier@umich.edu cycle_time = data_array2->cycle_time; 15210152Satgutier@umich.edu } 15310152Satgutier@umich.edu else 15410152Satgutier@umich.edu { 15510152Satgutier@umich.edu cycle_time = MAX(tag_array2->cycle_time, 15610152Satgutier@umich.edu data_array2->cycle_time); 15710152Satgutier@umich.edu } 15810152Satgutier@umich.edu} 15910152Satgutier@umich.edu 16010152Satgutier@umich.eduuca_org_t :: uca_org_t() 16110152Satgutier@umich.edu:tag_array2(0), 16210152Satgutier@umich.edu data_array2(0) 16310152Satgutier@umich.edu{ 16410152Satgutier@umich.edu 16510152Satgutier@umich.edu} 16610152Satgutier@umich.edu 16710152Satgutier@umich.eduvoid uca_org_t :: cleanup() 16810152Satgutier@umich.edu{ 16910152Satgutier@umich.edu if (data_array2!=0) 17010152Satgutier@umich.edu delete data_array2; 17110152Satgutier@umich.edu if (tag_array2!=0) 17210152Satgutier@umich.edu delete tag_array2; 17310152Satgutier@umich.edu} 174