Chris Chung
    • 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
    ## floating-point format > 會考一題單精度轉換 > ex: (-3.625)10 > 變成二進制 ![image](https://hackmd.io/_uploads/ByKKyfX4T.png) > 1. 浮點數沒有使用二補數的概念 前面的S代表正負數 > 2. Bios -> 主要是將Exponent中的負數變成正數 > 3. flaot 最小值為2的-126次方(因為指數偏移量是127, 如果是-127+127 = 0, 這是不可以的) > 4. 0 是用來表示0或者非標準數 > 5. 為什麼非標準數會逐漸underfloat 位元組的關係,所以正常都使用標準數,非標準數雖然可以更多位元,但這就是精密度喪失的原因 > 6. 非標準數最小可以到多少? 1x2的-149次方(因為加上中間23位元) > 7. 標準數最小可以到多少? 1x2的-126次方 > 8. 最大數值為什麼是127次方, 因為如果加上128就會到255, 不能超過, 因為代表其他數字 ![image](https://hackmd.io/_uploads/HJI0HwSBT.png) ![image](https://hackmd.io/_uploads/rJcvvvBBT.png) 1.比較兩個數字的指數;將較小的數向右移動,直到 指數將匹配較大的指數 2.加有效數 3.標準化總和,要么右移並增加指數,要么左移 並遞減指數 4.判斷overflow or underflow 5.是的話例外處理 6.不是的話將有效值四捨五入到適當的值位數 7.判斷是否標準化(浮點數形式) 8.是就結束 9.不是就重複第三步驟 ![image](https://hackmd.io/_uploads/SklcKmFrBT.png) > 1. small alu 主要確認指數 > 2. exponent diffentence 主要指數項相減給後續移位用 > 3. 這是一個多工選擇器, 以左邊fracrtion 如果是0就往下移動 右邊的fracrtion則是1就往下 > 範圍:第一部分:一直到shift right, 第二部分:big ALU ![image](https://hackmd.io/_uploads/Hy9PWoABT.png) > 1. 為什麼需要在第一步的時候先-127, > 例如:[1.23*10^(-3)] * [3.543 * 10^(-12)], 兩個數值都有透過編碼+127, 所以需要減掉一次。 > 2. 第五步可以透過XOR邏輯閘展示出來 1. 將兩個數字的有偏指數相加,從總和中減去偏差 得到新的有偏指數 2. 有效數字相乘 3. 進行標準化,轉移 正確並增加指數 4. 判斷Overflow or underflow? 5. 有的話例外 6. 沒有的話將有效值四捨五入到適當的值 位數 7. 判斷是否標準化 8. 不是就動第三步驟 9. 是就判斷正負數後結束 --- ## pipline > 第一週期單純讀取 - IF > 第二週期可以指令解碼 - ID > 第三週期ALU計算 - EX > 第四週期記憶體讀取 - MEM > 第五週期寫回register - WB ### 危障 > 1. 結構危障(structure hazards):因為只有一個記憶體, 他不能同時處理第一週期跟第四週期, 解決辦法:記憶體要買兩條 > 2. 資料危障(data hazards): 通常出現在ALU, 計算錯誤, 取決於相依性, 解決方式:forwards and 泡泡, 兩個連續add, sub指令有相依性:兩個泡泡(stall) + 二級forwards , 如果相依性lw指令 + R指令, 要放一個泡泡(stall) + 一級forwards, > 3. 控制危障(control hazards):到某個位置, beq相同往右, 不同就往左(pc+4), 因為前一個branch 進來, 後面的指令就已經進入pipline, 如果決定要branch到別的地方就會出錯, 所以控制危障事先預測, 像是隔離14天, 只要有出國就先回來隔離, 通常沒確診猜錯就會形成控制危障, 通常猜錯在第三週期, 猜錯的話就用IF.Flush 讓他們無效化變成stall包起來 ### 資料危障 硬體解決可以使用 forwards ### Wb for load 會發生問題 > 比如帳單問題, IF = 櫃檯, ID = 飯, EX = 主菜, MEM = 副菜, WB, 帳單要跟著走 不然會出錯, 上一個還沒結束, 下一個就開始寫入, 帳單會出錯 > ex. lw $s1 $s2(100) ![image](https://hackmd.io/_uploads/HJSf6fWva.png) ### detectiom the need to Forward ![image](https://hackmd.io/_uploads/rJiA8Q-Pp.png) > #### 三排以上都是安全的 > sw 不用forwards, 因為不用wb > 1. add $s1 $s2 $s3 1 -> 2 = #1 = 1a > 2. sub $s4 $s1 $s5 > 3. and $s7 $s8 $s1 1 -> 3 = #2 = 2b > 1. add $s2 $s1 $s3 > 2. sub $s1 $s5 $s4 > 3. and $s8 $s1 $s7 ------ > 4. or $10 $1 $2 -> 安全的 > rd, rs = a, rt = b ![image](https://hackmd.io/_uploads/Bk5eS4WDa.png) ![image](https://hackmd.io/_uploads/rkC1gVWDa.png) > #### rd 不能為0, 防止變成0號暫存器 > #### EX/MEM.RegWrite 為了防止sw指令 ![image](https://hackmd.io/_uploads/BJKiGVWPT.png) > 1,3 -> 2a 2,3 -> 1a > 2a 不能forward , 因為第二行也有一個WB, 如果2a forward 值會是錯的 (2a and 1a 不能同時發生) ![image](https://hackmd.io/_uploads/H168rNZvp.png) > 一定要放一個stall, 慢一拍後再來fordward ![image](https://hackmd.io/_uploads/rkaewNZvT.png) > 透過nop 指令讓他們無害通過(包在泡泡裡), 把所有訊號變成0, 不戰、不和、不守、不死、不降、不走, PC不能+4, IM的地方要讓指令停止以及Reg要維持一樣的位置 --- ### 記憶體(Memory) #### Locality * Temporal locality(時間的區域性): -> It’s likely to need this word again in the near future > Example: int a = 0;(and then many programs in here...); a = a + 1; > * Spatial locality(空間的區域性): -> There is high probability that the other data in the block will be needed soon ### Cache Memory #### Block placement > 看block應該放在哪裡 * Direct mapped (對號座) : 取餘數作為index * Fully associative (自由座) : 任意位置都可以放置 * Set associative (只可選車廂) : 取Set數量的餘數 #### Block identification * Block address * Block offset Source: Lecture 7: Caches https://people.engr.tamu.edu/djimenez/taco/utsa-www/cs5513-fall07/lecture7.html #### Block replacement > 衝突發生時,Block的取代方式 * Random * LRU(Least Recently Used Cache) * FIFO(First in First out) #### Write strategy > 假設執行一個儲存指令時,我們只將資料寫到資料快取中(而沒有寫到主記憶體)時,會使快取和記憶體是不一貫(inconsistent)的 => 同步的概念 **1. 針對資料命中而言(Write hit)**: * Write through(較常使用,並搭配寫緩衝器Write buffer): 優點: 資料一致性 缺點: 操作量大,等待時間較長,也因為操作量大,故需要write buffer減少硬體衝突 > -> 當cache裡沒有需要的資料時,修改cache裡面的值(如果沒有空格子,則覆蓋在cache內最舊的資料),並修改MEM裡面對應的Block內的值 * Write back(適合嵌入式系統): 優點: 節省了大量的寫入操作,速度快 缺點: 因為只在快取作更改,資料會有不一致的問題,並且在快取丟失資料時,通常也來不及做存取至記憶體 > -> 將要修改的值標記為Dirty Block,在下次Block要被取代時才寫回MEM **2. 若沒命中(Write miss):** * Write allocate policy > -> 將所需資料讀入快取,然後再將資料寫到被讀入的單元 > -> 把要寫的地址所在塊先從main memory調入cache中,然後再寫入cache * No write allocate policy > -> 總是直接將資料寫回記憶體 Source: 什麼是write-allocate policy? https://blog.csdn.net/dahailantian1/article/details/78584856 ## 磁碟陣列(RAID)

    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