当前位置:网站首页>CPU design practice - Chapter 4 practical task 2 using blocking technology to solve conflicts caused by related problems
CPU design practice - Chapter 4 practical task 2 using blocking technology to solve conflicts caused by related problems
2022-07-05 14:37:00 【Xiaowei programmer】
Use blocking technology to solve the conflict caused by data correlation
Preface
stay lab3 In an experimental environment , add to lab4 Instruction test sequence , Add corresponding code and use blocking technology to solve the conflicts caused by correlation .
experiment
The key point is to control how to generate the conditions for the forward or blocking of decoding pipeline instructions , Its core is to judge whether the existence of instructions in different stages of the pipeline will cause conflicts “ Read after writing ” Correlation .
1. Delivery execution level 、 The destination register number of the memory access level and write back level to the decoding level
At the decoding level, we judge that the current time is at the execution level 、 Whether the register number of the destination operand of the memory access level or write back level instruction is the same as that of the source operand of the decoding level , Therefore, the execution level must be 、 The destination register numbers of the memory access level and the write back level are directly passed to the decoding level . Add the following code at each flow level :
EXE_stage:
output [ 4:0] EXE_dest, // The operand register number of the execution level
assign EXE_dest = es_dest & {
5{
es_valid}}; // It is suggested to add at the end , The same below
MEM_stage:
output [ 4:0] MEM_dest // Access level operand register number
assign MEM_dest = ms_dest & {
5{
ms_valid}};
WB_stage:
output [ 4:0] WB_dest // Write back the operand register number of the stage
assign WB_dest = ws_dest & {
5{
ws_valid}};
ID_stage:
input [ 4:0] EXE_dest, // The operand register number of the execution level
input [ 4:0] MEM_dest, // Access level operand register number
input [ 4:0] WB_dest, // Write back the operand register number of the stage
And in mycpu_top Add the corresponding signal to the instantiation of the corresponding module :
// Instantiate the line declaration used , I forgot this part when I changed it for the first time …………
wire [4:0] EXE_dest;
wire [4:0] MEM_dest;
wire [4:0] WB_dest;
//wire es_load_op;
ID_stage:
// Addition of instantiation port
.EXE_dest (EXE_dest),
.MEM_dest (MEM_dest),
.WB_dest (WB_dest),
//.es_load_op (es_load_op) // Next, add
EXE_stage:
// Addition of instantiation port
.EXE_dest (EXE_dest),
//.es_load_op (es_load_op)
MEM_stage:
// Addition of instantiation port
.MEM_dest (MEM_dest)
WB_stage:
// Addition of instantiation port
.WB_dest (WB_dest)
2. Determine whether data correlation is generated
At the decoding level, we get that the current time is at the execution level 、 After the register number of the destination operand of the instructions of the memory access level and the write back level , Next, we need to generate corresponding logic to judge whether to generate data correlation , After generating data correlation , Pause pipeline . The codes added and modified at the decoding level are as follows :
/* The data is incremented / Modify the code */
// increase -begin
wire src1_no_rs; // Instructions rs Domain non 0, And not read from the register heap rs The data of
wire src2_no_rt; // Instructions rt Domain non 0, And not read from the register heap rt The data of
assign src1_no_rs = 1'b0;
assign src2_no_rt = inst_addiu | load_op | inst_jal | inst_lui;
wire rs_wait; // With the source operand rs The corresponding register numbers are consistent
wire rt_wait; // With the source operand rt The corresponding register numbers are consistent
assign rs_wait = ~src1_no_rs & (rs!=5'd0)
& ( (rs==EXE_dest) | (rs==MEM_dest) | (rs==WB_dest) );
assign rt_wait = ~src2_no_rt & (rt!=5'd0)
& ( (rt==EXE_dest) | (rt==MEM_dest) | (rt==WB_dest) );
wire inst_no_dest; // The tag instruction has no register number
assign inst_no_dest = inst_beq | inst_bne | inst_jr | inst_sw;
// increase -end
// modify -begin
assign dest = dst_is_r31 ? 5'd31 :
dst_is_rt ? rt :
inst_no_dest ? 5'd0 : rd;
assign ds_ready_go = ds_valid & ~rs_wait & ~rt_wait;
// modify -end
/*---------------*/
3. Transfer calculation not completed
There is another case to consider , That is, the transfer calculation is not completed . That is, when the transfer instruction is at the decoding level ,Load Instructions cannot be obtained at the execution level Load result , Therefore, the transfer instruction cannot calculate the correct jump target . At this time, according to the requirements of the textbook , Add and modify the corresponding code , as follows :
IF_stage:
wire pre_fs_ready_go; // increase
wire br_stall; // increase
assign to_fs_valid = ~reset && pre_fs_ready_go;// modify
assign pre_fs_ready_go = ~br_stall; // increase
assign {
br_stall,br_taken,br_target} = br_bus; // modify
assign inst_sram_en = to_fs_valid && fs_allowin && ~br_stall; // modify
ID_stage:
input es_load_op // Indicates that the current execution level is load Instructions
wire br_stall; // increase
wire load_stall;
assign br_stall = br_taken & load_stall & {
5{
ds_valid}}; // increase
assign load_stall = (rs_wait & (rs == EXE_dest) & es_load_op ) ||
(rt_wait & (rt == EXE_dest) & es_load_op );
assign br_bus = {
br_stall,br_taken,br_target}; // modify
EXE_stage:
output es_load_op // Indicates that the execution level is load Instructions
mycpu.h:
`define BR_BUS_WD 34 // modify
stay mycpu_top Add the corresponding signal to the instantiation of the corresponding module :
// Instantiate the line declaration used
wire es_load_op;
ID_stage:
// Addition of instantiation port
.es_load_op (es_load_op)
EXE_stage:
// Addition of instantiation port
.es_load_op (es_load_op)
experimental result
Simulation results :
launch_simulation: Time (s): cpu = 00:00:09 ; elapsed = 00:00:15 . Memory (MB): peak = 945.371 ; gain = 91.242
Tested :
----PASS!!!
run: Time (s): cpu = 00:00:20 ; elapsed = 00:00:16 . Memory (MB): peak = 945.371 ; gain = 0.000
边栏推荐
- The speed monitoring chip based on Bernoulli principle can be used for natural gas pipeline leakage detection
- 黑马程序员-软件测试-10阶段2-linux和数据库-44-57为什么学习数据库,数据库分类关系型数据库的说明Navicat操作数据的说明,Navicat操作数据库连接说明,Navicat的基本使用,
- 外盘入金都不是对公转吗,那怎么保障安全?
- 动态规划
- PostgreSQL 13 installation
- Matrix chain multiplication dynamic programming example
- Section - left closed right open
- 03_ Dataimport of Solr
- MongDB学习笔记
- There is a powerful and good-looking language bird editor, which is better than typora and developed by Alibaba
猜你喜欢
直播预告|如何借助自动化工具落地DevOps(文末福利)
How does redis implement multiple zones?
[learning notes] stage test 1
SaaS multi tenant solution for FMCG industry to build digital marketing competitiveness of the whole industry chain
面试突击62:group by 有哪些注意事项?
How to protect user privacy without password authentication?
CYCA少儿形体礼仪 宁波市培训成果考核圆满落幕
How can non-technical departments participate in Devops?
如何将电脑复制的内容粘贴进MobaXterm?如何复制粘贴
浅谈Dataset和Dataloader在加载数据时如何调用到__getitem__()函数
随机推荐
申请代码签名证书时如何选择合适的证书品牌?
[C question set] of Ⅷ
useMemo,memo,useRef等相关hooks详解
2022年国内正规的期货公司平台有哪些啊?方正中期怎么样?安全可靠吗?
快消品行业SaaS多租户解决方案,构建全产业链数字化营销竞争力
freesurfer运行完recon-all怎么快速查看有没有报错?——核心命令tail重定向
启牛证券账户怎么开通,开户安全吗?
Niuke: intercepting missiles
【华为机试真题详解】字符统计及重排
mysql8.0JSON_ Instructions for using contains
浅谈Dataset和Dataloader在加载数据时如何调用到__getitem__()函数
分享 20 个稀奇古怪的 JS 表达式,看看你能答对多少
直播预告|如何借助自动化工具落地DevOps(文末福利)
SSL证书错误怎么办?浏览器常见SSL证书报错解决办法
Principle and performance analysis of lepton lossless compression
[learning notes] stage test 1
Thymeleaf 常用函数
3W principle [easy to understand]
js亮瞎你眼的日期选择器
ASP.NET大型外卖订餐系统源码 (PC版+手机版+商户版)