当前位置:网站首页>CPU design practice - Chapter 4 practical tasks - simple CPU reference design and debugging
CPU design practice - Chapter 4 practical tasks - simple CPU reference design and debugging
2022-07-01 08:13:00 【서리가 가장 아름답다.】
Simple CPU Refer to the design and commissioning DeBug—MyCPU part
Make a note of it :
Run All Options are only available after entering the simulation page , And the process of its operation is prompted in the lower right corner .
1. Signal transmission Bug

Add five paragraphs respectively PC The signal value is not difficult to find ,IF_PC => ID_PC Fail to pass EXE_PC, That is, the execution stage does not receive the... From the decoding stage PC value . The inspection found that :
if Send the data to id, however id_stage There is no fs_to_ds_bus_r <= fs_to_ds_bus. Go to id modular , Find out ds_valid Not assigned .
Before the change :
After modification :
always @(posedge clk) begin // Bug 1
if(reset) begin
ds_valid <= 1'b0;
end
else if(ds_allowin) begin
ds_valid <= fs_to_ds_valid;
end
if (fs_to_ds_valid && ds_allowin) begin
fs_to_ds_bus_r <= fs_to_ds_bus;
end
end
2. A typical "Z" The signal Bug

This situation is often caused by the fact that variables are not assigned values . find id_stage Module discovery :
load_op There is no relevant assignment statement . Add it at the right place :
load_op It means load Of operate Part this part should be related to lw Instructions are connected .
Simulation Bug episode
Complete the above logic Bug, Re simulate , The following episode appears :
Most of this prompt is due to the wrong typing of some variables when typing the code , So don't panic . Click on ok You can view the file path where the problem is accurately located :
Open it in Notepad and you can see the precise error location .
my Bug It is positioned as :ID.stage Of the 128 Line and line three

Use new tools - be based on Trace Debugging of comparison
3.Addiu The instruction instance passes parameters Bug
Run All Then the first trace Comparison error , The comparison error message prompt comes from the following related codes :
It can be seen that the relevant information of the comparison is :PC value 、 Write back destination register 、 Destination data written back 
analysis :PC The value is 0x bfc00000, Which instruction does it represent ?
stay lab3\CPU_CDE\soft\func_lab3\obj\test.s Mid search bfc00000 You can see the corresponding instruction :
by 0x2408 ffff Its corresponding instruction 001001 00000 01000 1111111111111111
Look up the table , The corresponding instruction format is addiu Instructions , And the error position is on the written data , So we need to check alu Module and EXE_stage modular , Find out :
EXE_stage Module parameter instantiation error 
Change to :
alu u_alu(
.alu_op (es_alu_op ),
.alu_src1 (es_alu_src1 ),
.alu_src2 (es_alu_src2 ),
.alu_result (es_alu_result)
);
4.Bug

