<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/">
  <channel>
    <title>Computation Strcuture on MT&#39;s blog</title>
    <link>https://rmtt.github.io/zh/categories/computation-strcuture/</link>
    <description>Recent content in Computation Strcuture on MT&#39;s blog</description>
    <generator>Hugo</generator>
    <language>zh</language>
    <lastBuildDate>Wed, 24 Nov 2021 00:00:00 +0000</lastBuildDate>
    <atom:link href="https://rmtt.github.io/zh/categories/computation-strcuture/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>Designing an instruction set</title>
      <link>https://rmtt.github.io/zh/posts/computation-structure/computation-structure-09/</link>
      <pubDate>Wed, 24 Nov 2021 00:00:00 +0000</pubDate>
      <guid>https://rmtt.github.io/zh/posts/computation-structure/computation-structure-09/</guid>
      <description>&lt;h1 id=&#34;designing-an-instruction-set&#34;&gt;Designing an instruction set&lt;/h1&gt;
&lt;blockquote&gt;
&lt;p&gt;课程地址: &lt;a href=&#34;https://ocw.mit.edu/courses/electrical-engineering-and-computer-science/6-004-computation-structures-spring-2017/c9/c9s1/&#34;&gt;https://ocw.mit.edu/courses/electrical-engineering-and-computer-science/6-004-computation-structures-spring-2017/c9/c9s1/&lt;/a&gt;&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;本章用前8章所学的知识设计了一个简单的通用计算机，采用冯诺伊曼结构，即&lt;em&gt;main memory&lt;/em&gt; + &lt;em&gt;CPU&lt;/em&gt;，而CPU则主要由&lt;em&gt;datapath&lt;/em&gt;(即以ALU为主的计算电路)和&lt;em&gt;control logic&lt;/em&gt;(即用ROM和Register实现的FSM控制电路)。整体内容很简单，但是很好玩！&lt;/p&gt;
&lt;h2 id=&#34;datapaths-and-fsms&#34;&gt;Datapaths and FSMs&lt;/h2&gt;
&lt;p&gt;Let’s start by designing the logic that implements the desired computations — we call this part of the logic the “&lt;em&gt;datapath&lt;/em&gt;”.&lt;/p&gt;
&lt;p&gt;&lt;img loading=&#34;lazy&#34; src=&#34;https://blog-img.rmtt.fun/posts/computation-structure-09/datapath-for-factorial.png&#34;&gt;&lt;/p&gt;
&lt;p&gt;上图虽然实现了a和b的计算，但还不能控制其状态，即不能在b为0时结束循环，所以需要一个FSM来控制整个计算电路即datapath的状态。&lt;/p&gt;
&lt;p&gt;&lt;img loading=&#34;lazy&#34; src=&#34;https://blog-img.rmtt.fun/posts/computation-structure-09/control-fsm-for-factorial.png&#34;&gt;&lt;/p&gt;
&lt;p&gt;&lt;img loading=&#34;lazy&#34; src=&#34;https://blog-img.rmtt.fun/posts/computation-structure-09/control-fsm-hardware.png&#34;&gt;&lt;/p&gt;
&lt;h2 id=&#34;programmable-datapath&#34;&gt;Programmable Datapath&lt;/h2&gt;
&lt;p&gt;第一节中设计了一个可以计算介乘的datapath, 然后配上一个简单的FSM, 就可以完成计算任务。但实际中的计算任务有成千上万种，我们不能为每种任务都设计一个单独的datapath。&lt;/p&gt;
&lt;p&gt;首先每种计算都可以分解为ALU的几个基本计算类型(Arithmetic, Bool, Comparable, Shift)，所以就计算来说，一个ALU就差不多够用了。但有的任务可能需要更多的寄存器来保存中间结果，所以增加寄存器数量是必须的。如下是一个简单的可以进行通用计算的datapath.&lt;/p&gt;
&lt;p&gt;&lt;img loading=&#34;lazy&#34; src=&#34;https://blog-img.rmtt.fun/posts/computation-structure-09/a-simple-programmable-datapath.png&#34;&gt;&lt;/p&gt;
&lt;p&gt;&lt;img loading=&#34;lazy&#34; src=&#34;https://blog-img.rmtt.fun/posts/computation-structure-09/a-control-fsm-for-factorial.png&#34;&gt;&lt;/p&gt;
&lt;h2 id=&#34;the-von-neumann-model&#34;&gt;The von Neumann Model&lt;/h2&gt;
&lt;p&gt;在上一节的模型的基础上，冯诺伊曼引入了主存和输入/输出设备，从而执行数据量更大的计算任务，而且也可以有各种各样的输入输出设备，如下图所示。&lt;/p&gt;
&lt;p&gt;&lt;img loading=&#34;lazy&#34; src=&#34;https://blog-img.rmtt.fun/posts/computation-structure-09/the-von-neumann-model.png&#34;&gt;&lt;/p&gt;
&lt;h2 id=&#34;storage&#34;&gt;Storage&lt;/h2&gt;
&lt;p&gt;冯诺伊曼模型的要点是用主存来存储指令和数据，主存相对于寄存器来说，最主要的优点就是容量大，所以能存储很多条指令。假如一条指令是32位也就是4bytes的话，那么1KB就能存256条指令，1M就能存256000条！&lt;/p&gt;
&lt;p&gt;&lt;img loading=&#34;lazy&#34; src=&#34;https://blog-img.rmtt.fun/posts/computation-structure-09/stored-program-computer.png&#34;&gt;&lt;/p&gt;
&lt;p&gt;在冯诺伊曼结构中，有一个专门的&lt;em&gt;PC&lt;/em&gt;寄存器，用来存储&lt;em&gt;下一条&lt;/em&gt;指令在主存中的地址。&lt;/p&gt;
&lt;p&gt;&lt;img loading=&#34;lazy&#34; src=&#34;https://blog-img.rmtt.fun/posts/computation-structure-09/anatomy-of-von-neumann-computer.png&#34;&gt;&lt;/p&gt;
&lt;h2 id=&#34;指令和指令集&#34;&gt;指令和指令集&lt;/h2&gt;
&lt;p&gt;指令就是用来告诉&lt;em&gt;control logic&lt;/em&gt;该干什么，指令集就是按同一标准设计的一大堆指令，可以控制&lt;em&gt;control logic&lt;/em&gt;干各种各样的事。指令集相关内容感觉没有太多需要记录的，所以就不记录啦。&lt;/p&gt;
&lt;h2 id=&#34;summary&#34;&gt;Summary&lt;/h2&gt;
&lt;p&gt;&lt;img loading=&#34;lazy&#34; src=&#34;https://blog-img.rmtt.fun/posts/computation-structure-09/beta-isa-summary.png&#34;&gt;&lt;/p&gt;</description>
    </item>
  </channel>
</rss>
