FANFNA
    • Create new note
    • Create a note from template
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
    • Invite by email
      Invitee

      This note has no invitees

    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Note Insights
    • Engagement control
    • Transfer ownership
    • Delete this note
    • Save as template
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Versions and GitHub Sync Note Insights Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Engagement control Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
  • Invite by email
    Invitee

    This note has no invitees

  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       owned this note    owned this note      
    Published Linked with GitHub
    Subscribed
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    Subscribe
    # ALU [TOC] ## overflow: :::info 我這邊引用一句話我覺得還蠻不錯的 overflow 就是張開翅膀(超出範圍) ::: :::success | a | b | | ---------------- | ---- | | $s0=0x70 000 000 (hex) | $s0=0x40 000 000 (hex) | | $s1=0x0F FFF FFF (hex) | $s0=0x40 000 000 (hex) | ::: 1. For the contents of registers $s0 and $s1 as specified aboce what is the value of $t0 for the followinf assembly code: ``` assemble add $t0, $s0, $s1 sub $t0 $s0,$s1 ``` assemble add $t0,$s0,$s1 ``` ``` mips add $t0,$s0,$s1 ``` ``` Is the result in $t0 the desired resulr or has there been overflow? ## [ADDR](https://www.youtube.com/watch?v=1I5ZMmrOfnA&t=246s) ### half addr 1. 只有當`1 XOR 1`才會是1 ![](https://i.imgur.com/dOY7UyT.png =300x300) ### FULL ADDR ![](https://i.imgur.com/1Eqi0Xt.png =300x300) ![](https://i.imgur.com/7T50Adp.jpg =500x300) ### Carry look-ahead adder :::success 在ALU中,加法器與乘法器有最長的delay path。carry-look-ahead logic就是預先將 Carry 預知送到下一級去運算,減少等待各級間 Carry 運算的時間來增加速度。 ::: :::warning 要預先得到 Carry 的情況就需要藉助 Carry Generate Block 的處理,我們定義 Propagate bit 與 Generate bit如下: P(i) = A(i) XOR B(i) G(i) = A(i) * B(i) 因此而得Carry和Sum為 C(i) = G(i) + P(i)G(i-1) + P(i)P(i-1)G(i-2) + … + P(i)…P(1)C(0) SUM(i) = A(i) XOR B(i) XOR C(i-1) = P(i) XOR C(i-1) ::: ![](https://i.imgur.com/jHOt0h2.png) :::danger 又因此而4 bit carry look-ahead adder的carry分別為 C1 = P0C0 + G0 C2 = P1C1 + G1 = P1(P0C0 + G0) + G1 = P1P0C0 + P1G0 + G1 C3 = P2C2 + G2 = P2(P1P0C0 + P1G0 + G1) + G2 = P2P1P0C0 + P2P1G0 + P2G1 + G2 C4 = P3C3 + G3 = P3(P2P1P0C0 + P2P1G0 + P2G1+ G2) + G3 = P3P2P1P0C0 + P3P2P1G0 + P3P2G1 + P3G2 + G3 ::: ## Mutiple (乘法器) ### 改良成法器 :::success - 先加上部分積 - 乘數和積向右shift一位 (都是在乘積暫存器裡同時做):同時“讀乘數的下一bit" 並減少目前product的位數 “讓之後算出的部分積相對增加” ::: ![](https://i.imgur.com/lwVmVlh.png) :::warning 1. 假如 遇到0 goto 3 2. 遇到 1 才會產生+ 乘數 goto 3 3. shift right 4. goto 1 終止條件 (當Shift 到32bits 得時候就會 停止) ::: ![](https://i.imgur.com/F9R45O0.png) ### Booth algrithem :::info - 概念 Booth演算法是一種較簡潔的有號數字相乘的方法,即利用位元掃描方式,跳過00、11以增快速度,因此,當乘數中的連續1比較多時(形成比較長的1串時),booth演算法較一般的乘法演算法執行的加減法運算少。 ::: :::warning 舉例來說... ``` A * 0011 1110 = A * (0100 0000 - 0000 0010) = A * 0100 0000 - A * 0000 0010 = (A<<6) - (A<<1) ``` 因此在booth演算法中有加法與減法。 注意起始狀態時乘數(與積共用)最右側要加上mythical bit = 0 ::: ![](https://i.imgur.com/fywntlF.png) :::info 00: 字串0的中間部份,不需要算術運算 01: 字串1的結尾,所以將被乘數加到乘積的左半部 10: 字串1的開端,所以從乘積的左半部減去被乘數 11: 字串1的中間部份,所以不需要算術運算 ::: ## FP(floating point) ![](https://i.imgur.com/AQsmRic.png) :::info **IEEE二進位浮點數算術標準(IEEE 754)** 浮點數儲存格式 - S:最高有效位為符號位 - Exponent:儲存指數 - Fraction:儲存尾數的小數部份(在非規約形式下整數部份默認為0,其他情況下一律默認為1) ::: **Two representaion** - ![](https://i.imgur.com/17846jy.png) ![](https://i.imgur.com/NSgivST.png) :::info 正規形式與非正規形式 **denormalize & normalize** 如果浮點數中指數部分的編碼值在0 < exponent < 2^(e)-1之間,且尾數部分最高有效位(即整數位)是1,那麼這個浮點數將被稱為正規形式的浮點數。 ::: :::warning 實際上非正規形式的浮點數仍然是有效可以使用的,只是它們的絕對值已經小於所有的規約浮點數的絕對值;即所有的非規約浮點數比規約浮點數更接近0 ::: :::info **指數偏移值 (exponent bias)** 浮點數表示法中的指數域的編碼值為指數的實際值加上某個固定的值,IEEE 754標準規定該固定值為2^(e-1) - 1,其中的e為儲存指數的位元的長度。以單精度浮點數為例,它的指數域是8個位元,固定偏移值是128-1 = 127。 ::: :::warning 採用這種方式表示的目的是簡化比較。因為指數的值可能為正也可能為負,如果採用補碼表示的話,全體符號位S和Exp自身的符號位將導致不能簡單的進行大小比較。正因為如此,指數部分通常採用一個無符號的正數值存儲。單精度的指數部分是−126~+127加上偏移值127,指數值的大小從1~254(0和255是特殊值)。浮點小數計算時,指數值減去偏正值將是實際的指數大小。 ::: ### Single-Precision Range Exponents 00000000 and 11111111 reserved :::warning - Smallest value - Exponent: 00000001 ⇒ actual exponent = 1 – 127 = –126 ::: Fraction: 000…00 ⇒ significand = 1.0 :::warning - Largest value - exponent: 11111110 ⇒ actual exponent = 254 – 127 = +127 Fraction: 111…11 ⇒ significand ≈ 2.0 ::: ### Double Precision ![](https://i.imgur.com/am3ccs1.png) ![](https://i.imgur.com/pgu0mkn.png) ### 計算 ![](https://i.imgur.com/VQBW3YD.png ) ### FP Adder Hardware :::success 因為一個一個位數換算太複雜了 而這邊我們來看看 交給機器下會是什麼樣 ![](https://i.imgur.com/8j0uYd1.png) ::: :::danger 1. 我們這裡看到兩個 FP 比較他們之間的大小(為什麼呢) 因為我們要 denormalize it help we 計算 2. 小的數值排到右邊 3. 我們再來是denormalize 這個最小的數值 4. 然後兩個數相加 5. normalize 6. Round (trash the bits not for use) ::: ![](https://i.imgur.com/G7Xw50x.png) ![](https://i.imgur.com/8IG1GG1.png) **[mropengate:computer-organization-ch3-arithmetic ](https://mropengate.blogspot.com/2015/01/computer-organization-ch3-arithmetic.html)**

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password

    or

    By clicking below, you agree to our terms of service.

    Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully