Line 35... |
Line 35... |
#include "sprs.h"
|
#include "sprs.h"
|
#include "sim-config.h"
|
#include "sim-config.h"
|
|
|
/* Data cache */
|
/* Data cache */
|
|
|
extern struct dev_memarea *cur_area;
|
|
struct dc_set {
|
struct dc_set {
|
struct {
|
struct {
|
unsigned long line[MAX_DC_BLOCK_SIZE];
|
unsigned long line[MAX_DC_BLOCK_SIZE];
|
unsigned long tagaddr; /* tag address */
|
unsigned long tagaddr; /* tag address */
|
int lru; /* least recently used */
|
int lru; /* least recently used */
|
Line 75... |
Line 74... |
int i;
|
int i;
|
unsigned long tagaddr;
|
unsigned long tagaddr;
|
extern int mem_cycles;
|
extern int mem_cycles;
|
unsigned long tmp;
|
unsigned long tmp;
|
|
|
if ((!testsprbits(SPR_UPR, SPR_UPR_DCP)) || (!testsprbits(SPR_SR, SPR_SR_DCE))) {
|
if ((!testsprbits(SPR_UPR, SPR_UPR_DCP)) ||
|
|
(!testsprbits(SPR_SR, SPR_SR_DCE)) ||
|
|
data_ci) {
|
if (width == 4)
|
if (width == 4)
|
return evalsim_mem32(dataaddr);
|
return evalsim_mem32(dataaddr);
|
else if (width == 2)
|
else if (width == 2)
|
return (unsigned long)evalsim_mem16(dataaddr);
|
return (unsigned long)evalsim_mem16(dataaddr);
|
else if (width == 1)
|
else if (width == 1)
|
Line 127... |
Line 128... |
minway = i;
|
minway = i;
|
|
|
for (i = 0; i < (config.dc.blocksize); i += 4) {
|
for (i = 0; i < (config.dc.blocksize); i += 4) {
|
dc[set].way[minway].line[((dataaddr + i) & (config.dc.blocksize - 1)) >> 2] =
|
dc[set].way[minway].line[((dataaddr + i) & (config.dc.blocksize - 1)) >> 2] =
|
evalsim_mem32((dataaddr & ~(config.dc.blocksize - 1)) + (((dataaddr & ~3ul)+ i) & (config.dc.blocksize - 1)));
|
evalsim_mem32((dataaddr & ~(config.dc.blocksize - 1)) + (((dataaddr & ~3ul)+ i) & (config.dc.blocksize - 1)));
|
if(!cur_area)
|
if(!cur_area) {
|
|
dc[set].way[minway].tagaddr = -1;
|
|
dc[set].way[minway].lru = 0;
|
return 0;
|
return 0;
|
}
|
}
|
|
}
|
|
|
dc[set].way[minway].tagaddr = tagaddr;
|
dc[set].way[minway].tagaddr = tagaddr;
|
for (i = 0; i < config.dc.nways; i++)
|
for (i = 0; i < config.dc.nways; i++)
|
if (dc[set].way[i].lru)
|
if (dc[set].way[i].lru)
|
dc[set].way[i].lru--;
|
dc[set].way[i].lru--;
|
Line 178... |
Line 182... |
else if (width == 2)
|
else if (width == 2)
|
setsim_mem16(dataaddr, (unsigned short)data);
|
setsim_mem16(dataaddr, (unsigned short)data);
|
else if (width == 1)
|
else if (width == 1)
|
setsim_mem8(dataaddr, (unsigned char)data);
|
setsim_mem8(dataaddr, (unsigned char)data);
|
|
|
if (!cur_area)
|
if ((!testsprbits(SPR_UPR, SPR_UPR_DCP)) ||
|
return;
|
(!testsprbits(SPR_SR, SPR_SR_DCE)) ||
|
|
data_ci ||
|
if ((!testsprbits(SPR_UPR, SPR_UPR_DCP)) || (!testsprbits(SPR_SR, SPR_SR_DCE)))
|
(!cur_area))
|
return;
|
return;
|
|
|
/* Which set to check out? */
|
/* Which set to check out? */
|
set = (dataaddr / config.dc.blocksize) % config.dc.nsets;
|
set = (dataaddr / config.dc.blocksize) % config.dc.nsets;
|
tagaddr = (dataaddr / config.dc.blocksize) / config.dc.nsets;
|
tagaddr = (dataaddr / config.dc.blocksize) / config.dc.nsets;
|
Line 229... |
Line 233... |
minway = i;
|
minway = i;
|
|
|
for (i = 0; i < (config.dc.blocksize); i += 4) {
|
for (i = 0; i < (config.dc.blocksize); i += 4) {
|
dc[set].way[minway].line[((dataaddr + i) & (config.dc.blocksize - 1)) >> 2] =
|
dc[set].way[minway].line[((dataaddr + i) & (config.dc.blocksize - 1)) >> 2] =
|
evalsim_mem32((dataaddr & ~(config.dc.blocksize - 1)) + (((dataaddr & ~3ul)+ i) & (config.dc.blocksize - 1)));
|
evalsim_mem32((dataaddr & ~(config.dc.blocksize - 1)) + (((dataaddr & ~3ul)+ i) & (config.dc.blocksize - 1)));
|
if(!cur_area)
|
if(!cur_area) {
|
|
dc[set].way[minway].tagaddr = -1;
|
|
dc[set].way[minway].lru = 0;
|
return;
|
return;
|
}
|
}
|
|
}
|
|
|
dc[set].way[minway].tagaddr = tagaddr;
|
dc[set].way[minway].tagaddr = tagaddr;
|
for (i = 0; i < config.dc.nways; i++)
|
for (i = 0; i < config.dc.nways; i++)
|
if (dc[set].way[i].lru)
|
if (dc[set].way[i].lru)
|
dc[set].way[i].lru--;
|
dc[set].way[i].lru--;
|