-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathintegrate.c
86 lines (64 loc) · 1.97 KB
/
integrate.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#include "sim.h"
#include "cache.h"
//store instructions in data memory
void init_data_memory()
{
}
void input_cfg(FILE * incfg)
{
if(incfg==NULL)
{printf("Error - incfg is NULL\n");exit(-99);}
char ch[1000];
//fscanf(incfg,"# Common config file for MIPs core");
fscanf(incfg,"%s",ch);
fscanf(incfg,"%s",ch);
fscanf(incfg,"%s",ch);
fscanf(incfg,"%s",ch);
fscanf(incfg,"%s",ch);
fscanf(incfg,"%s",ch);
fscanf(incfg,"%s",ch);
fscanf(incfg,"%s",ch);
bool perfect=false;int temp;
if(strcmp(ch,"[perf_model/l1_icache]")==0)
{
cache_split=1;
fscanf(incfg,"perfect =");fscanf(incfg,"%s",ch);
if(strcmp(ch,"false")==0)
{cache_writealloc[0]=1;}
else if(strcmp(ch,"true")==0)
{cache_writealloc[0]=1;}
else
{printf("Wrong input for perfect\n");}
fscanf(incfg,"cache_size =");fscanf(incfg,"%d",cache_isize);
fscanf(incfg,"associativity =");fscanf(incfg,"%d",cache_assoc[0]);
fscanf(incfg,"replacement_policy =");fscanf(incfg,"%s",ch);
fscanf(incfg,"writethrough =");fscanf(incfg,"%d",temp);cache_writeback[0]=1-temp;
fscanf(incfg,"cache_block_size =");fscanf(incfg,"%d",cache_block_size[0]);
}
else if(strcmp(ch,"[perf_model/l1_dcache]")==0)
{
cache_split=1;
fscanf(incfg,"perfect =");fscanf(incfg,"%s",ch);
if(strcmp(ch,"false")==0)
{cache_writealloc[1]=1;}
else if(strcmp(ch,"true")==0)
{cache_writealloc[1]=1;}
fscanf(incfg,"cache_size =");fscanf(incfg,"%d",cache_dsize);
fscanf(incfg,"associativity =");fscanf(incfg,"%d",cache_assoc[1]);
fscanf(incfg,"replacement_policy =");fscanf(incfg,"%s",ch);
fscanf(incfg,"writethrough =");fscanf(incfg,"%d",temp);cache_writeback[1]=1-temp;
fscanf(incfg,"cache_block_size =");fscanf(incfg,"%d",cache_block_size[1]);
}
else if(strcmp(ch,"[perf_model/core]")==0)
{
fscanf(incfg,"frequency =");fscanf(incfg,"%f",fghz);
}
else if(strcmp(ch,"[perf_model/dram]")==0)
{
fscanf(incfg,"latency =");fscanf(incfg,"%d",latency);
}
else
{
printf("Error - unrecognized string %s\n",ch);
}
}