📄 5.htm
字号:
<td width="16%" align="center"><b><font color="#000000" size="4">Branch</font></b></td>
<td width="17%" align="center"><b><font color="#000000" size="4">0</font></b></td>
<td width="17%" align="center"><b><font color="#000000" size="4">0</font></b></td>
<td width="17%" align="center"><b><font color="#000000" size="4">0</font></b></td>
<td width="17%" align="center"><b><font color="#000000" size="4">1</font></b></td>
</tr>
<tr>
<td width="16%" align="center"><b><font color="#000000" size="4">ALUOp1</font></b></td>
<td width="17%" align="center"><b><font color="#000000" size="4">1</font></b></td>
<td width="17%" align="center"><b><font color="#000000" size="4">0</font></b></td>
<td width="17%" align="center"><b><font color="#000000" size="4">0</font></b></td>
<td width="17%" align="center"><b><font color="#000000" size="4">0</font></b></td>
</tr>
<tr>
<td width="16%" align="center"><b><font color="#000000" size="4">ALUOP0</font></b></td>
<td width="17%" align="center"><b><font color="#000000" size="4">0</font></b></td>
<td width="17%" align="center"><b><font color="#000000" size="4">0</font></b></td>
<td width="17%" align="center"><b><font color="#000000" size="4">0</font></b></td>
<td width="17%" align="center"><b><font color="#000000" size="4">1</font></b></td>
</tr>
</table>
<p><font size="4"> <font color="#000000"><b>这样我们可以得到主逻辑控制单元的设计实现</b></font></font></p>
<p><b><font color="#000000" size="4"> 所以我们得到主控制单元的逻辑实现:</font></b></p>
<p><font size="4"><img border="0" src="Image/5-6.gif" width="490" height="475"></font></p>
<p><b><font color="#000000" size="4">现在我们可以化出完整的数据通路图:</font></b></p>
<p><img border="0" src="Image/5-4.gif" width="1000" height="715"></p>
<p><b><font color="#000000">下面我们来看看j指令的实现</font></b></p>
<p><b><font color="#000000">j指令的作用是使程序的流程发生转移,所以就要把转移的地址送到pc中</font></b></p>
<p><b><font color="#000000">j指令的转移地址由以下几部分组成</font></b></p>
<p><b><font color="#000000">1)pc中的高4位</font></b></p>
<p><b><font color="#000000">2)j指令中的26位</font></b></p>
<p><b><font color="#000000">3)最低2位为00</font></b></p>
<p><b><font color="#000000">实现图如下</font></b></p>
<p><font color="#000000"><img border="0" src="Image/5-5.gif" width="800" height="800"></font></p>
<p><b><font color="#000000">四.单周期指令实现的问题</font></b></p>
<p><b><font color="#000000">我们在前面已经提到单周期指令实现存在一些问题,现在我们来具体讨论一下</font></b></p>
<p><b><font color="#000000">由于单周期指令每一条指令的周期为1 所以CPI=1</font></b></p>
<p><b><font color="#000000">Clock cycles perinstruction(CPI) = Average clock cycles / Instruction = 1 / 1 =1</font></b></p>
<p><strong><font color="#000000">这样的设计有两个问题;</font></strong></p>
<p><strong><font color="#000000">1)效率不高</font></strong></p>
<p><strong><font color="#000000">2)违反了提高常用部件性能的原则</font></strong></p>
<p><strong><font color="#000000">为了说明问题,设</font></strong></p>
<p><strong><font color="#000000">1)存储器的读取时间:10ns</font></strong></p>
<p><strong><font color="#000000">2)ALU和加法器:10ns</font></strong></p>
<p><strong><font color="#000000">3)寄存器的读和写:5ns</font></strong></p>
<p><strong><font color="#000000">我们知道,各个指令执行的步骤如下:</font></strong></p>
<table border="1" width="100%" bordercolordark="#CC9966" bordercolorlight="#FFCC66">
<tr>
<td width="16%" align="center"><b><font color="#000000">Instruction type</font></b></td>
<td width="84%" colspan="5" align="center"><b><font color="#000000">Functional unit used by the
instruction types</font></b></td>
</tr>
<tr>
<td width="16%" align="center"><b><font color="#000000">R-format</font></b></td>
<td width="16%" align="center"><b><font color="#000000">Instruction fetch</font></b></td>
<td width="17%" align="center"><b><font color="#000000">Register access</font></b></td>
<td width="17%" align="center"><b><font color="#000000">ALU</font></b></td>
<td width="17%" align="center"><b><font color="#000000">Memory access</font></b></td>
<td width="17%" align="center"><font color="#000000"> </font></td>
</tr>
<tr>
<td width="16%" align="center"><b><font color="#000000">Load word</font></b></td>
<td width="16%" align="center"><b><font color="#000000">Instruction fetch</font></b></td>
<td width="17%" align="center"><b><font color="#000000">Register access</font></b></td>
<td width="17%" align="center"><b><font color="#000000">ALU</font></b></td>
<td width="17%" align="center"><b><font color="#000000">Memory access</font></b></td>
<td width="17%" align="center"><b><font color="#000000">Register access</font></b></td>
</tr>
<tr>
<td width="16%" align="center"><b><font color="#000000">Store word</font></b></td>
<td width="16%" align="center"><b><font color="#000000">Instruction fetch</font></b></td>
<td width="17%" align="center"><b><font color="#000000">Register access</font></b></td>
<td width="17%" align="center"><b><font color="#000000">ALU</font></b></td>
<td width="17%" align="center"><b><font color="#000000">Memory access</font></b></td>
<td width="17%" align="center"><font color="#000000"> </font></td>
</tr>
<tr>
<td width="16%" align="center"><b><font color="#000000">Branch</font></b></td>
<td width="16%" align="center"><b><font color="#000000">Instruction fetch</font></b></td>
<td width="17%" align="center"><b><font color="#000000">Register access</font></b></td>
<td width="17%" align="center"><b><font color="#000000">ALU</font></b></td>
<td width="17%" align="center"><font color="#000000"> </font></td>
<td width="17%" align="center"> </td>
</tr>
<tr>
<td width="16%" align="center"><b><font color="#000000">Jump</font></b></td>
<td width="16%" align="center"><b><font color="#000000">Instruction fetch</font></b></td>
<td width="17%" align="center"><font color="#000000"> </font></td>
<td width="17%" align="center"> </td>
<td width="17%" align="center"> </td>
<td width="17%" align="center"> </td>
</tr>
</table>
<p><b><font color="#000000">所用的时间如下:</font></b></p>
<table border="1" width="100%" bordercolordark="#CC9966" bordercolorlight="#FFCC66">
<tr>
<td width="14%" align="center"><b><font color="#000000">Instruction typpe</font></b></td>
<td width="14%" align="center"><b><font color="#000000">Instruction memory</font></b></td>
<td width="14%" align="center"><b><font color="#000000">Register read</font></b></td>
<td width="14%" align="center"><b><font color="#000000">ALU operation</font></b></td>
<td width="14%" align="center"><b><font color="#000000">Data memory</font></b></td>
<td width="15%" align="center"><b><font color="#000000">Register write</font></b></td>
<td width="15%" align="center"><b><font color="#000000">Totle</font></b></td>
</tr>
<tr>
<td width="14%" align="center"><b><font color="#000000">R-format</font></b></td>
<td width="14%" align="center"><b><font color="#000000">10</font></b></td>
<td width="14%" align="center"><b><font color="#000000">5</font></b></td>
<td width="14%" align="center"><b><font color="#000000">10</font></b></td>
<td width="14%" align="center"><b><font color="#000000">0</font></b></td>
<td width="15%" align="center"><b><font color="#000000">5</font></b></td>
<td width="15%" align="center"><b><font color="#000000">30ns</font></b></td>
</tr>
<tr>
<td width="14%" align="center"><b><font color="#000000">Load word</font></b></td>
<td width="14%" align="center"><b><font color="#000000">10</font></b></td>
<td width="14%" align="center"><b><font color="#000000">5</font></b></td>
<td width="14%" align="center"><b><font color="#000000">10</font></b></td>
<td width="14%" align="center"><b><font color="#000000">10</font></b></td>
<td width="15%" align="center"><b><font color="#000000">5</font></b></td>
<td width="15%" align="center"><b><font color="#000000">40ns</font></b></td>
</tr>
<tr>
<td width="14%" align="center"><b><font color="#000000">Store word</font></b></td>
<td width="14%" align="center"><b><font color="#000000">10</font></b></td>
<td width="14%" align="center"><b><font color="#000000">5</font></b></td>
<td width="14%" align="center"><b><font color="#000000">10</font></b></td>
<td width="14%" align="center"><b><font color="#000000">0</font></b></td>
<td width="15%" align="center"><font color="#000000"> </font></td>
<td width="15%" align="center"><b><font color="#000000">35ns</font></b></td>
</tr>
<tr>
<td width="14%" align="center"><b><font color="#000000">Branch</font></b></td>
<td width="14%" align="center"><b><font color="#000000">10</font></b></td>
<td width="14%" align="center"><b><font color="#000000">5</font></b></td>
<td width="14%" align="center"><b><font color="#000000">10</font></b></td>
<td width="14%" align="center"><b><font color="#000000">10</font></b></td>
<td width="15%" align="center"><font color="#000000"> </font></td>
<td width="15%" align="center"><b><font color="#000000">25ns</font></b></td>
</tr>
<tr>
<td width="14%" align="center"><b><font color="#000000">Jump</font></b></td>
<td width="14%" align="center"><b><font color="#000000">10</font></b></td>
<td width="14%" align="center"><font color="#000000"> </font></td>
<td width="14%" align="center"> </td>
<td width="14%" align="center"> </td>
<td width="15%" align="center"> </td>
<td width="15%" align="center"><b><font color="#000000">10ns</font></b></td>
</tr>
</table>
<p><strong><font color="#000000">比较的条件:</font></strong></p>
<p><strong><font color="#000000">1)单时钟周期,全部的指令执行时间相同</font></strong></p>
<p><strong><font color="#000000">2)每一条指令用一个周期,但长度可变</font></strong></p>
<p><strong><font color="#000000">CPU的执行时间=程序指令数*CPI*时钟周期</font></strong></p>
<p><strong><font color="#000000"> =指令数*时钟周期</font></strong></p>
<p><strong><font color="#000000">令在gcc程序中统计得到</font></strong></p>
<p><strong><font color="#000000"> lw : 22%
sw : 11%
R : 49% Branch
: 16% j : 2%</font></strong></p>
<p><strong><font color="#000000">则变时钟周期平均执行 CPU周期</font></strong></p>
<p><strong><font color="#000000">CPU平均时钟周期 = 40*22%+35*11%+30*49%+25*16%+10*2%= 31.6ns</font></strong></p>
<p><strong><font color="#000000">单时钟周期(以最长的时间算)和变时钟周期的性能比:</font></strong></p>
<p><strong><font color="#000000">40/31.6 = 1.27</font></strong></p>
<p><strong><font color="#000000">但实际上,单时钟周期的设计后果非常的严重,这里的值还可以接受。</font></strong></p>
<p><strong><font color="#000000">对于浮点的运算,同样有这样的计算:</font></strong></p>
<p><strong><font color="#000000">令:浮点加:20ns</font></strong></p>
<p><strong><font color="#000000"> 浮点乘:60ns</font></strong></p>
<p><strong><font color="#000000"> 其他的一样</font></strong></p>
<p><strong><font color="#000000">所以完成浮点乘时间 = 10+5+60+5 = 80ns</font></strong></p>
<p><strong><font color="#000000"> CPU的时钟周期 =
40*26%+35*14%+30*31%+25*8%+10*2%+80*9%+40*10%=38ns</font> </strong></p>
<p><strong><font color="#000000"> 80/38=2.11; 几乎快了两倍</font></strong></p>
<p><strong><font color="#000000">随着机器的功能的增强,有必要采用新的方法。</font></strong></p>
</body>
</html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -