1 / 34

Basic Input/Output

Basic Input/Output. Wannachai Wannasawade Department of Computer Education Faculty of Technical Education, KMITNB. Basic Input/Output.

magnar
Download Presentation

Basic Input/Output

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. Basic Input/Output Wannachai Wannasawade Department of Computer Education Faculty of Technical Education, KMITNB.

  2. Basic Input/Output • การทำงานของไมโครโพรเซสเซอร์ไม่ได้มีเฉพาะกับหน่วยความจำเท่านั้น แต่ยังมีการทำงานที่เกี่ยวกับอินพุท-เอาท์พุท หรือที่เรียกว่า “I/O port”ซึ่งเป็นทางที่ใช้ในการเชื่อมต่อแลกเปลี่ยนข้อมูลระหว่างไมโครโพรเซสเซอร์กับอุปกรณ์ภายนอก • โดยมีประเภทของอินพุท-เอาท์พุทที่เป็นพื้นฐานหลัก 2 ประเภทคือ • ขนานข้อมูล (Parallel) • อนุกรมข้อมูล (Serial) • การเชื่อมต่อแบบขนานข้อมูลเป็นวิธีการเชื่อมต่อที่ง่ายที่สุด โดยมองข้อมูลเป็นกลุ่มก้อน ซึ่งมีขนาดเท่าใด จะขึ้นอยู่กับขนาดของไมโครโพรเซสเซอร์แต่ละตัว อาจมีขนาด 8 บิท 16 บิท 32 บิท หรือ 64 บิท การส่ง หรือรับข้อมูลตามจำนวนความกว้างของข้อมูลที่ไมโครโพรเซสเซอร์แต่ละตัว

  3. Basic Input/Output • ส่วนการเชื่อมต่อแบบอนุกรมข้อมูล มีลักษณะการส่ง ข้อมูลที่แตกต่างกันออกไปคือ ข้อมูลจะส่งไปในรูปแบบของบิทที่ต่อเนื่องกันไป ซึ่งจะมีการส่งข้อมูลที่ช้ากว่าแบบขนานข้อมูล แต่มีข้อดีตรงที่ใช้สายสัญญาณที่น้อยลง เช่น การเชื่อมต่อแบบสองทาง (Full-Duplex) จะใช้สายสัญญาณเพียง 3 เส้น • Transmit Data • Receive Data • Common Ground between Computer and Peripheral

  4. Basic Input/Output Type of Input/Output • Parallel I/O • Serial I/O • Programmed I/O • Interrupt-Driven I/O • Direct Memory Access

  5. Basic Input/Output I/O Instructions เป็นกลุ่มคำสั่งที่ใช้ในการติดต่อควบคุมอุปกรณ์อินพุท-เอาท์พุทต่าง ๆ โดยแบ่งได้ 2 คำสั่งหลัก ๆ คือ INเป็นคำสั่งที่ใช้ในการอ่านข้อมูลจากอุปกรณ์อินพุท-เอาท์พุท OUT เป็นคำสั่งที่ใช้ในการเขียนข้อมูลไปให้กับอุปกรณ์อินพุท-เอาท์พุท

  6. Basic Input/Output Instruction Data WidthFunction IN AL,p8 8 Read byte from port p8(8 bit) into AL IN AX,p8 16 Read word from port p8(8 bit) into AX IN EAX,p8 32 Read doubleword from port p8(8 bit) into EAX IN AL,DX 8 Read byte from port address by DX into AL IN AX,DX 16 Read word from port address by DX into AX IN EAX,DX 32 Read doubleword from port address by DX into EAX INSB 8 Read byte from port address by DX into Extra Segment by DI = DI (+,-) 1 INSW 16 Read word from port address by DX into Extra Segment by DI = DI (+,-) 2 INSD 32 Read doubleword from port address by DX into Extra Segment by DI = DI (+,-) 4

  7. Basic Input/Output Instruction Data Width Function OUT p8,AL 8 Write byte from AL to port p8(8 bit) OUT p8,AX 16 Write word from AX to port p8(8 bit) OUT p8,EAX 32 Write double word from EAX to port p8(8 bit) OUT DX,AL 8 Write byte from AL to port address by DX OUT DX,AX 16 Write word from AX to port address by DX OUT DX,EAX 32 Write double word from EAX to port address by DX OUTSB 8 Write byte from Data Segment to port address by DX SI= SI(+,-)1 OUTSW 16 Write word from Data Segment to port address by DX SI= SI(+,-)2 OUTSD 32 Write double word from Data Segment to port address by DX SI= SI(+,-)4

  8. Basic Input/Output โดยที่คำสั่งทั้ง 2 ประเภทจะใช้การรับส่งข้อมูลผ่านทาง Accumulator ของไมโครโพรเซสเซอร์ (AL, AX, EAX) ซึ่งค่า I/O Address ที่เก็บอยู่ใน Register DX จะเป็นแบบ 16 บิท หรือ 8 บิท ที่ตามหลัง Opcode ทาง Intel เรียก port ขนาด 8 บิท (p8) เป็น Fixed Address และ 16 บิทที่เรียกผ่าน DX เป็น Variable Address I/O Address นิยมเรียกว่า “Port Number” ซึ่ง Fixed port number (p8) จะใช้สายสัญญาณ Address 8 เส้นคือ A0-A7 (0-255 หรือ 0000H-00FFH) ส่วน Variable port number ใช้สายสัญญาณ Address 16 เส้นคือ A0-A15(0-65535 หรือ 0000H-FFFFH) โดยที่ 256 ตำแหน่งแรกสามารถใช้งานได้ทั้ง Fixed port number และ Variable port number แต่หลังจากนั้นจะเป็นของ Variable port number เท่านั้น สำหรับในเครื่องไมโครคอมพิวเตอร์ทั่วไปจะใช้งานอินพุท-เอาท์พุทที่ตำแหน่ง 00XXH-03XXH

  9. Basic Input/Output Isolated I/O เป็น I/O ที่แยกกันอย่างอิสระระหว่างหน่วยความจำของระบบกับ I/OAddress ที่ใช้กับ I/O เรียกว่า “Ports” ข้อดีของวิธีการนี้คือ สามารถขยายขนาดของหน่วยความจำได้โดยไม่ต้องคำนึงถึงพื้นที่ของ I/O port ข้อเสียของแบบนี้คือ จะต้องมีการแยกสัญญาณควบคุมที่แน่นอน โดยใช้สัญญาณ M/IO และ W/R ให้เป็น IORC กับ IOWC Isolate I/O ใช้ในการควบคุมอุปกรณ์โดยกำหนดให้ใช้ port ขนาด 8 บิทควบคุมอุปกรณ์บน System Board ส่วน port ขนาด 16 บิทควบคุมการติดต่อทั้งแบบอนุกรมและขนาน FFFFFH 1M X 8 0FFFFH 64K X 8 00000H 00000H Isolate I/O

  10. Basic Input/Output FFFFFH I/O 00000H Memory Mapped I/O Memory Mapped I/O เป็นระบบที่นำตำแหน่งของหน่วยความจำของระบบมารวมกับตำแหน่งของ I/O ทำให้มีข้อเสียคือ ไม่สามารถใช้งานหน่วยความจำได้ทั้งหมด ข้อดีคือ ลดสัญญาณควบคุมที่ไม่จำเป็นออก ทำให้ลดขนาดของวงจรลง และที่สำคัญที่สุดคือ คำสั่งที่ใช้งาน ไม่ใช้คำสั่งที่เกี่ยวกับ I/O (IN, INS, OUT, OUTS) แต่ใช้คำสั่งที่รับส่งข้อมูลระหว่างไมโครโพรเซสเซอร์กับหน่วยความจำ กับ I/O ได้

  11. Basic Input/Output Personal Computer I/O Mapped Port 0000H-03FFH: จองไว้สำหรับระบบของเครื่อง Port 0400H-FFFFH : เปิดใช้งานทั่วไป

  12. Basic Input/Output Basic Input

  13. Basic Input/Output • Basic Input Interface • Three-State Buffer • External TTL connect to inputs of buffer • Outputs of buffer connect to Data bus • Data bus size depend on version of the Microprocessor such as 8086 has data bus 16 bits 80486 has data bus 32bits and Pentium II has data bus 64 bits • Microprocessor can receive data when execute IN Instruction

  14. Basic I/O Interface : Output

  15. Basic Input/Output • Basic Output Interface • Receive data from Microprocessor and must hold data for some external device • Latches or Flip-flop, like the buffers • Used OUT instruction then send data from AL, AX, EAX • Data must hold until next OUT Instruction execute

  16. Basic Input/Output • Handshaking • Many I/O device much slower rate than the microprocessor. Thus, How to control I/O device? • Handshaking or Polling • Synchronizes the I/O with the microprocessor • Example Parallel Printer BUSYindicates that the printer busy and STB is clock pulse used to send data to printer

  17. Basic Input/Output Input Device :ส่วนใหญ่ จะเป็น TTL การเชื่อมต่อจึงไม่มีข้อยุ่งยากอะไร ซึ่งอินพุทที่ใช้ส่วนใหญ่ เป็นอุปกรณ์จำพวกสวิตซ์ แต่ในบางครั้งอาจต้องมาการดัดแปลงแก้ไขบ้าง ซึ่งส่วนใหญ่จะใส่ Resistor ที่เรียกว่าR Pull-upเพื่อให้ทำงานได้ถูกต้อง ( TTL Logic Level : “0”= 0.0 V - 0.8 V“1”= 2.0 V - 5.0 V ) โดยที่ค่า R อยู่ระหว่าง 1KW - 10KWและนอกจากปัญหาเรื่องของระดับสัญญาณ ลอจิกแล้วยังมีปัญหาที่เกิดจากการกดสวิตซ์ซึ่งจะพบมากับการนำไปใช้ในวงจรที่มีสัญญาณนาฬิกาเข้ามาเกี่ยวข้องแต่สามารถแก้ไขได้โดยการเพิ่มวงจร

  18. Basic Input/Output

  19. Basic Input/Output

  20. Basic Input/Output Output Device :เป็นอุปกรณ์ที่มีความหลากหลายในการเชื่อมต่อ แต่สิ่งที่เหมือนกันคือ แรงดันและกระแสไฟฟ้าที่ใช้ โดยที่แรงดันที่ไมโครโพรเซสเซอร์ส่งออกมาในรูปแบบของสัญญาณ TTL มีค่าแตกต่างจากทางด้านอินพุทคือ ที่ระดับ “0” จะให้แรงดันระหว่าง 0.0 V - 0.4 V และระดับ “1” ที่ 2.4 V - 5.0 V ส่วนทางด้านกระแสของระดับ “0” จะอยู่ที่ 0.0 - 2.0 mA และที่ระดับ “1” จะอยู่ที่ 0.0 - 400 mA

  21. Basic Input/Output

  22. Basic Input/Output

  23. Basic Input/Output I/O Port Address Decode การ Decode Address ของ I/O จะง่ายกว่าการ Decode Address ของหน่วยความจำเพราะ I/O มีตำแหน่งที่แน่นอน และที่แตกต่างกันชัดเจนคือ จำนวนของ สัญญาณ Address ที่ใช้ เช่น Decode หน่วยความจำจะใช้สัญญาณ Address A0-A31, A0-A24 หรือ A0-A19แต่ I/O ใช้สัญญาณ Address คือ A0-A15 เท่านั้น และสัญญาณควบคุมที่ใช้ คือ IORC และ IOWC มาร่วมในการ Decode ด้วย

  24. I/O Port Decoding

  25. Basic Input/Output 8 Bit Decode

  26. Basic Input/Output 16 Bit Decode

  27. Basic Input/Output 16 Bit 2 Bank Decode

  28. Basic Input/Output 16 Bit Decode

  29. Basic Input/Output 32 Bit Decode

  30. Use 8 LED’s A19 A18 : A0 : mov al, 55 out dx, al : : : D7 D6 D5 D4 D3 D2 8088 D1 Minimum D0 Mode IOR IOW

  31. A0 B0 A1 B1 A2 B2 A3 B3 A4 B4 74LS245 A5 B5 A6 B6 A7 B7 E DIR 5V A A A A A A A A A A A A A A A A IOW 1 1 1 1 1 1 9 8 7 6 5 4 3 2 1 0 5 4 3 2 1 0 Use of 74LS245 and Address Decoder A19 A18 : A0 D7 D6 D5 D4 D3 D2 8088 D1 Minimum D0 Mode IOR : mov al, 55 mov dx, F000 out dx, al : IOW

  32. D0 Q0 D1 Q1 D2 Q2 D3 Q3 D4 Q4 74LS373 D5 Q5 D6 Q6 D7 Q7 LE OE Use of 74LS373 and Address Decoder A19 A18 : A0 D7 D6 D5 D4 D3 D2 8088 D1 Minimum D0 Mode IOR : mov al, 55 mov dx, F000 out dx, al : IOW A A A A A A A A A A A A A A A A IOW 1 1 1 1 1 1 9 8 7 6 5 4 3 2 1 0 5 4 3 2 1 0

  33. A0 B0 A1 B1 A2 B2 A3 B3 A4 B4 74LS245 A5 B5 A6 B6 A7 B7 E DIR Use of 74LS245 and Address Decoder 5V A19 A18 : A0 D7 D6 D5 D4 D3 D2 8088 D1 Minimum D0 Mode IOR : mov dx, F000 in al, dx : IOW A A A A A A A A A A A A A A A A IOR 1 1 1 1 1 1 9 8 7 6 5 4 3 2 1 0 5 4 3 2 1 0 Same address for input and output?

  34. Polling mov dx, F000 in al, dx L1: cmp al, FF je L1 : :

More Related