1 / 11

รหัส (Codes)

รหัส (Codes). วัตถุประสงค์ของบทเรียน รู้จักรหัสแบบต่างๆ ศึกษาประโยชน์ของรหัสแต่ละประเภท ศึกษาวิธีการแปลงรหัส ศึกษาวิธีการเข้ารหัสและถอดรหัส. Number Representation Codes. Straight binary code: Represents numbers using natural or straight binary form (this is a weighted code)

pearl-brock
Download Presentation

รหัส (Codes)

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. รหัส (Codes) วัตถุประสงค์ของบทเรียน • รู้จักรหัสแบบต่างๆ • ศึกษาประโยชน์ของรหัสแต่ละประเภท • ศึกษาวิธีการแปลงรหัส • ศึกษาวิธีการเข้ารหัสและถอดรหัส A. Yaicharoen

  2. Number Representation Codes Straight binary code: Represents numbers using natural or straight binary form (this is a weighted code) Decimal codes: Use binary to represent a decimal value • Weighted decimal codes The location of each bit contains related weight. Example: BCD (or 8421) code, 2421 code, 7536' code, or 5043210 code • Nonweighted decimal codes The location of each bit has no related weight. Example: Excess-3 code, 2-out-of-5 code A. Yaicharoen

  3. Code Conversion Decimal to BCD code conversion (VS straight binary) 1 9 2 8 (decimal) 0001 1001 0010 1000 (BCD) 0111 1000 1000 (binary) A. Yaicharoen

  4. Unit-Distance Codes Use when convert analog quantity to digital representation Only one bit change between two successive integer numbers Example: Gray code A. Yaicharoen

  5. + + + Code Conversion Binary code to Gray code conversion 1 0 0 1 (binary) 1 1 0 1 (Gray) A. Yaicharoen

  6. + + + Code Conversion Gray code to Binary code conversion 1 1 0 1 (Gray) 1 0 0 1 (binary) A. Yaicharoen

  7. Alphanumeric codes Use binary to represent characters Number of bits in these codes depends on number of characters these codes represented. Example: ASCII (American Standard Code for Information Interchange) is 7-bit code Unicode Standard is 16-bit code A. Yaicharoen

  8. Error Detection Codes เป็นรหัสที่สามารถตรวจสอบได้ว่ามีความผิดพลาดในการรับ-ส่ง หรือไม่ แบ่งเป็น 2 ประเภทคือ 1. ประเภทที่สามารถตรวจสอบข้อผิดพลาดได้จากตัวรหัสเอง เช่น รหัส 2-out-of-5, biquinary 2. ประเภทที่ต้องมีการเพิ่มเติมข้อมูลลงไปในรหัสเพื่อใช้ในการ ช่วยตรวจสอบข้อผิดพลาด เช่น การเพิ่ม parity bit - odd parity เป็น 1 เพื่อให้จำนวนของ 1 เป็นจำนวนคี่ - even parity เป็น 1 เพื่อให้จำนวนของ 1 เป็นจำนวนคู่ A. Yaicharoen

  9. Error Correction Codes เป็นรหัสที่มีการเพิ่มเติมข้อมูลลงไปเพื่อช่วยให้สามารถ 1. ตรวจสอบว่าข้อมูลผิดพลาดหรือไม่ 2. ถ้าข้อมูลผิดก็สามารถบอกตำแหน่งที่ผิดพลาดได้ ตัวอย่างของรหัสนี้ได้แก่ Hamming code สำหรับข้อมูลขนาด 4 bit จำเป็นต้องเพิ่มข้อมูลของ parity อีก 3 bit ในระบบของ Hamming code โดยจะอยู่ในรูปของ p1 p2 b1 b2 p3 b3 b4 (หนังสือบางเล่มจะเป็น b4 b3 b2 p3 b1 p2 p1) จำนวนของ parity bit (k) ที่จะเติมลงในรหัสที่มีข้อมูลจำนวน m bit หาได้จาก m  2k - k - 1 A. Yaicharoen

  10. Hamming Code จำนวนของ parity bit (k) ที่จะเติมลงในรหัสที่มีข้อมูลจำนวน m bit จำนวนข้อมูล จำนวนของ parity bit 2-4 3 5-11 4 12-26 5 27-57 6 58-120 7 ตำแหน่งของ parity bit ที่ใช้ตรวจสอบตำแหน่งของข้อมูลที่ผิดพลาด ตำแหน่งของ parity bit ตำแหน่งของข้อมูล 1 1,3,5,7,9,11,13,15,17,... 2 2,3,6,7,10,11,14,15,18,... 4 4,5,6,7,12,13,14,15,20,... 8 8,9,10,11,12,13,14,15,24,... A. Yaicharoen

  11. Hamming Code Parity bit ที่ตำแหน่ง i (pi) จะเป็น even parity ที่เติมเข้าไป โดยคิดจากตำแหน่ง ของข้อมูลใน bit ต่างๆที่เกี่ยวข้อง เช่น p1 จะได้จากการนำข้อมูลใน bit ที่ 3, 5, 7,... ดังนั้น ถ้าข้อมูลใน bit ที่ 3, 5, และ 7 เป็น 0, 1, และ 1 ตามลำดับ จะได้ p1 = 0 (จาก 0  1  1) การตรวจสอบว่าข้อมูลใน bit ใดผิดพลาด สามารถทำได้โดย 1. หาค่าของ check bit จากการหา even parity ของ parity bit ที่ i กับ ข้อมูลในบิตที่เกี่ยวข้อง 2. นำข้อมูลทั้งหมดมาเรียงกัน ค่าที่ได้คือตำแหน่งที่เกิดความผิดพลาด เช่น p1p2p3 = 011 หมายความว่า ตำแหน่งที่ 3 ของข้อมูลเกิดความผิดพลาด A. Yaicharoen

More Related