当前位置:网站首页>[C language programming 7] BTB model
[C language programming 7] BTB model
2022-07-19 12:45:00 【Xiaoyao】
Depth is 4、16、32、64 Of BTB Model
BTB The model is as follows , Use N To represent depth . When the command is in BTB Match the corresponding PC When it's worth it , Count it as a hit .
The specific implementation can be seen in the source code , Comments for further details are also placed in the source code .
/*BTB The simulation model of */
#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;// This section reads the file
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])// Match to PC
{
hit++;
break;
}
if(j == max && max < N)// When it is not matched and the depth is not full , add to
{
hy_i[j] = instr;
max++;
}
else if(j == N)// Not matched and the depth is full , to update
{
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;
}
边栏推荐
- When will the deflationary market reverse? How should we operate? 2020-03-13
- Acwing786. The kth number
- Create a custom palette in swiftui color tutorial
- 第一天实验
- 查看mysql数据表结构的两种方法你会吗?
- ros(26):ros::Time::now(),ros::Duration,toSec(),toNSec(); Calculate program execution time
- Impulse function, step function, ramp function and impulse response
- Detailed explanation of RAID disk array, raid classification, advantages and disadvantages
- 超声波传感器(CH101&ch201) - Ⅰ
- hcip第四天笔记
猜你喜欢

About the "bottom reading" mentality, it makes you exhausted 2020-03-15

收益风险比:投资机会最重要指标 2020-03-14

机器学习作业1
MIHA tour 2023 autumn recruitment officially begins ~ early approval has the opportunity to avoid written examination!

Notes on the fifth day

How to invest scientifically and rationally when the global financial crisis strikes? 2020-03-17

Dynamic memory planning

第五天笔记

ros(26):ros::Time::now(),ros::Duration,toSec(),toNSec();计算程序执行时间

基于STM32设计的云端健康管理系统(采用阿里云物联网平台)
随机推荐
超声波传感器(CH101&ch201) - Ⅱ
Growth of operation and maintenance Xiaobai - week 6 of Architecture
運維小白成長記—架構第6周
标签球问题
String correlation function (II)
LeetCode_前缀和_中等_523.连续的子数组和
Committer identity unknown *** Please tell me who you are...
三分钟了解mysql中主键、外键、非空、唯一、默认约束是什么,以及如何创建表
Summary of ultrasonic sensor series articles
Brief analysis of circuit fault
hcip第四天笔记
Acwing4405. Statistical submatrix
基于STM32设计的云端健康管理系统(采用阿里云物联网平台)
Day 4 homework
机器学习作业1
Lazy to the bone, I am too lazy to write articles in CSDN. I write articles based on selenium simulation
Editing skills
Ultrasonic sensor (chx01) learning notes Ⅲ - I2C reading and writing operation
Talk about the redis cache penetration scenario and the corresponding solutions
Experiment the next day