当前位置:网站首页>【C语言编程7】BTB模型
【C语言编程7】BTB模型
2022-07-17 15:52:00 【逍遥xiaoy】
深度为4、16、32、64的BTB模型
BTB的模型如下,使用N来表示深度。当指令在BTB中匹配到相应的PC值的时候,就计为一次命中。
具体的实现可见源代码,进一步细节的注释也放在源代码中。
/*BTB的仿真模型*/
#include<stdio.h>
#define N 4
int main()
{
int hy_i[N], instr, addr, taken;
int i = 0, j, max = 0, ic = 0, hit = 0;
FILE *fin;//此部分读取文件
fin = fopen("history.txt", "r");
if(fin == NULL)
{
printf ("Failed to open the file !\n");
return 0;
}
while(!feof(fin))
{
fscanf(fin, "%x%x%d", &instr, &addr, &taken);
for(j = 0;j < max;j++)
if(instr == hy_i[j])//匹配到PC
{
hit++;
break;
}
if(j == max && max < N)//未匹配到且深度未满时,添加
{
hy_i[j] = instr;
max++;
}
else if(j == N)//未匹配到且深度已满,更新
{
hy_i[i % N] = instr;
i++;
}
ic++;
}
printf("N = %d, ic = %d, hit = %d, hit/ic = %f\n", N, ic, hit, float(hit) / float(ic));
fclose(fin);
return 0;
}
边栏推荐
- TiKV 线程池性能调优
- 数字化转型的两种误区
- 3.Golang字符串string类型
- Dual machine hot standby of Huawei firewall (NGFW)
- Developing those things: how to solve the problem of long-time encoding and decoding of RK chip video processing?
- mysql学习笔记-约束
- Tiflash performance tuning
- STL string 输入输出重载1
- 微机原理与技术接口 实验五 基本IO操作温度控制实验
- [untitled] CV learning 1 conversion
猜你喜欢

windows10:vscode下go语言的适配

C语言绘图示例-分色调图20例

如何应用小程序容器技术开发Hybrid App

Opencv draw a black rectangle and write the serial number

Lychee sound quality high fidelity AI noise reduction technology sharing

TCP congestion control details | 7 Surpass TCP

HCIP(4)

解决:code ERESOLVE:ERESOLVE could not resolve 的报错问题

人大、微软等提出InclusiveFL:异构设备上的包容性联邦学习

Application of semi supervised learning in malware traffic detection
随机推荐
Tidb memory control document
Lychee sound quality high fidelity AI noise reduction technology sharing
PPPoE拨号上网
Application of semi supervised learning in malware traffic detection
Three. JS basic element usage
LeetCode_ 17_ Letter combination of telephone number
zabbix-snmp监控
Huawei firewall authentication technology
Overview of the application of air, space and sea Association
[MySQL] add, delete, check and modify MySQL (Advanced)
Flink
Genesis与BlueRun Ventures展开深度交流
解决:code ERESOLVE:ERESOLVE could not resolve 的报错问题
TCP congestion control details | 7 Surpass TCP
Tikv memory parameter performance tuning
LeetCode_216_组合总和Ⅲ
QT -- excellent open source project
Energy saving resource allocation strategy based on time-varying graph in satellite networks
02 - 3. Différences entre les pointeurs et les références
High performance IO framework library libevent (III): overview of libevent framework functions