Académique Documents
Professionnel Documents
Culture Documents
Khaled A. Al-Utaibi
Copyright c 2013, University of Hail, Hail, Saudi Arabia. All rights reserved. http://www.uoh.edu.sa
Contents
Preface
1.1 1.2 1.3 1.4
iii 1
Proteus Virtual System Modeling (VSM) 1 Overview of the ISIS Editor 3 Design Example 6 Schematic Entry of the Modulo-5 Binary Counter 7
17
2.1 Design Example 17 2.2 Frequency Divider by 5 with a 50% Duty Cycle 18 2.3 Schematic Entry of the Frequency Divider Circuit 19
25
3.1 Pin Functions of the 8284A Clock Generator 25 3.2 Operations of the 8284A Clock Generator 27 3.3 Schematic Entry of the 8284A Clock Generator 28
35
4.1 Pin Functions of the 8086 Microprocessor (Minimum Mode) 35 4.2 Basic Connections of the 8086 Microprocessor (Minimum Mode) 39 4.3 Testing the 8086 Microprocessor 40
47
ii
57
69
7.1 8086 I/O Mapping 69 7.2 Designing a Simple 8-Bit Parallel Port 71
7.2.1 Testing the I/O Port 73
Appendix
75
Preface
This LAB Manual is intended to guide computer engineering students to design and fabricate an 8086-based microcomputer system. The manual consists of a set of experiments for gradually designing, assembling and testing a single-board 8086-based microcomputer system. Through the gradual construction process, students will gain knowledge and experience in circuit design, wire-wrapping and soldering techniques, board design and parts layout, static and dynamic testing, programming, use of test equipment for analysis and troubleshooting, and data acquisition. Upon completion of the project, the student will have constructed a fully functional single-board 8086-based microcomputer with a fullydemultiplexed and buered bus system, a 32KB memory system, a simple 8-bit parallel input/output (I/O) port. The students will also be exposed to common I/O peripheral devices such as the 8251A Universal Synchronous/Asynchronous Receiver/Transmitter (USART), the 8255A Programmable Peripheral Interfaces (PPI), the 8253 Programmable Interval Timer (PIT), and the 8259A Programmable Interrupt Controller (PIC). The LAB manual provides a set of design and programming experiments to teach the students how interface these I/O peripheral devices to the 8086-based microcomputer system and use assembly programming to operate them. The LAB manual include the following set of experiments : 1. Introduction the Proteus Virtual System Modeling (VSM) - Part I. 2. Introduction the Proteus Virtual System Modeling (VSM) - Part II. 3. The 8284A Clock Generator. 4. Basic Connections of the 8086 Microprocessor.
iv
Preface
5. Designing a Fully-Demultiplexed and Buered Bus System. 6. Designing a 32KB Memory System. 7. Designing a Simple 8-Bits Parallel I/O Port. 8. Programming and Testing the 80806-Based Microcomputer System. 9. Interfacing and Programming the 8255A Programmable Peripheral Interfaces (PPI). 10. Interfacing and Programming the 8253 Programmable Interval Timer (PIT). 11. Interfacing and Programming the 8259A Programmable Interrupt Controller (PIC).
LAB Objectives
The aim of this LAB experiment is to familiarize students with the techniques required to design and simulate digital circuits using Proteus Virtual System Modeling (VSM) software package. The experiment is design to guide the students through the process of designing, editing and simulating a simple modulo-n counter circuit using the schematic editor ISIS. The LAB covers basic schematic editing topics such as placing and wiring up components, and then moves on to circuit testing using virtual modeling and simulation.
Schematic Entry
Proteus VSM uses ISIS schematic capture software to provide the environment for design entry and development. The ISIS software combines ease of use with powerful editing tools. It is capable of supporting schematic capture for both simulation and PCB design. Designs entered in to Proteus VSM for testing can be net-listed for PCB layout either with Proteus PCB Design products or with third party PCB layout tools. ISIS also provides a very high degree of control over the drawing appearance, in terms of line widths, ll styles, fonts, etc. These capabilities are used to provide the graphics necessary for circuit animation.
Circuit Simulation
The Proteus VSM includes the ProSPICE which is an established product that combines uses a SPICE3f5 analogue simulator kernel with a fast event-driven digital simulator to provide seamless mixed-mode simulation. The use of a SPICE kernel allows the designer to utilize any of the numerous manufacturer-supplied SPICE models now available and around 6000 of these are included with the package. Proteus VSM includes a number of virtual instruments including an Oscilloscope, Logic Analyzer, Function Generator, Pattern Generator, Counter Timer and Virtual Terminal as well as simple voltmeters and ammeters. The Advanced Simulation Option allows the designer to take detailed measurements on graphs, or perform other analysis types such as frequency, distortion, noise or sweep analyses of analogue circuits. This option also includes Conformance Analysis - a unique and powerful tool for Software Quality Assurance.
step the code, he can observe the eect on the entire design - including all the electronics external to the micro-controller.
Diagnostic Messaging
Proteus is equipped with comprehensive diagnostic or trace messaging. This allows the designer to specify which components or processor peripherals that are of interest at any given time and receive detailed textual reporting of all activity and system interaction. This is invaluable as a debugging aid, allowing the designer to locate and x problems in both software and hardware much faster than he could when working on a physical prototype.
Editing Modes
The ISIS provide several editing tools (or modes) to facilitate schematic editing. These tools can be selected from the left bar menu. Figure 1.3 list the editing tools and their corresponding icons for your reference during this experiment.
Zooming
There are several ways to zoom in and out of areas of the schematic : Point the mouse where you want to zoom in and out of and roll the middle mouse button (roll forwards to zoom in and backwards to zoom out).
Figure 1.2 ISIS schematic capture window. (1) Editing Window, (2) Object Selector, and (3) Overview Window.
Point the mouse where you want to zoom in or out of and and press the F6 or F7 keys respectively. Hold the SHIFT key down and drag out a box with the left mouse button around the area you want to zoom in to. We call this Shift Zoom Use the Zoom In, Zoom Out, Zoom All or Zoom Area icons on the toolbar (See Figure 1.4).
input M R such that the counter is cleared when the count reaches 5 (Q3 Q2 Q1 Q0 = 0101). Note that, the binary value 0101 can be distinguished from lower binary counts (0000, 0001, 0010, 0011, 0100) by the values of Q2 and Q0 together. Thus, as shown in Figure 1.6, the asynchronous reset input of the counter is connected to Q2 Q0 .
Exercise 1.1 List the binary counts for a modulo-3 counter and show how to gate the outputs of the 4-bit binary counter to implement this modulo counter. Repeat the exercise for modulo-4, modulo-6, and modulo-7 counters.
CLK 1
COUNTER4
CLK Q0 Q1 Q2 Q3 3 4 5 6 Q0 Q1 Q2 Q3
MR 74LS393
AND2
1 3 2 74LS08
The rst thing we need to do is to get the components from the libraries that we need in our schematic.
(a)
(b)
(c)
Figure 1.8 Selecting Components. (a) library menu, (b) parts button, (c) place
menu.
Either one of these three methods will cause the Device Library Browser dialogue form to appear (See Figure 1.9). For reference, the following is a list of all the components we will need for our design : 74LS393 74LS08 MINRES100R LED-RED
There are several ways in which we can nd and import components from the libraries into the schematic : You can enter a device name "74LS393" directly into into the Keywords eld on the Device Library Browser dialogue form. You can search for a device type such as "resistor" in the library browser. You can search for a device by selecting a device category such as "TTL 74LS series" from the Category List Box.
To place the clock generator, choose the Generator Mode from the left menu bar and then select DCLOCK from the Generators list box as shown in Figure 1.10(a). Similarly, you can place the ground terminal by choosing the Terminals Mode and then select GROUND from the Terminals list box as shown in Figure 1.10(b).
10
(a)
(b)
Figure 1.10 Placing components using Editing Modes. (a) clock generator, (b)
ground terminal.
data sheet, PCB layout, etc. As an example, consider the Properties window of the resistance "R3" in the modulo-5 counter schematic as shown in Figure 1.11. In this window, you can modify the resistance name, value, model type, or PCB package.
Exercise 1.3 Check the properties of the components you have placed in Exercise 1.2 and modify their names according to Figure 1.7.
Wiring Up
There are three main techniques used to make wiring a circuit : 1. Modeless Wiring : there is no "wiring mode" in ISIS - wires can be placed and edited at any time, without the need of entering a dedicated wiring mode prior to placement. 2. Follow-Me Wire Auto-routing : after starting to place a wire, the proposed route of the wire will follow the movement of the mouse orthogonally to the termination point of the wire.
11
3. Live Cursor Display : the cursor will change as a visual indicator when wiring to show when a wire can be placed, when a wire can be terminated and when a wire is being placed. The basic procedure for placing a wire between two pins is given below : Move the mouse over the rst pin to be connected - the cursor will change to a green pen as shown in Figure(a). Left click the mouse and then move it until it is over the second pin to be connected. The wire will follow the mouse and the cursor / pen is white during wiring as shown in Figure(b). Left click the mouse again to commit the connection and place the wire as shown in Figure(c).
(a)
(c)
The procedure for wiring onto an existing wire is almost identical but there are a couple of items to note : You cannot directly start a connection from an arbitrary point on a wire. When you terminate the connection on another wire a junction dot will be placed automatically to complete the connection as shown in Figure.
Exercise 1.4 Referring to Figure 1.7, wire up the components you have placed in Exercise 1.2.
12
by labeling a terminal is making a connection to a terminal with the same name without placing a physical wire between the two objects.
Figure 1.14 Modied schematic of the modulo-5 counter using terminals for
connection.
The Power and Ground terminals are the special type of terminals. Although there is no reason not to label them ; an unlabelled power terminal is assigned to the VCC net and an unnamed ground terminal will be assigned to net GND. You can insert a terminal into the drawing area by choosing Terminal Mode then selecting DEFAULT from the Terminals list box as shown in Figure 1.15. You change the orientation of the terminal using the rotate and mirror buttons from the left bar menu.
To change the terminal name, double click on the terminal point and enter an appropriate name in the "Edit Terminal Label Window" as shown Figure 1.16.
13
Exercise 1.5 Referring to Figure 1.14, modify your schematic for modulo-5 counter replacing direct connections with terminals and labeling them appropriately.
Power Connections
ISIS supports a powerful scheme for making power connections implicitly, thus vastly reducing the number of wires on the schematic. Almost all relevant components in ISIS have their power pins hidden (not visible on the schematic). It is important to remember that in such cases the name of the power and ground pins are set to VCC and GND by default. To change these default values, you can use the component Properties Window as shown in Figure 1.17.
14
You have full control over the position and visibility of component labels - you can change the values, move the position or hide information that you feel is unnecessary. The discussion below details how to manipulate component labels on a per component basis. If you zoom in on any resistor you have placed you will see that ISIS has labeled it with a unique Reference (e.g. R1) and also with a Value (e.g. 100). You can edit both these elds and their visibility via the Edit Component dialogue form. You can launch this dialogue form by double clicking the left mouse button over the resistor (or using one of the alternative methods discussed previously). From the resulting dialogue form you can edit both the component reference name and its value (in this case, the resistance). You can also, show or hide these two properties as highlighted in Figure 1.18.
Block Editing
ISIS editor allows you to copy, move, rotate or delete a group (block) of selected components. This action is called block editing which can be performed by rst drag a box around the required group of components (e.g. devices and wires), and then applying the required editing from Block Editing menu as shown in Figure 1.19.
15
to reect the modulo-5 count. You can check the Simulation Log by double clicking on the Simulation Log Status to right of the simulation buttons as shown in Figure 1.21. The Simulation Log window displays compilation status and errors.
For demonstration purpose, lets change the power pin name from the default value VCC to another name say "V" as illustrated in Figure 1.22.
When we run the simulation again, the compiler displays an error on the Simulation Log as shown in Figure 1.23.
Exercise 1.6 Referring to Figure 1.14, modify the design of the modulo-5 counter into modulo-3 counter and simulate the resulting counter.
16
LAB Objectives
The this LAB experiment builds on the previous experiment to introduce more advance topics in schematic editing and system simulation using using Proteus Virtual System Modeling (VSM). The experiment is design to guide the students through the process of designing, editing and simulating a frequency-divider circuit based on the modulo-n counter designed in the previous experiment. The LAB covers more advance schematic editing and simulation topics such as multiple design sheets and virtual instruments.
18
fout = fin/n = 8/4 = 2kHz, Tout = 1/fout = 0.5 x 10-3 seconds fout = 2 kHz Tout
Figure 2.1 The output of a frequency divider with fin = 8kHz and n = 4.
60% 40%
19
0 fin
fx
fy
fout
Figure 2.3 Timing diagram of a frequency divider by 5 with 50% duty cycle.
3. Connect the clock inputs of the two ip-ops as follows : (a) CLKx = fin (b) CLKy = f in 4. Exclusive-OR the outputs of the two ip-ops (fx and fy ) to generate the output frequency (i.e. fout = fx fy ).
VCC
NOT
1 2 4
74LS04 3 J CLK K
XOR2
Q 5 1 3 2 6 74LS386 Fout
NOR3 MOD_5_COUNTER
Q0 Fin 5 CLK Q2 Q3 Q1 1 2 1 2 13 74LS27 12
1 2
S 4
X
74LS113
3 4 3
J CLK K
AND2
MOD5CNTR 1 3 2 74LS08
1 2
Y
74LS113
Exercise 2.1 Show how to design a frequency divider by 3 with 50% duty cycle using modulo-3 binary counter and two JK ip-ops. Repeat the exercise for frequency divider by 4, 6 and 7.
20
methodology and we have arranged our tutorial design into two sheets in order to cover the relevant procedures. The work we have done so far to design the modulo-5 counter has been to complete the rst sheet. The second part of our design (i.e. designing the logic for the two reference clocks) will be done on a separate sheet.
Next we will enter the reference clocks circuit shown in Figure 2.6 into the new design sheet. Note that in order to connect two terminals in two separate design sheets, you need to assign the same name to both terminals.
21
Now, we run the simulation and observe the input and output frequencies on the oscilloscope as shown in Figure 2.8. If the oscilloscope window does not pop-up when you run the simulation, then you need to open it manually by right clicking on the oscilloscope component and then select "Digital Oscilloscope".
Figure 2.8 Comparing the input and output frequencies of the frequency divider using the oscilloscope.
We will refer to Figure 2.9 to illustrate the usage of the oscilloscope. This oscilloscope consists of three main parts : (1) input channels, (2) display scree and (3) control panels.
22
The considered oscilloscope has four input channels labeled A, B , C and D as shown in Figure 2.6. You can trace a given signal by connecting its terminal (or wire) to one of the four channels. The trace signals connected to the input channels of the oscilloscope will be displayed on the screen. The x-axis of the screen represents time, while the y-axis represents voltage. The control panels consist of a trigger control, horizontal control and channel control (one for each channel). The trigger control panel, as illustrated in Figure 2.10, provides the user with the following control functions : Change the position the horizontal reference line. Specify signal display type : analog (AC ) or digital (DC ). Complement the input signals display. Enable/disable continuous tracing of input signals. Enable/disable one-shot tracing of input signals. This option works for periodical signals only, and it will freeze the display so the user can perform any required analysis for the input signal. Enable/disable cursors. When this control is enabled, a cursor can be inserted by clicking on any place on the display screen. When a cursor is inserted it will display the time measure between the vertical reference line and the inserted cursor. Focus the display by selecting the main source of input channels. This is useful when displaying signals with large dierence in their frequencies which my distort the display. The horizontal control panel, as illustrated in Figure 2.11, provides the user with the following control functions : Change the position of the signal trace on the x-axis.
23
Position the horizontal reference line Change signal display from analog to digital and vise versa Complement signal Enable/disable continuous tracing of input signals Enable/disable one shot tracing of input signals (for periodical signals) Enable/disable cursors Select main input channel
Change time division scale which allows the user to zoom-in or zoom-out on the x-axis.
Change the position of the signal trace on the x-axis Change time division scale
The channel control panel, as illustrated in Figure 2.12, provides the user with the following control functions for the specied channel (A, B , C or D) : Change the position of the signal trace on the y-axis Change the type of signal display : analog (AC), digital (CD), ground (GND) or turn the signal o (OFF). Complement the signal trace. Combine two signals (A + B or C + D) in one signal trace by adding their amplitudes. Change voltage division scale which allows the user to zoom-in or zoom-out on the y-axis.
Exercise 2.2 Referring to Figure 2.6, complete the reference clocks circuit on the new design sheet, run the simulation and with the help of your instructor learn how to utilize the oscilloscope to compare the input and output frequencies.
24
Change the position of the signal trace on the y-axis Change the type of signal display Complement the signal trace Add two signals Change voltage division scale
Objectives
1. Discuss the pin congurations and operations of the 8284A clock generator. 2. Start the rst phase of designing a single-board 8086-based microcomputer system. This phase involves making the basic connections of the 8086 microprocessor in minimum mode and interfacing the 8284A clock generator.
26
1 2 3 4 5 6 7 8 9 8284A
18 17 16 15 14 13 12 11 10
ASYNC
Ready Synchronization Select (ASY N C ) is an active LOW input which denes the synchronization mode of the READY logic. When ASY N C is LOW, two stages of READY synchronization are provided. When ASY N C is left open or HIGH, a single stage of READY synchronization is provided.
READY
READY is an active HIGH output signal which is the synchronized RDY signal input. READY is cleared after the guaranteed hold time to the processor has been met.
X1 and X2
Crystal Inputs (X 1 and X 2) are the pins to which a crystal is attached. The crystal frequency is 3 times the desired processor clock frequency. Note that if the crystal inputs are not used X 1 must be tied to V CC or GN D and X 2 should be left open.
F/C
Frequency/Crystal Select (F/C ) is an input used as a strapping option. When strapped LOW, F/C permits the processors clock to be generated by the crystal. When F/C is strapped HIGH, CLK is generated for the EF I input.
EFI
External Frequency Input (EF I ) is strapped HIGH, CLK is generated from the input frequency appearing on this pin. The input signal is a square wave 3 times the frequency of the desired CLK output.Frequency/Crystal Select (F/C ) is an input used as a strapping
27
option. When strapped LOW, F/C permits the processors clock to be generated by the crystal. When F/C is strapped HIGH, CLK is generated for the EF I input.
CLK
Processor Clock (CLK ) is the clock output used by the processor and all devices which directly connect to the processors local bus. CLK has an output frequency which is 1/3 of the crystal or EF I input frequency and a 1/3 duty cycle.
PCLK
Peripheral Clock (P CLK ) is a peripheral clock signal whose output frequency is 1/2 that of CLK and has a 50% duty cycle.
OSC
Oscilloscope Clock (OSC ) is the output of the internal oscillator circuitry. Its frequency is equal to that of the crystal.
RES
Reset Input (RES ) is an active LOW input signal which is used to generate RESET . The 82C 84A provides a schmitt trigger input so that an RC connection can be used to establish the power-up reset of proper duration.
RESET
RESET is an active HIGH output signal which is used to reset the 80x86 family processors. Its timing characteristics are determined by RES .
CSYNC
Clock Synchronization (CSY N C ) is an active HIGH input signal which allows multiple 8284A chips to be synchronized to provide clocks that are in phase. When CSY N C is HIGH the internal counters are reset. When CSY N C goes LOW the internal counters are allowed to resume counting. CSY N C needs to be externally synchronized to EF I . When using the internal oscillator CSY N C should be hardwired to ground.
28
Clock Generator
The 8284A can derive its basic operating frequency from one of two sources : (1) an external frequency source connected to the EF I pin, and (2) a quartz crystal connected to X 1 and X 2. The control input F/C is used to select one of these sources. The crystal frequency should be selected at three times the required CPU clock. The 8284A generates three clock signals : OSC , CLK and P CLK . The OSC has the same frequency as the crystal (or the external frequency) and can be used to test the clock generator or as and external frequency input to other 8284A chips. The CLK is 1/3 the frequency of the crystal (or the external frequency) with a 33% duty cycle designed to drive the 8086 processor directly. The P CLK is a peripheral clock signal whose output frequency is 1/2 that of the CLK with 50% duty cycle.
RESET Logic
The 8284A generates an active HIGH signal (RESET ) which is used to reset the 8086 microprocessor. This signal must be held high for at least 50s in order to guarantee a correct reset of the microprocessor. This requirement can be achieved using a simple RC circuit as will be explained later in this experiment.
READY Synchronization
The READY signal is used by slow devices (memory or I/O peripherals) to request the processor to extend the bus cycle to allow these device to nish reading/writing from/to the bus. The 8284A generates a READY signal that is synchronized with the CPU clock. For this project, READY synchronization is not required.
29
30
Edit the properties of the capacitor and change the capacitance value to 10F and the initial conditions to IC = 0V as shown in Figure 3.4. Similarly, edit the properties of the resistor and change the resistance value to 10K .
Vc = Vs (1 expt/RC ) Where, Vc is the voltage across the capacitor, Vs is the supply voltage, t is the elapsed time since the application Vs, and RC is the time constant of the RC charging circuit .
(3.1)
Exercise 3.2 Using the RC charging formula, calculate the duration of the reset signal assuming that the minimum high voltage of the 8284A is 2.5V (i.e. Vc = 2.5V ) .
31
32
Double click the title-bar of the Analog Analysis Window to open the Prospice Window as shown in Figure 3.7. Click on the "Add Trace" button and then select the voltage probe signal Vc as illustrated in the gure.
Click on the "Edit Graph" button to open the Edit Transient Graph Window as shown in Figure 3.8. Modify "stop time" to 200ms and uncheck the "initial DC solution" box as illustrated in the gure. To complete the analog analysis click on the "Simulate Graph" button as shown in Figure 3.9. The analog analysis simulation shows that the capacitor charge will reach 2.5V after 69.5ms as illustrated in the gure.
Exercise 3.3 Compare the minimum reset time calculated in Exercise 3.2 with the minimum reset time measured using analog analysis.
33
34
Figure 3.10 Adding CLK and RESET terminals to the 8284A schematic.
Objectives
1. Discuss the minimum mode pin congurations of the 8086 microprocessor. 2. Continue the rst phase of designing a single-board 8086-based microcomputer system by making the basic connections of the 8086 microprocessor in minimum mode.
AD15-AD0
Address/Data Lines (AD15-AD0) are input/output lines constituting the time multiplexed memory/IO address lines (during bus cycle T1 ), and data lines (during bus cycle T2 , T3 , TW , and T4 ).
A19/S6-A16/S3
Address/Status Lines (A19/S 6-A16/S 3) are output lines constituting address and status lines. During T1 , they provide the four most signicant address lines for memory operations.
36
GND AD14 AD13 AD12 AD11 AD10 AD9 AD8 AD7 AD6 AD5 AD4 AD3 AD2 AD1 AD0 NMI INTR CLK GND
1 2 3 4 5 6 7 8 9 10 8086 11 12 13 14 15 16 17 18 19 20
40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 21
VCC AD15 A16/S3 A17/S4 A18/S5 A19/S6 BHE/S7 MN/MX RD HOLD HOLDA WR M/IO DT/R DEN ALE INTA TEST READY RESET
37
During I/O operations these lines are LOW. During memory and I/O operations, status information is available on these lines during T2 , T 3, T W and T 4.
BHE/S7
Bus High Enable/Status (BHE /S 7) is an output signal that is used together with A0 during T1 to enable even byte D7-D0 alone, odd byte D15-D8 alone or both as shown in Table 4.1. The S 7 status information is available during T2 , T3 , and T4 .
Table 4.1 Byte selection in 8086 BHE 0 0 1 1 A0 0 1 0 1 Byte(s) Selected Both bytes (D15-D0 Odd byte (D15-D8) Even byte (D7-D0) None
RD
Read Strobe (RD ) is an active LOW output signal which indicates that the processor is performing a memory or I/O read cycle.
READY
READY is an input signal representing the acknowledgment from the addressed memory or I/O device that it will complete the data transfer. This input is controlled to insert WAIT states into the timing of the microprocessor. If the READY pin is placed at a logic 0, the microprocessor enters into WAIT states and remains idle. If the READY pin is placed at a logic 1, it has no eect on the operation of the microprocessor. The READY signal from memory/IO is synchronized by the 8284A clock generator which will be discussed in the next section.
INTR
Interrupt Request (IN T R) is a level triggered input signal used to request a hardware interrupt. It is sampled during the last clock cycle of each instruction to determine if the processor should enter into an interrupt acknowledge operation. If IN T R is held high when IF = 1, the 8086 enters an interrupt acknowledge cycle (IN T A becomes active) after the current instruction has completed execution.
TEST
T EST input is examined by the "Wait" instruction. If the T EST input is LOW execution continues, otherwise the processor waits in an "Idle" state. This pin is most often connected to the 8087 numeric coprocessor.
38
NMI
Non-Maskable Interrupt N M I is an input signal similar to IN T R except that the N M I interrupt does not check to see if the IF ag bit is a logic 1.
RESET
RESET is an input signal that causes the processor to immediately terminate its present activity and restart. The signal must become a logic 1 no later than four clocks after system power is applied and to be held high for at least 50s.
CLK
Clock (CLK ) is an input signal that provides the basic timing signal to the microprocessor. The clock signal must have a duty cycle of 33% (high for one-third of the clocking period and low for two-thirds) to provide proper internal timing for the 8086.
MN/MX
Minimum/Maximum mode (M N/M X ) input pin selects either minimum mode or maximum mode operation for the microprocessor. If minimum mode is selected, the M N/M X pin must be connected directly to +5.0V .
M/IO
Memory/IO (M /IO) is an output signal used to distinguish a memory access from an I/O access.
WR
Write (W R) is an active LOW output signal used to indicate that the processor is performing a write memory or write I/O cycle, depending on the state of the M /IO signal.
INTA
Interrupt Acknowledge (IN T A) is an active LOW output signal which is generated as a response to the IN T R input pin.
ALE
Address Latch Enable is an output signal used to indicate that the 8086 address/data bus contains address information. This address can be a memory address or an I/O port number.
DT/R
Data Transmit/Receive (DT /R) is an output signal used to indicate that the microprocessor data bus is transmitting (DT /R = 1) or receiving (DT /R = 0) data. This signal is used to enable external data bus buers.
39
DEN
Data Bus Enable (DEN ) is an active low output signal which can be used to activate external data bus buers.
HOLD
HOLD is an active HIGH input signal used to request a direct memory access (DMA). If the HOLD signal is a logic 1, the microprocessor stops executing software and places its address, data, and control bus at the high-impedance state. If the HOLD pin is a logic 0, the microprocessor executes software normally.
HLDA
Hold Acknowledge (HLDA) is an active HIGH signal used to indicate that the 8086 microprocessors have entered the hold state.
Start a new design project and place the 8086 microprocessor component on the Editing Window. Then, make the basic wiring of the 8086 microprocessor as shown in Figure 4.2.
40
Exercise 4.1 Refer to the pin functions of the 8086 microprocessor described in Section 4.1 and the basic connections given in Figure 4.2. Then, complete Table 4.2 indicating what is connected to each one of the listed pins (GN D or V CC ) and the justication of the these connections.
Table 4.2 Basic connections of the 8086 microprocessor (minimum mode) 8086 Pin READY Connection V CC Justication The microcomputer system to be designed is a simple one that does not require using ready logic to request extra extra bus cycles. Therefore, this pin is placed is placed at logic 1, so that it has no eect on the operation of the microprocessor.
41
Figure 4.3 Load program into internal memory of the 8086 model.
42
Figure 4.4 Adding voltage probes to control pins of the 8086 model.
Next, we add voltage probes to the least signicant address/data bus lines AD0 AD7 as follows : 1. Choose Terminal Mode and then select BUS from Terminals List Box as shown in Figure 4.5. 2. Place the BUS terminal on the Edit Window and then connect it to the address/data lines AD[0..15] of the 8086 model as shown in Figure. 3. Double click the BUS terminal to open its properties and enter AD[0..15] into the label text box as shown in Figure 4.7. 4. Add 8 terminals labeled (AD0, AD1, . . . , AD7) and connect them to voltage probes as shown in Figure 4.8. Finally, we add a Digital Analysis Window as shown in Figure 4.9. The Digital Analysis Window is identical to the Analog Analysis Window which we have used in the previous experiment. The only dierence between the two windows is the type of signals they can handle (i.e. digital or analog signals).
43
Figure 4.6 Connecting a bus terminal to the address/data lines of the 8086
model.
44
Figure 4.8 Adding terminals and voltage probes for address/data lines AD0
AD7.
45
Exercise 4.3 Following the the procedure used in Experiment 3 to set the Analog Analysis Window, perform the following step : Add all voltage probes shown in Figure 4.8 to the Digital Analysis Window. Set "stop time" to 1ms. Leave the "initial DC solution" box checked. Run the simulation.
After completing Exercise 4.3 you should get the signal trace shown in Figure 4.10. The active regions of this trace correspond to the bus cycles of one instruction from our program which is the I/O instruction "OUT 22H, AL" as it is the only one accessing the data bus. On the other hand, oating (inactive) regions in the trace correspond to other instructions which are internal to the 8086 model and do not aect the control signals or the data bus.
Figure 4.11 shows 4 bus cycles corresponding to the I/O instruction. As illustrated in this gure, the control signals behave as follows : ALE is active in T 1 of each bus cycle. RD is always oating as the instruction is not reading data from the bus. W R is active LOW from T 2 to T 4 as the instruction is writing data to the bus. M/IO is always active LOW as the instruction is accessing an IO port rather than a memory. Also, it is clear from the gure that the address/data lines (AD7 AD0) are behaving as expected. During T 1 they carry the address of the port which is 22H = 0010_0010 (shown in blue). In T 2 and T 3, they carry data which is 8-bit binary count (shown in green). For the rest of T 4 these lines are oating or high-impedance (shown in red).
46
Bus Cycle T1 CLK ALE RD WR M/IO AD0 AD1 AD2 AD3 AD4 AD5 AD6 AD7
0 1 0 0 1
Bus Cycle T4 T1 T2 T3 T4 T1
Bus Cycle T2 T3 T4 T1
Bus Cycle T2 T3 T4
T2
T3
0 1
0 1
0 1
0 1
0 1
0 1
address
data
float address
data
float address
data
float address
data
float
Objectives
The aim of this LAB experiment is to design the second phase of our microcomputer system by interfacing the 8086 to a fully-demultiplexed and buered bus system.
48
The 74LS 373 octal latch (refer to the data sheet in the Appendix) is a simple leveltriggered D ip-ops with two control lines : Output Control (OC ) and Latch Enable (G). As long as the Latch Enable (G) is high, the outputs of the D ip-ops follow their inputs. When G goes low, the ip-ops latch (save) the input signals. The Output Control line (OC ) can be used to place the eight latches in either a normal logic state (HIGH or LOW logic levels), or a high-impedance state. Figure 5.1 illustrates the 8086 microprocessor and the components required to demultiplex its buses. In this case, three 74LS 373 transparent latches are used to demultiplex the address/data lines AD15 AD0, address/status lines A19/S 6 A16/S 3 and BHE/S 7. These transparent latches become transparent whenever the Address Latch Enable signal (ALE ) becomes a logic 1, passing the inputs to the outputs. After a short time, ALE returns to its logic 0 condition, which causes the latches to latch (save) the inputs at the time of the change to a logic 0. In this case, the A19 A0 and BHE are stored in the three latches yield a separate address bus. These address connections allow the 8086 to address 1M byte of memory space.
Exercise 5.1 Complete the design of the 8086-based microcomputer system form previous experiment by including the fully-demultiplexed bus system shown in Figure 5.1.
49
Bus Buffering
If more than 10 components are attached to any bus pin, then the entire 8086 system must be buered. The demultiplexed pins (i.e. address bus A19 A0 and BHE ) are already buered by the 74LS 373 latches. Thus, we need to buer the data bus D15 D0 and the three control bus signals M/IO, RD and W R. Since the data bus is bi-directional, we need to use bi-directional 3-state buers such as the 74LS 245 Tri-State Octal Bus Transceiver. On the other hand, the control bus signals are uni-directional signals (i.e. originating from the CPU to the peripheral devices). Hence, we need to use uni-directional buers such as the 74LS 244 Octal Buer. The 74LS 245 octal buer (refer to the data sheet in the Appendix) is a bi-directional bus transceiver. The device allows data transmission from the A bus to the B bus or from the B bus to the A bus depending upon the logic level at the direction control (DIR) input. The enable input (G) can be used to disable the device so that the buses are eectively isolated (i.e. on high-impedance state). The 74lS 244 octal buer (refer to the data sheet in the Appendix) is a uni-directional buer. The device allows data transmission from the A bus to the Y . The enable inputs (1G and 2G) can be used to disable the device so that the buses are eectively isolated (i.e. on high-impedance state). The fully buered bus system, as shown in Figure 5.2, uses two types of buers : 74LS 245 and 74LS 244. The 74LS 245 buers are used to buer the data bus D15 D0. These buers are controlled by two control signals form the 8086 : (1) DT /R which controls the direction of the data ow, and (2) DEN which enable/disable the data bus.
Exercise 5.2 Complete the design of the 8086-based microcomputer system form previous experiment by including the fully-demultiplexed and buered bus system shown in Figure 5.2.
50
51
because programs running on the 8086 model do not include DOS functions such as the program termination function. 3. Compile and link the assembly code to generate the executable le. 4. Load the executable le into the internal memory of the 8086 simulation model. 5. Add voltage probes to monitor address, data and control signals as shown in Figure 5.4. Note that a reference clock of 5MHz need to be added because we have access to the internal clock of the 8086 model. 6. Add a digital analysis window and include all signals to be monitored as shown in Figure 5.5. 7. Run the digital analysis simulation.
Program 5.1 A Simple I/O Read Program 01 02 03 04 05 06 07 08 09 12 13 ; assembly code to read one byte from port 72h. .MODEL SMALL .8086 .STACK .CODE .STARTUP IN AL, 72H ENDLESS_LOOP: JMP ENDLESS_LOOP .DATA END
After completing your design according to the previous procedure, you should obtain a timing diagram similar to the one shown in Figure 5.6. This timing diagram shows a complete and correct bus read cycle which reads the value 9CH from port address 72H. The behavior of each monitored signals in this diagram is explained as follows : The ALE signal is active in rst clock cycle T 1.
52
Figure 5.4 Probes to monitor address, data and control signals during an 8086
bus read cycle.
Figure 5.5 Digital analysis window for an 8086 bus read cycle.
53
The DT /R is LOW during T 1 T 4 to set the direction of the data ow from the I/O device to the CPU. The DEN is set LOW during T 2 T 4 to enable the data bus. The port address 72H is latched on the address lines A7 A0 at the end of T 1. The address/data lines AD7 AD0 carry the address during T 1, oat during T 2 and carry the hard-coded input data 9CH during T 3 T 4.
Figure 5.6 Result of the digital analysis of an 8086 bus read cycle.
54
Program 5.2 A Simple I/O Write Program 01 02 03 04 05 06 07 07 08 09 12 13 ; assembly code to output one byte of value 9Ch to port 72h. .MODEL SMALL .8086 .STACK .CODE .STARTUP MOV AL, 9CH OUT 72H, AL ENDLESS_LOOP: JMP ENDLESS_LOOP .DATA END
Figure 5.7 Probes to monitor address, data and control signals during an 8086
bus write cycle.
After completing you design according to the previous procedure, you should obtain a timing diagram similar to the one shown in Figure 5.8. This timing diagram shows a complete bus write cycle which outputs the value 9CH to port address 72H. The behavior of each monitored signals in this diagram is explained as follows : The ALE signal is active in rst clock cycle T 1. The DT /R is HIGH during T 1 T 4 to set the direction of the data ow from the CPU to the I/O device. The DEN is set LOW during T 1 T 4 to enable the data bus. However, this behavior is not correct as the DEN should be set LOW starting from T 2 rather than T 1. This seems to be due to a bug in the 8086 which can be xed using a simple logic similar to the one shown in Figure 5.9. The port address 72H is latched on the address lines A7 A0 at the end of T 1.
55
The data lines D7 D0 should carry only the output data (i.e. 9CH) during T 2 T 4, and oat during T 1. However, due to the bug in the DEN signal, the diagram shows that these lines carry the port address 72H during T 1.
Figure 5.8 Result of the digital analysis of an 8086 bus write cycle.
Exercise 5.3 Adjust your schematic design to x the bug in the DEN signal by adding a new design sheet that includes the logic in Figure 5.9. Run the digital analysis simulation and compare the results with ones obtained before xing the bug.
56
DT/R
DENin
D CLK
2 3
D_FLIP_FLOP
Q 5
AND
AND_2 6
74LS74
OR
DENout
OR_2
Objectives
The aim of this LAB experiment is to design the third phase of our microcomputer system by interfacing the 8086 to a small memory system using SRAM and EPROM memory chips.
58
the second is a 16KB EPROM ending at address FFFFH. The EPROM module is mapped specically to this range in the memory space because, on reset, the 8086 microprocessor begins executing instructions at location FFFF0H. This location is called the boot-strap and typically contains a jump instruction that transfers execution to a location of the ROM where a start-up program is stored. In our design, we will use two 6264 (8KB) SRAM memory chips and two 2764 (8KB) EPROM memory chips. You can refer to the data sheets of these two chips to familiarize yourself of their pin functions.
FFFFFH ROM 16KB FC000H
1MB
Figure 6.1 Mapping of the ROM and RAM modules into the 8086 memory
space.
Exercise 6.1 Based on the design requirements of the memory system discussed above, answer the following questions : 1. How to decode the RD, W R and M/IO signals to generate the following memory and I/O read and write control signals : M EM R, M EM W , IOR and IOW ? 2. How to design the 32KB memory system using full address decoding ? 3. How to design the same memory system using partial address decoding ? 4. Which address decoding approach should we use for our design ? Why ? 5. Which of 8086 address lines are required to address the two modules ? 6. How to distinguish the even and odd banks of the SRAM module ? 7. Is it necessary to distinguish the even and odd banks of the EPROM module ? Why ?
59
RD
IOR
WR
IOW
Figure 6.2 Decoding memory and I/O read and write signals.
60
Address Decoding
In this project, we will consider partial address decoding because our 8086-based microcomputer system uses only a small part of the 1MB memory space. It is only necessary to distinguish two memory modules (i.e. RAM and ROM), and hence, only one address line is needed for address decoding. Figure 6.4 shows that the two modules dier in the 6 most signicant address lines A19 A14. Thus, we can use any one of these address lines to build the address decoder (say A19). This decoder, as shown in Figure 6.5, is simply just a single inverter.
A19 A18 A17 A16 A15 A14 A13 A12 A11 A10 0 RAM 0 1 ROM 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 0 1 0 1 0 1 0 1 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 0 0 0 0 0 0 0 0 0 A9 0 A8 0 A7 0 A6 0 A5 0 A4 0 A3 0 A2 0 A1 0 A0 0
Address Decoding
Address Lines
Figure 6.4 Address decoding of the RAM and ROM memory modules.
RAM_SELECT
A19
ROM_SELECT
The ROM module, on the other hand, does not require any logic to select the even/odd banks. This is because the ROM module allows only read operations which are considered as safe operations. Therefore, both the even and odd banks are enabled during a read operation
61
A0 A19 BHE
RAM_EVEN
RAM_ODD
and 8086 will select the required byte(s) from the data bus. An unneeded byte on the data bus is simply ignored by the processor.
IO7-IO0 A12-A0
IO7-IO0 A12-A0
IO7-IO0 A12-A0
8KB RAM
8KB RAM
8KB ROM
8KB ROM
MEMR MEMW
OE WE CS
OE WE CS
OE CS
OE CS
A0
RAM_EVEN
A19 BHE
A19
ROM_SELECT RAM_ODD
Exercise 6.3 Create a new design sheet with title "Memory System" and draw the schematic of the memory system as shown in Figure 6.8.
62
63
Figure 6.9 Digital analysis congurations required for testing the memory
system.
64
Program 6.1 A Simple Memory Read/Write Program 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 ; assembly code to write one word to memory location at address 0000:0120 ; and read it back. .MODEL SMALL .8086 .STACK .CODE .STARTUP MOV AX, 0 MOV DS, AX MOV BX, 0120H MOV AX, 3B7CH MOV [BX], AX MOV AX, [BX] ENDLESS_LOOP: JMP ENDLESS_LOOP .DATA END
After completing your design according to the previous procedure, you should obtain a timing diagram similar to the one shown in Figure 6.10. This timing diagram shows a memory write cycle to the RAM module followed by a memory read cycle from the RAM module. The behavior of each monitored signals in this diagram is explained as follows : The ALE signal is active in T 1 in the memory write cycle as well as in the memory read cycle. The M/IO signal is active HIGH in both bus cycles which indicates a memory access. The W R signal is active LOW in the rst bus cycle which indicates a memory write cycle. The RD signal is active LOW in the second bus cycle which indicates a memory read cycle. The address 00120H is latched on the address lines A19 A0 at the end of T 1 of each bus cycle. The data lines D15 D0 carry the correct data word 3B7CH in both bus cycles.
65
Figure 6.10 Result of the digital analysis of an 8086 a RAM read and write
cycles.
66
The following procedure can be used to load data into the EPROM chips : 1. Using any text editor, type the data shown below in Intel HEX format and save the le as "rom_data.hex" in the same directory as your design le. :04171000AC7D36EB8B :00000001FF 2. Double click the even EPROM chip to open its properties window and edit the following properties as shown in Figure 6.11 : In Image File text box type the name of the data le "rom_data.hex". In File Base Address text box type the value 0. Note that this property is used to re-map the addresses in the le in order to achieve byte splitting between even and odd chips. Setting this property to 0 assigns even bytes (i.e. bytes 0, 2, . . . , etc.) to this chip. In File Address Shift text box type the value 1. Note that this property is used to shift the addresses in the le by a certain number of bits. In the case of 8086 microprocessor, the address is shifted by 1 bit because A0 is used to distinguish even and odd banks and not used as part of the address lines connected to the memory chip. Click OK button to save these setting. 3. Double click the odd EPROM chip to open its properties window and edit the following properties : In Image File text box type the name of the data le "rom_data.hex". In File Base Address text box type the value 1. Setting this property to 1 assigns odd bytes (i.e. bytes 1, 3, . . . , etc.) to this chip. In File Address Shift text box type the value 1. Click OK button to save these setting. Testing the ROM module involves the following steps : 1. Write an assembly code (see Program 6.2) to read two words from the following memory addresses : FC00 :1710 and FC00 :1712. 2. Compile and link the assembly code to generate the executable le. 3. Load the executable le into the internal memory of the 8086 simulation model. 4. Run the digital analysis simulation. After completing your design according to the previous procedure, you should obtain a timing diagram similar to the one shown in Figure 6.12. This timing diagram shows two memory read cycles from the ROM module. The behavior of each monitored signals in this diagram is explained as follows : The ALE signal is active in T 1 in both memory read cycles. The M/IO signal is active HIGH in both bus cycles which indicates a memory access. The RD signal is active LOW in both bus cycle which indicates two memory read cycles.
67
The address FD710H (F C 00 :1710)is latched on the address lines A19 A0 at the end of T 1 of rst bus cycle. The address FD712H (F C 00 :1712)is latched on the address lines A19 A0 at the end of T 1 of second bus cycle. The data lines D15 D0 carry the correct data words 7DACH and textEB 36H respectively.
Program 6.2 A Simple Memory Read Program 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 ; assembly code to read two words from the following memory addresses: ; FC00:1710 and FC00:1712. .MODEL SMALL .8086 .STACK .CODE .STARTUP MOV AX, 0FC00H MOV DS, AX MOV BX, 1710H MOV AX, [BX+0] MOV AX, [BX+2] ENDLESS_LOOP: JMP ENDLESS_LOOP .DATA END
68
Figure 6.12 Result of the digital analysis of an 8086 a ROM read cycles.
Objectives
The aim of this LAB experiment is to design the fourth phase of our microcomputer system by interfacing the 8086 to a simple 8-bit parallel I/O port using LEDs and Dip-Switches.
Isolated I/O
The most common I/O mapping technique used in the 8086 microprocessor is isolated I/O. This technique uses a separate I/O address space isolated from the memory address space as shown in Figure 7.1. The addresses for isolated I/O devices, called ports, are accessed using only I/O instructions. Also, two separate control signals, I/O Read (IOR) and I/O Write (IOW ), are needed to control access to the I/O space. These tow signals are decoded form M/IO, RD, and W R signals as shown in Figure 7.2.
70
FFFFFH
1MB
1M x 8
FFFFH
64KB
64K x 8
0000H
RD
IOR
WR
IOW
Figure 7.2 Decoding memory and I/O read and write signals.
71
Memory-Mapped I/O
This technique uses the memory address space of the 8086 microprocessor as shown in Figure 7.3. It uses any instruction that transfer data between the microprocessor and the memory. A memory-mapped I/O device is treated as a memory location in the memory map. The IOR and IOW control signals are not required in memory-mapped I/O system which will reduce the amount of circuitry required for decoding. However, the disadvantage of this technique is that a portion of the memory system is used for I/O mapping.
Memory + I/O FFFFFH
I/O
1MB
72
Input Port
The 8-bits input port can be designed using a simple circuit as shown in Figure 7.4. The design consists of the following parts : 1. 8-dip switches (DIPSW_8) which will be used to read 8-bits on parallel through the data bus of the 8086 microprocessor. Note that it is our choice to connect the I/O port to either the odd byte (D15 D8) or the even byte (D7 D0). If the I/O port is connected to D15 D8, then odd dummy addresses must be used with I/O instructions accessing this port. Otherwise even dummy addresses must be used. 2. 8 1K resistors. 3. A 74LS 244 octal 3-state buer which is used for two purposes : (1) to buer the I/O data and (2) to enable the I/O data during I/O read operation and disable it otherwise. The input port is enabled by the IOR signal which is connected to the Output Enable (OE ) pins of the octal buer.
73
Output Port
The 8-bits output port can be designed using a simple circuit as shown in Figure 7.5. The design consists of the following parts : 1. 8 LEDs (LED-RED) which will be used to display an 8-bit output byte on parallel. 2. A 74LS 373 octal latch which will be used to store the output data and supply it continuously to the LEDs. The latch is enabled to pass its input to the LEDs only when the CPU is writing to the output port (i.e. I/O write cycle). This functionality is achieved by connecting the complement of the IOW signal to the Latch Enable (LE ) pin of the 74LS 373 chip.
Exercise 7.1 Open the microcomputer system design built throughout the previous experiments, and create a new design sheet with title "I/O Ports". In the newly created design sheet, draw the schematic of the I/O ports shown in Figures 7.4 and 7.5.
74
Exercise 7.2 While the simulation is running, try to input any 8-bit binary value on the dip-switches and see if it get displayed on the LEDs.
Appendix
This appendix contains the following data sheets : 1. 8086 16-Bit HMOS Microprocessor 2. 8284A CMOS Clock Generator 3. 74LS 373 3-State Octal D-Type Transparent Latches 4. 74LS 245 3-State Octal Bus Transceiver 5. 74LS 244 3-State Octal Buer 6. 6264 8K 8 Static RAM 7. 2764 8K 8 EPROM 8. 8255A Programmable Peripheral Interface 9. 8253 Programmable Interval Timer 10. 8259A Programmable Interrupt Controller