cacti_interface.cc revision 10152
18868SMatt.Horsnell@arm.com/***************************************************************************** 27191Sgblack@eecs.umich.edu * McPAT/CACTI 37191Sgblack@eecs.umich.edu * SOFTWARE LICENSE AGREEMENT 47191Sgblack@eecs.umich.edu * Copyright 2012 Hewlett-Packard Development Company, L.P. 57191Sgblack@eecs.umich.edu * All Rights Reserved 67191Sgblack@eecs.umich.edu * 77191Sgblack@eecs.umich.edu * Redistribution and use in source and binary forms, with or without 87191Sgblack@eecs.umich.edu * modification, are permitted provided that the following conditions are 97191Sgblack@eecs.umich.edu * met: redistributions of source code must retain the above copyright 107191Sgblack@eecs.umich.edu * notice, this list of conditions and the following disclaimer; 117191Sgblack@eecs.umich.edu * redistributions in binary form must reproduce the above copyright 127191Sgblack@eecs.umich.edu * notice, this list of conditions and the following disclaimer in the 137191Sgblack@eecs.umich.edu * documentation and/or other materials provided with the distribution; 147191Sgblack@eecs.umich.edu * neither the name of the copyright holders nor the names of its 157191Sgblack@eecs.umich.edu * contributors may be used to endorse or promote products derived from 167191Sgblack@eecs.umich.edu * this software without specific prior written permission. 177191Sgblack@eecs.umich.edu 187191Sgblack@eecs.umich.edu * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 197191Sgblack@eecs.umich.edu * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 207191Sgblack@eecs.umich.edu * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 217191Sgblack@eecs.umich.edu * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 227191Sgblack@eecs.umich.edu * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 237191Sgblack@eecs.umich.edu * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 247191Sgblack@eecs.umich.edu * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 257191Sgblack@eecs.umich.edu * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 267191Sgblack@eecs.umich.edu * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 277191Sgblack@eecs.umich.edu * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 287191Sgblack@eecs.umich.edu * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.” 297191Sgblack@eecs.umich.edu * 307191Sgblack@eecs.umich.edu ***************************************************************************/ 317191Sgblack@eecs.umich.edu 327191Sgblack@eecs.umich.edu#include <pthread.h> 337191Sgblack@eecs.umich.edu 347191Sgblack@eecs.umich.edu#include <algorithm> 357191Sgblack@eecs.umich.edu#include <cmath> 367191Sgblack@eecs.umich.edu#include <ctime> 377191Sgblack@eecs.umich.edu#include <iostream> 387191Sgblack@eecs.umich.edu 397191Sgblack@eecs.umich.edu#include "Ucache.h" 407191Sgblack@eecs.umich.edu#include "area.h" 417191Sgblack@eecs.umich.edu#include "basic_circuit.h" 427191Sgblack@eecs.umich.edu#include "cacti_interface.h" 437191Sgblack@eecs.umich.edu#include "component.h" 447191Sgblack@eecs.umich.edu#include "const.h" 457191Sgblack@eecs.umich.edu#include "parameter.h" 467191Sgblack@eecs.umich.edu 477308Sgblack@eecs.umich.eduusing namespace std; 487191Sgblack@eecs.umich.edu 497316Sgblack@eecs.umich.edu 507316Sgblack@eecs.umich.edubool mem_array::lt(const mem_array * m1, const mem_array * m2) 517316Sgblack@eecs.umich.edu{ 527316Sgblack@eecs.umich.edu if (m1->Nspd < m2->Nspd) return true; 537316Sgblack@eecs.umich.edu else if (m1->Nspd > m2->Nspd) return false; 547316Sgblack@eecs.umich.edu else if (m1->Ndwl < m2->Ndwl) return true; 557191Sgblack@eecs.umich.edu else if (m1->Ndwl > m2->Ndwl) return false; 567191Sgblack@eecs.umich.edu else if (m1->Ndbl < m2->Ndbl) return true; 577435Sgblack@eecs.umich.edu else if (m1->Ndbl > m2->Ndbl) return false; 587191Sgblack@eecs.umich.edu else if (m1->deg_bl_muxing < m2->deg_bl_muxing) return true; 597191Sgblack@eecs.umich.edu else if (m1->deg_bl_muxing > m2->deg_bl_muxing) return false; 607435Sgblack@eecs.umich.edu else if (m1->Ndsam_lev_1 < m2->Ndsam_lev_1) return true; 617191Sgblack@eecs.umich.edu else if (m1->Ndsam_lev_1 > m2->Ndsam_lev_1) return false; 627191Sgblack@eecs.umich.edu else if (m1->Ndsam_lev_2 < m2->Ndsam_lev_2) return true; 637248Sgblack@eecs.umich.edu else return false; 647191Sgblack@eecs.umich.edu} 657192Sgblack@eecs.umich.edu 667192Sgblack@eecs.umich.edu 677192Sgblack@eecs.umich.edu 687192Sgblack@eecs.umich.eduvoid uca_org_t::find_delay() 697192Sgblack@eecs.umich.edu{ 707192Sgblack@eecs.umich.edu mem_array * data_arr = data_array2; 717192Sgblack@eecs.umich.edu mem_array * tag_arr = tag_array2; 727192Sgblack@eecs.umich.edu 737192Sgblack@eecs.umich.edu // check whether it is a regular cache or scratch ram 747191Sgblack@eecs.umich.edu if (g_ip->pure_ram|| g_ip->pure_cam || g_ip->fully_assoc) 757191Sgblack@eecs.umich.edu { 767191Sgblack@eecs.umich.edu access_time = data_arr->access_time; 777192Sgblack@eecs.umich.edu } 787192Sgblack@eecs.umich.edu // Both tag and data lookup happen in parallel 797192Sgblack@eecs.umich.edu // and the entire set is sent over the data array h-tree without 807192Sgblack@eecs.umich.edu // waiting for the way-select signal --TODO add the corresponding 817192Sgblack@eecs.umich.edu // power overhead Nav 827192Sgblack@eecs.umich.edu else if (g_ip->fast_access == true) 837192Sgblack@eecs.umich.edu { 847192Sgblack@eecs.umich.edu access_time = MAX(tag_arr->access_time, data_arr->access_time); 857192Sgblack@eecs.umich.edu } 867192Sgblack@eecs.umich.edu // Tag is accessed first. On a hit, way-select signal along with the 877192Sgblack@eecs.umich.edu // address is sent to read/write the appropriate block in the data 887192Sgblack@eecs.umich.edu // array 897192Sgblack@eecs.umich.edu else if (g_ip->is_seq_acc == true) 907192Sgblack@eecs.umich.edu { 917192Sgblack@eecs.umich.edu access_time = tag_arr->access_time + data_arr->access_time; 927192Sgblack@eecs.umich.edu } 937192Sgblack@eecs.umich.edu // Normal access: tag array access and data array access happen in parallel. 947192Sgblack@eecs.umich.edu // But, the data array will wait for the way-select and transfer only the 957192Sgblack@eecs.umich.edu // appropriate block over the h-tree. 967192Sgblack@eecs.umich.edu else 977191Sgblack@eecs.umich.edu { 987191Sgblack@eecs.umich.edu access_time = MAX(tag_arr->access_time + data_arr->delay_senseamp_mux_decoder, 997191Sgblack@eecs.umich.edu data_arr->delay_before_subarray_output_driver) + 1007603SGene.Wu@arm.com data_arr->delay_from_subarray_output_driver_to_output; 1017191Sgblack@eecs.umich.edu } 10210037SARM gem5 Developers} 1037191Sgblack@eecs.umich.edu 10410037SARM gem5 Developers 1057191Sgblack@eecs.umich.edu 10610037SARM gem5 Developersvoid uca_org_t::find_energy() 1077191Sgblack@eecs.umich.edu{ 1087191Sgblack@eecs.umich.edu if (!(g_ip->pure_ram|| g_ip->pure_cam || g_ip->fully_assoc))//(g_ip->is_cache) 1097191Sgblack@eecs.umich.edu power = data_array2->power + tag_array2->power; 1107191Sgblack@eecs.umich.edu else 1117191Sgblack@eecs.umich.edu power = data_array2->power; 1127191Sgblack@eecs.umich.edu} 1137248Sgblack@eecs.umich.edu 1147191Sgblack@eecs.umich.edu 1157192Sgblack@eecs.umich.edu 1167192Sgblack@eecs.umich.eduvoid uca_org_t::find_area() 1177192Sgblack@eecs.umich.edu{ 1187192Sgblack@eecs.umich.edu if (g_ip->pure_ram|| g_ip->pure_cam || g_ip->fully_assoc)//(g_ip->is_cache == false) 1197192Sgblack@eecs.umich.edu { 1207192Sgblack@eecs.umich.edu cache_ht = data_array2->height; 1217192Sgblack@eecs.umich.edu cache_len = data_array2->width; 1227192Sgblack@eecs.umich.edu } 1237192Sgblack@eecs.umich.edu else 1247192Sgblack@eecs.umich.edu { 1257192Sgblack@eecs.umich.edu cache_ht = MAX(tag_array2->height, data_array2->height); 1267192Sgblack@eecs.umich.edu cache_len = tag_array2->width + data_array2->width; 1277192Sgblack@eecs.umich.edu } 1287192Sgblack@eecs.umich.edu area = cache_ht * cache_len; 1297191Sgblack@eecs.umich.edu} 1307192Sgblack@eecs.umich.edu 1317192Sgblack@eecs.umich.eduvoid uca_org_t::adjust_area() 1327192Sgblack@eecs.umich.edu{ 1337192Sgblack@eecs.umich.edu double area_adjust; 1347192Sgblack@eecs.umich.edu if (g_ip->pure_ram|| g_ip->pure_cam || g_ip->fully_assoc) 1357192Sgblack@eecs.umich.edu { 1367192Sgblack@eecs.umich.edu if (data_array2->area_efficiency/100.0<0.2) 1377192Sgblack@eecs.umich.edu { 1387192Sgblack@eecs.umich.edu //area_adjust = sqrt(area/(area*(data_array2->area_efficiency/100.0)/0.2)); 1397192Sgblack@eecs.umich.edu area_adjust = sqrt(0.2/(data_array2->area_efficiency/100.0)); 1407192Sgblack@eecs.umich.edu cache_ht = cache_ht/area_adjust; 1417192Sgblack@eecs.umich.edu cache_len = cache_len/area_adjust; 1427192Sgblack@eecs.umich.edu } 1437192Sgblack@eecs.umich.edu } 1447192Sgblack@eecs.umich.edu area = cache_ht * cache_len; 1457192Sgblack@eecs.umich.edu} 1467192Sgblack@eecs.umich.edu 1477192Sgblack@eecs.umich.eduvoid uca_org_t::find_cyc() 1487192Sgblack@eecs.umich.edu{ 1497192Sgblack@eecs.umich.edu if ((g_ip->pure_ram|| g_ip->pure_cam || g_ip->fully_assoc))//(g_ip->is_cache == false) 1507192Sgblack@eecs.umich.edu { 1517192Sgblack@eecs.umich.edu cycle_time = data_array2->cycle_time; 1527192Sgblack@eecs.umich.edu } 1537192Sgblack@eecs.umich.edu else 1547192Sgblack@eecs.umich.edu { 1557192Sgblack@eecs.umich.edu cycle_time = MAX(tag_array2->cycle_time, 1567192Sgblack@eecs.umich.edu data_array2->cycle_time); 1577192Sgblack@eecs.umich.edu } 1587192Sgblack@eecs.umich.edu} 1597192Sgblack@eecs.umich.edu 1607191Sgblack@eecs.umich.eduuca_org_t :: uca_org_t() 1617191Sgblack@eecs.umich.edu:tag_array2(0), 1627191Sgblack@eecs.umich.edu data_array2(0) 1637191Sgblack@eecs.umich.edu{ 1647191Sgblack@eecs.umich.edu 1657191Sgblack@eecs.umich.edu} 1667191Sgblack@eecs.umich.edu 1677191Sgblack@eecs.umich.eduvoid uca_org_t :: cleanup() 1687314Sgblack@eecs.umich.edu{ 16912788Sgiacomo.travaglini@arm.com if (data_array2!=0) 17012788Sgiacomo.travaglini@arm.com delete data_array2; 17112788Sgiacomo.travaglini@arm.com if (tag_array2!=0) 17212788Sgiacomo.travaglini@arm.com delete tag_array2; 17312788Sgiacomo.travaglini@arm.com} 17412788Sgiacomo.travaglini@arm.com