当前位置:网站首页>【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;
}
边栏推荐
- js链式调用sleep函数 ------- <秋招打卡篇二>
- MapGIS IGServer九州-驾驭国产化环境下的拓展服务开发
- Research on downlink spectrum efficiency of 6G space earth integrated network high altitude platform base station
- Property analysis of rotate matrix (forwarding)
- LeetCode_216_组合总和Ⅲ
- Mysql5.6 alter statement
- Bet Net is a good thing
- windows10:vscode下go语言的适配
- Wi Fi sensing technology and practice based on channel state information
- [untitled] CV learning 1 conversion
猜你喜欢

Nature | the carbon sequestration rate of groundwater is similar to that of oligotrophic marine system

es安装ik分词器

Redis distributed cache redis cluster

How to build dashboard and knowledge base in double chain note taking software? Take the embedded widget library notionpet as an example

Project construction depends on people, and success depends on people!

The concept of binary tree and three traversal methods (C language)

Valid bracket sequence of "Niuke | daily question"

Kunlunbase online meetup is waiting for you~

mysql学习笔记-约束

QT -- excellent open source project
随机推荐
Conversion between Swift binary data and hexadecimal string
C# .NET 云南农信国密签名(SM2)简要解析
微机原理与技术接口 实验五 基本IO操作温度控制实验
渐变色按钮功能按钮绘制C语言示例
Send blocking, receive blocking
[embedded unit test] construction of C language unit test framework
Tikv memory parameter performance tuning
Kernel mode and user mode
How to build dashboard and knowledge base in double chain note taking software? Take the embedded widget library notionpet as an example
Two misunderstandings of digital transformation
C语言绘图示例-繁花图案
C # build a system based on WPF entry project of net5
zabbix-snmp监控
使用原生js实现按钮的全选功能,简单清晰
HCIP(4)
Region performance tuning
HCIP(8)
Wi Fi sensing technology and practice based on channel state information
C language drawing example - palette
Redis分布式缓存-Redis集群