source: trunk/IPs/systemC/Environment/Cache/src/Cache_latence.cpp @ 144

Last change on this file since 144 was 144, checked in by rosiere, 14 years ago

1) compatible gcc 4.4.3
2) Translation file in MORPHEO_PREFIX directory

  • Property svn:keywords set to Id
File size: 2.2 KB
Line 
1#include "../include/Cache.h"
2#include <stdio.h>
3
4namespace environment {
5namespace cache {
6 
7  // Return the time to have the data
8  // latence is call on the same port in a single cycle, only the last access is save
9  // { NOTE } : type_cache = 0 : icache, 1 : dcache
10  uint32_t Cache::latence (cache_t               type_cache, 
11                           uint32_t              num_entity, 
12                           uint32_t              num_port  , 
13                           uint32_t              address   , 
14                           uint32_t              trdid     , 
15                           type_req_cache_t      type      ,
16                           direction_req_cache_t dir    )
17  {
18    if (num_entity >= param->nb_cache_dedicated)
19      {
20        std::cerr << "<Cache.latence> {ERROR} num_entity must be >= nb_cache_dedicated" << std::endl;
21        exit (1);
22      }
23
24    cache_multilevel::Cache_MultiLevel * cache;
25    cache_multilevel::Parameters * param_cache_dedicated;
26    _cout(CACHE," * Access Cache_Dedicated_");
27    if (type_cache == INSTRUCTION_CACHE)
28      {
29        __cout(CACHE,"Instruction");
30        cache                 = icache_dedicated [num_entity];
31        param_cache_dedicated = param->param_icache_dedicated [num_entity];
32      }
33    else
34      {
35        __cout(CACHE,"Data");
36        cache                 = dcache_dedicated [num_entity];
37        param_cache_dedicated = param->param_dcache_dedicated [num_entity];
38      }
39    __cout(CACHE," [%d] - entity : %d, address : 0x%.x\n",num_port,num_entity,address);
40
41    if (num_port >= cache->param->nb_port)
42      {
43        std::cerr << "<Cache.latence> {ERROR} num_port can be >= nb_port" << std::endl;
44        exit (1);
45      }
46
47    // Make a access with this level "dedicated"
48    cache_multilevel::Access access_dedicated = cache->access(num_port,address,trdid,type,dir);
49
50    if (access_dedicated.hit == MISS)
51      {
52        _cout(CACHE," * Access Cache_shared\n");
53
54        // Make a access with this level "shared"
55        cache_multilevel::Access access_shared  = cache_shared->access(range_port (type_cache,num_entity)+num_port,address,trdid,type,dir);
56       
57        cache_shared->update_access (access_shared);
58       
59        access_dedicated.last_nb_level = param_cache_dedicated->nb_level; // Update all cache
60        access_dedicated.latence += access_shared.latence;
61      }
62
63    cache->update_access (access_dedicated);
64
65    _cout(CACHE,"Access latence : %d\n",access_dedicated.latence);
66    return access_dedicated.latence;
67  }
68
69};
70};
Note: See TracBrowser for help on using the repository browser.