Luke Tseng
    • 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 No publishing access yet

      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.

      Your account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

      Your team account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

      Explore these features while you wait
      Complete general settings
      Bookmark and like published notes
      Write a few more notes
      Complete general settings
      Write a few more notes
      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 New
    • Engagement control
    • Make a copy
    • 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 Note Insights Versions and GitHub Sync Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Engagement control Make a copy 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 No publishing access yet

    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.

    Your account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

    Your team account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

    Explore these features while you wait
    Complete general settings
    Bookmark and like published notes
    Write a few more notes
    Complete general settings
    Write a few more notes
    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
    1
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    # 什麼是奇偶校驗?(Parity Bit) [TOC] 歡迎你點入本篇文章,會促成我想做這篇的原因,主要是因為在上計概時,突然浮現很多靈感,跟一大堆的問題(~~教授,為什麼要講的這麼淺白呢?我想知道更多啊啊!~~),為了一次解決我所有的困惑,於是製作本篇文章。 若文章有任何疑點及錯誤的地方歡迎提出。 ## Parity Bit > **Parity bit**(同位位元 or 奇偶校驗位)為最簡單且廣泛使用的錯誤檢測方法,透過在資料中增加一個額外的位元來檢測傳輸或儲存過程中是否發生錯誤。這個概念在現代計算機系統與串列通訊中扮演著重要的角色。 > From Wikibooks : https://zh.wikibooks.org/zh-tw/%E5%B5%8C%E5%85%A5%E5%BC%8F%E7%B3%BB%E7%BB%9F/%E5%A5%87%E5%81%B6%E6%A0%A1%E9%AA%8C ### 原理 做奇偶校驗前先計算二進位中 **1** 的個數,在 1 byte 中,通常有 7 bits 用於實際資料,第 8 個 bit 用來當作檢查位(或稱校驗位)。檢查位的值會根據其他 7 個 bits 中「1」的個數來決定,使整個 byte 中 1 的總數保持為奇數或偶數。 也就是說如果要做偶校驗,假設這 1 byte 的資料裡面 1 的數量有 5 個,由於是做偶校驗,所以要在檢查位改成 1,讓他變成偶數的,反之。 ### 偶校驗(Even parity) 就是要讓整個二進位資料的 1 的個數變成偶數個。 * 如果資料位元中「1」的個數是**奇數**,檢查位設為「1」。 * 如果資料位元中「1」的個數是**偶數**,檢查位設為「0」。 範例:對 $(1100001)_2$ 二進位數字做偶校驗(even parity)。 觀察這個資料它是 7 bits 的二進位資料,而且 1 的個數只有三個,然後又要做偶校驗,因此在第 8 個 bit 中加上 1,就是最後一個位元,因而得到 $(11000011)_2$ ,那個檢查位在最右邊的位元。 ### 奇校驗(Odd parity) 跟偶校驗相反,這要讓 1 的個數變成奇數個。 * 如果資料位元中「1」的個數是**偶數**,校驗位設為「1」。 * 如果資料位元中「1」的個數是**奇數**,校驗位設為「0」。 沿用上面範例,得到的結果就是 $(11000010)_2$ 。 ## 為什麼要用到 Parity Bit 因為它可以用到以下幾個領域: - 序列通訊(Serial communication)如 UART - 記憶體系統 - RAID系統 另外常聽到的 ECC(Error Checking and Correcting,錯誤檢查與糾正)、CRC(Cyclic Redundancy Check,循環冗餘校驗)技術,也都是基於 Parity Bit 的,不過除了 CRC,因為 Parity Bit 算是 CRC 的一種特例。 ECC 比較常用於伺服器記憶體中,以下就比較 Parity Bit 跟 ECC 記憶體的主要差別: * Parity 記憶體:只能發現錯誤,系統會當機或重新啟動。 * ECC 記憶體:能發現錯誤並自動糾正,系統可以繼續正常運作。 然後 CRC 的應用也蠻多廣的: * 網路封包傳輸(Ethernet)。 * 檔案完整性驗證。 * 儲存裝置(硬碟、SSD)。 * Modbus 等工業通訊協定。 總之,Parity Bit 就是上述這些東西的基礎! ## Parity Bit 優缺點 優點: - 實作簡單:只需要基本的 XOR 運算即可實現。 - 資源需求低:僅需一個額外位元,運算成本極低。 - 硬體友善:容易在硬體層級實現,適用於資源受限的系統。 缺點: - 檢測能力有限:只能檢測奇數個位元的錯誤,無法檢測偶數個位元的同時錯誤。 - 無法糾錯:只能發現錯誤,無法確定錯誤位置或進行自動修正。 - 檢錯率50%:理論上只有 50% 的錯誤檢測率。 發生 2 個 bit 的錯誤率小於 1%,奇偶校驗(Parity Bit)在多數情況還是有用處的,但在高精密設備上,可能需要採用更先進的錯誤更正碼(如漢明碼:Hamming Code,就是 ECC 最常見的實作方法)。 ## 參考資料 [Parity bits - IBM Documentation](https://www.ibm.com/docs/en/aix/7.2.0?topic=parameters-parity-bits) [嵌入式系統/奇偶校驗 - 維基教科書,自由的教學讀本](https://zh.wikibooks.org/zh-tw/%E5%B5%8C%E5%85%A5%E5%BC%8F%E7%B3%BB%E7%BB%9F/%E5%A5%87%E5%81%B6%E6%A0%A1%E9%AA%8C) [什么是奇偶校验? - 惊风雨 - 博客园](https://www.cnblogs.com/winformasp/articles/11944018.html) [同位位元 - 維基百科,自由的百科全書](https://zh.wikipedia.org/zh-tw/%E5%A5%87%E5%81%B6%E6%A0%A1%E9%AA%8C%E4%BD%8D)

    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
    Sign in via Facebook Sign in via X(Twitter) Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    By signing in, you agree to our terms of service.

    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