You can see PC Something went wrong , It must be looking for branch instructions or jump instructions , Let's take a look at some instructions nearby (test.s file ).
/media/sf_func_lab3/start.S:19
bfc00004: 2408ffff li t0,-1
/media/sf_func_lab3/start.S:20
bfc00008: 100000e0 b bfc0038c <locate>
/media/sf_func_lab3/start.S:21
bfc0000c: 00000000 nop
/media/sf_func_lab3/start.S:24
bfc00010: 3c088000 lui t0,0x8000
/media/sf_func_lab3/start.S:25
bfc00014: 25290001 addiu t1,t1,1
It is obvious that bfc00008 This instruction is a branch instruction , and mycpu No jump .
First of all, let's explain nop Instructions , It is kind to set the delay slot instruction to nop, Same as above ,nop Instructions do not need to be specifically implemented .
The control flow first flows into the prefetch stage , Then prefetching refers to phase update PC And visit RAM Get instruction ,PC and RAM Finally, it flows into the decoding stage at the same time , In the decoding stage, the prefetching stage is controlled by combinatorial logic to complete the jump .
We Expected execution sequence 
You can see , In our expectation , The pre judgment of branch instruction is completed by the decoding stage .
This article B Instructions from r0 Constant for the 0 and BEQ Command to get .
We can find that in this delay slot instruction , It should have been assign br_bus = {br_taken,br_target};, But the two signals at the bottom are the same , So you can find the problem .
The problem occurred in the file path :\lab3\CPU_CDE\mycpu_verify\rtl\myCPU\mycpu.h
Change the bit width :
`define BR_BUS_WD 33
5.Bug
Global error 
This mistake is still alu modular ( Before and after bit width mismatch assignment ):
change :
assign sr_result = sr64_result[31:0];
6.Bug

This situation is caused by RTL There is a combined circuit in the code , Hard to find , If you happen to see this line , Its mistakes are still obvious .
alu.v Module error :
change :
assign or_result = alu_src1 | alu_src2;
PC-Bug episode
After solving the above problems in turn , Re run and find this phenomenon ...
Observation found that : Every time an error is reported, it is written back to the level PC And trace.txt atypism , But the destination register number and data are correct . What causes it ?
7. the last one Bug
Bad file path :mycpu_verify => rtl => myCPU => tools.v
If you are more careful, you will find decoder_6_64 The decoding of the module is not enough 64 position , That is, only 【62:0】, So it should be changed to :
generate for (i=0; i<64; i=i+1) begin:gen_for_dec_6_64 //Bug 7
Successful board video presentation :
It is recommended to turn on all dialing switches during board test , At this time, the counting speed is the slowest , It is convenient to observe experimental phenomena . Then you can dial oneortwo , Moderate speed .
Video link : Simple CPU Design reference practice task
Reference resources :
Learn from relevant blog links :CPU Design practice lab3
边栏推荐
- LSTM of RNN
- Office365 - how to use stream app to watch offline files at any time
- 软键盘高度报错
- Li Kou daily question - Day 32 -1822 Symbol of array element product
- How to prevent the other party from saying that he has no money after winning the lawsuit?
- Adding color blocks to Seaborn clustermap matrix
- ContentType所有类型对比
- OJ输入输出练习
- On several key issues of digital transformation
- SharePoint - modify web application authentication using PowerShell
猜你喜欢

Vhost kick & call principle

使用 setoolkit 伪造站点窃取用户信息

Microsoft stream - how to modify video subtitles

P4 installation bmv2 detailed tutorial

PostgreSQL source code learning (26) -- windows vscode remote debugging PostgreSQL on Linux

Gui Gui programming (XV) - use scale to control font size changes
![[kv260] generate chip temperature curve with xadc](/img/fc/e5e4648b09b1123b2d494b75a9f8f7.png)
[kv260] generate chip temperature curve with xadc
![[untitled]](/img/d9/5e97f2de256b9749131b5bf1437d24.png)
[untitled]

window c盘满了

【入门】输入整型数组和排序标识,对其元素按照升序或降序进行排序
随机推荐
Programmer's regimen
[getting started] extract non repeating integers
Anddroid text to speech TTS implementation
Utiliser Beef pour détourner le navigateur utilisateur
[introduction] approximate value
SQL number injection and character injection
初学者如何正确理解google官方建议架构原则(疑问?)
Implementation and encapsulation of go universal dynamic retry mechanism
力扣每日一题-第32天-1822.数组元素积的符号
Chinese font Gan: zi2zi
[website architecture] solve 90% of distributed transactions in one move, and introduce the working principles and application scenarios of database transactions and distributed transactions
【入门】提取不重复的整数
Precautions and skills in using regular expressions in golang
038 network security JS
Gdip - hatchbrush pattern table
Gru of RNN
getInputStream() has already been called for this request
Access report realizes subtotal function
On June 30, 2022, the record of provincial competition + national competition of Bluebridge
php laravel微信支付