Sunday, February 23, 2014

Architecture of 80386



The internal architecture of 80386DX is divided into following sections:
  • Central processing unit
    • Execution unit
    • Instruction decode unit
  • Memory management unit
    • Segmentation unit
    • Paging unit
  • Bus control unit

The central processing unit is further divided into execution unit and instruction unit. The memory management unit consists of a segmentation unit and a paging unit . These unit operate in parallel. Fetching, decoding, memory management and bus access for several instruction are performed simultaneously. This parallel operation is called pipelined instruction processing .

Execution unit : The execution unit read the instruction from the instruction queue and executes the instructions. It consists of three subunit: control unit, data unit and protection test unit .

  1. Control unit : It contains microcode and special hardware. The microcode and special hardware allow 80386DX to reduce time required for execution of multiply and divide instruction . It also speeds up the effective address calculation .
  2. Data unit : The data unit contain the ALU, eight 32-bit general perpose registers and a 64-bit barrel shifter. The barrel shifter is used for multiple bit shifts in one clock. Thus it increases the speed of all shift and rotate operation. The multiply/divide logic implement the bit shift rotate algorithm to complete the operation in minimum time. The entire data unit is responsible for data operation requested by the control unit .
  3. Protection test unit : the protection test unit check for segmentation violations under the control of the microcode.

Instruction decode unit : The instruction decode unit takes the instruction bytes fron the code prefetch queue and translates them into microcode the decoded. The decoded instruction are then stored in the instruction queue. They are passed to control section for deriving the necessary control signals .

Segmentation unit : The segmentation unit translates logic addresses into linear addresses at request of the execution unit . The segmentation unit compares the effective address for the length limit specified in the segment descriptor. The segment unit adds the segment base and the effective address to generate linear address. Before calculation of linear address it also check for access rights. It provides a 4-level protection mechanism for protecting and isolating the system code and data from those of the application program.

Paging unit : When the 80386DX paging mechanism is unabled, the paging unit translates linear addresses generated by the segmentation unit or the code prefetch unit into physical addresses. If paging unit is not enabled, the physical address is the same as the linear address, and no translation is necessary. The paging unit gives physical address to the bus interface unit to perform memory and I/O accesses . It organizes the physical memory in term of pages of 4 kbytes size each .

The control and attribute PLA check the privileges at the page level. Each of the page maintain the paging information of the task. The limit and attribute PLA checks segment limits and attributes at the segment level to avoid anvalid accesses to code and data in the memory segments .

Bus control unit : The bus control unit is the 80386DX's communication with the out side world. It provide a full 32-bit bi-directional data bus and 32-bit address bus. The bus control unit is responsible for the following operations :

  1. It accepts internal request for code fetch and data transfer from the code fetch unit and from the execution unit. It then prioritize the request with the help of prioritize and generate signal to perform bus cycles.
  2. It sends address, data and control signal to communicate with memory and I/O devices. The address driver drives the bus enable and address signal A0-A31 and the transceiver interface the internal data bus with the system bus .
  3. It control the interface to the external bus masters and coprocessors.
  4. It also provides the address relocation facility.

Instruction prefetch unit : The instrction prefetch unit fetch sequentially the instruction byte stream from the memory. It uses bus control unit to fetch instruction bytes when the bus control unit is not performing bus cycle to execute an instruction. These prefetched instruction bytes are stored in the 16-byte code queue. A 16-byte code queue holds these instruction until the decoder needs them the prefetcher always fetches instruction in the order in which they appear in the memory. It fact, the prefetcher simply reads code one double word at the time, not caring whether it's bringing in complete instruction are executed, the contents of the prefetched and decode queues are cleared out. In this case, prefetcher again starts filling its queue.

Instruction predecode unit : The instruction predecode unit takes instruction bytes from the instuction prefecth queue an translate them into microcode the decoded instruction are then stored in instruction queue.

References:
  1. Wikipedia page on 80386.
  2. Advanced 80386 Programming Techniques” by James L. Turley, TMH Publications.

1 comment: