[78] | 1 | #include "../include/Cache.h" |
---|
[144] | 2 | #include <stdio.h> |
---|
[78] | 3 | |
---|
[80] | 4 | namespace environment { |
---|
[78] | 5 | namespace 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; |
---|
[81] | 25 | cache_multilevel::Parameters * param_cache_dedicated; |
---|
| 26 | _cout(CACHE," * Access Cache_Dedicated_"); |
---|
[78] | 27 | if (type_cache == INSTRUCTION_CACHE) |
---|
[81] | 28 | { |
---|
[117] | 29 | __cout(CACHE,"Instruction"); |
---|
[81] | 30 | cache = icache_dedicated [num_entity]; |
---|
| 31 | param_cache_dedicated = param->param_icache_dedicated [num_entity]; |
---|
| 32 | } |
---|
[78] | 33 | else |
---|
[81] | 34 | { |
---|
[117] | 35 | __cout(CACHE,"Data"); |
---|
[81] | 36 | cache = dcache_dedicated [num_entity]; |
---|
| 37 | param_cache_dedicated = param->param_dcache_dedicated [num_entity]; |
---|
| 38 | } |
---|
[117] | 39 | __cout(CACHE," [%d] - entity : %d, address : 0x%.x\n",num_port,num_entity,address); |
---|
[78] | 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 | { |
---|
[117] | 52 | _cout(CACHE," * Access Cache_shared\n"); |
---|
[81] | 53 | |
---|
[78] | 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 | |
---|
[81] | 59 | access_dedicated.last_nb_level = param_cache_dedicated->nb_level; // Update all cache |
---|
[78] | 60 | access_dedicated.latence += access_shared.latence; |
---|
| 61 | } |
---|
| 62 | |
---|
| 63 | cache->update_access (access_dedicated); |
---|
| 64 | |
---|
[81] | 65 | _cout(CACHE,"Access latence : %d\n",access_dedicated.latence); |
---|
[78] | 66 | return access_dedicated.latence; |
---|
| 67 | } |
---|
| 68 | |
---|
| 69 | }; |
---|
| 70 | }; |
---|