当前位置:网站首页>CPU设计实战-第四章实践任务三用前递技术解决相关引发的冲突
CPU设计实战-第四章实践任务三用前递技术解决相关引发的冲突
2022-07-05 14:31:00 【小威程序员】
用前递技术解决数据相关引发的冲突
前言
实践任务三是在实践任务二的基础上进行修改的!!!
在lab4的实验环境下,增加相应代码用前递技术解决相关引发的冲突,最后使得仿真时间相比实践任务二更少。
实验
1.添加将执行级、访存级或者写回级的数据前递到译码级的数据通路
在译码级判断当前时刻处于执行级、访存级或者写回级的指令的目的操作数的寄存器号是否与译码级源操作数的寄存器号是否相同后,表示已经发生了数据相关,需要将执行级、访存级或者写回级的数据前递到译码级。代码如下:
EXE_stage:
output [31:0] EXE_result, //执行级
assign EXE_result = es_alu_result;
MEM_stage:
output [31:0] MEM_result
assign MEM_result = ms_final_result;
WB_stage:
output [31:0] WB_result
assign WB_result = ws_final_result;
ID_stage:
input [31:0] EXE_result,
input [31:0] MEM_result,
input [31:0] WB_result,
在mycpu_top相应模块的实例化中添加对应的信号:
//实例化所用线路声明
wire [31:0] EXE_result;
wire [31:0] MEM_result;
wire [31:0] WB_result;
ID_stage:
.EXE_result (EXE_result),
.MEM_result (MEM_result),
.WB_result (WB_result)
EXE_stage:
.EXE_result (EXE_result)
MEM_stage:
.MEM_result (MEM_result)
WB_stage:
.WB_result (WB_result)
2.判断需要前递的是执行级、访存级还是写回级的数据
我们在译码级得到了当前时刻处于执行级、访存级和写回级的指令需要最终写回到寄存器的目的操作数后,接下来就要产生相应的逻辑来判断需要前递的是执行级、访存级还是写回级的数据。在译码级修改的代码如下:
//删除
/* assign rs_value = rf_rdata1; assign rt_value = rf_rdata2; */
//添加-begin
assign rs_value = rs_wait ? (rs == EXE_dest ? EXE_result :
rs == MEM_dest ? MEM_result : WB_result)
: rf_rdata1;
assign rt_value = rt_wait ? (rt == EXE_dest ? EXE_result :
rt == MEM_dest ? MEM_result : WB_result)
: rf_rdata2;
assign ds_ready_go = ds_valid & ~load_stall;
//load_stall在实践任务二就已经添加,表示第i条指令是load指令,第i+1条指令
//和load指令发生数据相关,此时需要前递的数据还未准备好,需要流水线暂停。
//添加-end
实验结果
仿真结果:
launch_simulation: Time (s): cpu = 00:00:05 ; elapsed = 00:00:12 . Memory (MB): peak = 958.809 ; gain = 0.000
过测试:
----PASS!!!
run: Time (s): cpu = 00:00:18 ; elapsed = 00:00:16 . Memory (MB): peak = 958.809 ; gain = 0.000
边栏推荐
- What about SSL certificate errors? Solutions to common SSL certificate errors in browsers
- LeetCode_ 2 (add two numbers)
- SaaS multi tenant solution for FMCG industry to build digital marketing competitiveness of the whole industry chain
- Penetration testing methodology
- 01. Solr7.3.1 deployment and configuration of jetty under win10 platform
- 开挖财上的证券账户可以吗?安全吗?
- 【招聘岗位】基础设施软件开发人员
- CyCa children's physical etiquette Ningbo training results assessment came to a successful conclusion
- Thymeleaf th:with use of local variables
- 快消品行业SaaS多租户解决方案,构建全产业链数字化营销竞争力
猜你喜欢
家用电器行业商业供应链协同平台解决方案:供应链系统管理精益化,助推企业智造升级
Thymeleaf th:classappend属性追加 th:styleappend样式追加 th:data-自定义属性
分享 20 个稀奇古怪的 JS 表达式,看看你能答对多少
Share 20 strange JS expressions and see how many correct answers you can get
CyCa children's physical etiquette Ningbo training results assessment came to a successful conclusion
Niuke: intercepting missiles
Chow Tai Fook fulfills the "centenary commitment" and sincerely serves to promote green environmental protection
LeetCode_ 2 (add two numbers)
Sharing the 12 most commonly used regular expressions can solve most of your problems
Online electronic component purchasing Mall: break the problem of information asymmetry in the purchasing process, and enable enterprises to effectively coordinate management
随机推荐
Thymeleaf 使用后台自定义工具类处理文本
有一个强大又好看的,赛过Typora,阿里开发的语雀编辑器
Disjoint Set
webRTC SDP mslabel lable
一网打尽异步神器CompletableFuture
R language ggplot2 visual bar graph: visualize the bar graph through the two-color gradient color theme, and add label text for each bar (geom_text function)
The speed monitoring chip based on Bernoulli principle can be used for natural gas pipeline leakage detection
2022年国内正规的期货公司平台有哪些啊?方正中期怎么样?安全可靠吗?
R language uses the polR function of mass package to build an ordered multi classification logistic regression model, and uses the coef function to obtain the log odds ratio corresponding to each vari
How to make a second clip of our media video without infringement
Is the securities account given by the head teacher of qiniu school safe? Can I open an account?
Pointer operation - C language
R language ggplot2 visualization: visual line graph, using legend in theme function The position parameter defines the position of the legend
Don't be unconvinced. Mobile phone function upgrade is strong
After the microservice project is deployed, static resources and files uploaded to upload cannot be accessed. Solution
03_ Dataimport of Solr
黑马程序员-软件测试-10阶段2-linux和数据库-44-57为什么学习数据库,数据库分类关系型数据库的说明Navicat操作数据的说明,Navicat操作数据库连接说明,Navicat的基本使用,
分享 20 个稀奇古怪的 JS 表达式,看看你能答对多少
Longest common subsequence dynamic programming
R语言dplyr包select函数、group_by函数、mutate函数、cumsum函数计算dataframe分组数据中指定数值变量的累加值、并生成累加数据列