Академический Документы
Профессиональный Документы
Культура Документы
Cairo University
Faculty of Engineering,
Computer Engineering Department,
2nd Year.
Lab Manual
(1st Term)
Contents:
General Guidelines
Lab 1: ALU design
Lab 2: Traffic Light Controller
Lab 3: Serial Communications
General Guidelines
a. Title Page
The title page should be the first page of the report and must include the following
information.
Cairo University
Computer Engineering Department
Experiment # ??
Experiment Title
NAME: Date: ?
Section: ?
b. Validation Sheet
A validation sheet is a page where you write the summary of your results or
observations,... etc. and then you get a teaching assistant to sign it for you verifying your
statements.
Insert the validation sheet into the report immediately after the title page.
d. Program Listing(s)
The report should include the listing file for the program(s). Organize the listing file
using comments and assembler directives. Print the listing in a neat manner, especially
avoid unnecessary line breaks. Separate the printer output and insert the pages in the
report following the main body of the report.
e. Comment Sheet
Please take time to submit a comment sheet and attach it as the last page of the report.
Your comments will be used to improve the project assignments, laboratory equipment,
etc. Your input is valuable and greatly appreciated.
Documentation Guidelines
In addition to the text of your report, your design must be documented by schematic
diagrams, pseudo-code, and listing file. Good documentation that can be easily
understood by others, is neat and well organized, and conveys all necessary information
in a complete, yet concise, manner. Some specific guidelines for schematic diagrams and
pseudo-code are given below.
1. Schematic Diagrams
2 Pseudo-code
A few rules for pseudo-code are listed below.
1. Use high-level, meaningful terms for functions and variables. Do not use actual
microprocessor instructions or register references.
2. Do not substitute a paragraph description for pseudo-code.
3. Use assignment statements, subroutine calls, macro names, and control structures
such as “if-then-else" or “do-while.”
4. Use more than one level when necessary. For example, write pseudo-code for the
main program that specifies subroutines by name, and then write pseudo-code for
each subroutine.
5. Organize pseudo-code by using indentation and spacing.
Lab 1
ALU Design
Objectives
-Introducing one of the basic computer components, ALU.
-Reviewing combinational circuit design.
-Practicing the use of design simulators (Altera-Max Plus 2 or Quartus II).
The circuit accepts two 4-bit data inputs (A and B). Depending on the operation, it
generates an output F. The mode select input S2 distinguishes between arithmetic and
logic operations. The two function-select inputs S1 and S0 specify a particular arithmetic
or logic operation to be generated at the output lines. With three selection lines, it is
possible to specify four arithmetic operations and four logic operations. The input and
output carries have meaning only during arithmetic operations.
Operation Outpu
Select Function
S2 S1 S0 Cin F
0 0 0 0 A Transfer A
0 0 0 1 A+1 Increment A
0 0 1 0 A+B Addition
0 0 1 1 A+B+1 Add with carry
0 1 0 0 A+B` A plus B’s one’s complement
0 1 0 1 A+B`+1 Subtraction
0 1 1 0 A-1 Decrement A
0 1 1 1 A Transfer A
1 0 0 0 A AND B AND
1 0 1 0 A OR B OR
1 1 0 0 A XOR B XOR
1 1 1 0 A` Complement A
Notice how the input carry Cin is used as a fourth selection variable for arithmetic
operations. In this way the arithmetic operations are doubled from four to eight.
Ci Ci+1
Ai
B One stage of
i
arithmetic
circuit
0 MUX
Fi
1
Select
S0
One stage of
S1 logic circuit
S2
As shown, one stage of arithmetic circuit is combined with that of logic circuit to
produce one stage of ALU. Selection lines S1 and S0 can be common between both
circuits provided that the third selection S2 is used to differentiate between the two. As
shown in figure 2, the outputs of the arithmetic and logic circuits in each stage are
applied to a 2x1 multiplexer with selection line S2. When S2 is 0, the arithmetic output is
selected, and when S2 is 1, the logic output is selected. The figure shows just one stage of
the ALU. This circuit must be repeated n times for an n-bit ALU.
1- Start by drawing a block diagram for the circuit identifying inputs and output.
2- Simplify your design problem into a set of simpler design problems. This is
done by dividing your design into its basic components. Draw each component
showing its inputs and outputs.
3- Repeat step 2 recursively until you reach a component that can be
implemented directly giving the available material.
4- For each component defined in step 3,
Draw the circuit logic diagram.
Find out the types and the number of ICs required.
5- Implementation issue: A good design is the one with min. number of ICs
(not min. number of gates). Try to minimize the number of ICs required for your
design.
Design Problem
Requirements:
Use a design simulator to design a 4-bit Arithmetic Logic Unit that accepts 2 4-bit inputs,
A and B, 4 control signals, s3s2s1s0, and carry in, ci, and produce a 4-bit output, F, and
carry out, co, (when appropriate), such that F could be one of the following 15 outputs
depending on the control signals.
Output F Operation
0 Clear
A+1 Increment
A+B Add
A+B+ci Add with carry
A+B`+ci Sub with borrow
A+B`+1 Sub
A-1 Decrement
A Transfer
A∧B AND
A∨B OR
A⊕B XOR
A` Complement
Shr A Shift right A
Shl A Shift left A
AL*BL Multiply lower nibbles
Available Material:
Available ICs: 1-bit Binary Adder, 4-to-1 MUX, 2-to-1 MUX, 2-input (AND, OR,
NAND and XOR) gates and Inverters.
Note: Best grade for min. Number of ICs (not min. number of gates).
By the way, a typical ALU chip is the 74181 which is capable of performing several
arithmetic and logic functions. The 74181 has five function selection inputs M, S3, S2,
S1, and S0 and a “carry” input to calculate the outputs.
Lab 2
Traffic Light Controller
Objective: N
- Design, Build, and Test a traffic light controller.
W E
Requirements:
Design, build, and test a hardware circuit for a traffic light controller. S
System Description:
There are four sensors embedded in the roadway (North (N) sensor, South (S) sensor,
East (E) sensor, and West (W) sensor). Data switches may be used to implement the
sensors.
When a car has been detected waiting at a red light, the counter should count 12 pulses
before it turns the green light of the other direction to yellow. The yellow light should
remain on for 4 pulses and then turn red, simultaneously turning the red light on the other
road to green.
Since N/S Red is the complement of E/W Red, a flip-flop can be used to give the reds.
The flip-flop toggles every 16 seconds. Once a mod sixteen counter has been connected
to a flip-flop, the only additions are a few gates to indicate when the yellow and green
lights are ON. For example, N/S Yellow is ON whenever E/W Red is ON and the count
is between 12 and 15. It can be assumed that the green light is a particular direction is ON
when the red and yellow light of the direction is not ON.
If a vehicle stops at a red light makes a right turn, the counter should stop (provided no
yellow light is ON). To cause the counting to continue, another vehicle must stop at a red
light.
Some of the information given below may appear obvious but in the design process it is
always useful to have all facts stated explicitly.
5) If any yellow light is ON, the count continues even if there are no cars waiting.
6) Use six LEDs to represent N/S red, N/S yellow, N/S green, E/W red, E/W yellow,
E/W green.
7) Since the counter chip (7493) has no “stop count” position the starting and
stopping of the counter is achieved by turning on or off the clock as and when
needed.
Points of guidance
1- Start by drawing a block for the circuit showing its main components.
2- Use clock of frequency 1 Hz for the counter.
3- Use switches to simulate sensors. Only 2 switches are required; one for N/S
direction, and one for E/W direction.
4- Read the design description then write down the logic equations for:
a. The counter enable conditions.
b. The flip-flop toggle conditions.
c. The output LEDs of the circuit; N/S red, N/S yellow, N/S green, E/W red,
E/W yellow, E/W green.
5- Given the available material, design a logic circuit for each of the above
equations.
Available Material
- Digital-Analog Training System.
- 4-bit Counter (7493)
- JK flip flop (7476)
- 2-input (AND, OR, NAND and NOR) gates and Inverters.
Lab 3
Serial Communications
Objective:
- To be familiar with PC serial ports.
Requirement:
Connect two PCs directly through their serial port and write a program that splits the
screen into two halves. The upper half displays what is being typed on the PC and the
lower half displays what is being typed on the other PC.
Guide Lines:
1. Take care when you are constructing your cable connection that both computers are
DTEs so you need switch pin 2 and 3.
2. The program may contain two main procedures. One procedure for initializing the
UART and the other procedure should detect any pressed keys and transmit it serially
as well as detecting any received characters on the serial port.
Lab 3 – 11/12
Microprocessor Based Systems Lab Manual
c. The second procedure should detect any pressed keys and transmit it serially
as well as detecting any received characters on the serial port.
i. If a key is pressed then a character is in the keyboard buffer (use the
BIOS function Int 16h/AH=01h to check if a character is available in
the keyboard buffer) then read it and display it in the upper half of the
screen and send it to the UART using an Out instruction. If a character
is present you could read it using Int16h/AH=00h, then display it at
any place on the screen. Use the BIOS functions Int10h/AH=2 to set
the cursor position to the upper half of the screen then use
Int10h/AH=9 to display the character on the screen at the preset cursor
position.
ii. If a character is in the UART RDR (Receiver Data Register) then read
it (using an In instruction) and display it in the lower half of the
screen. You can check if a character is available in the UART RDR by
reading the LSR (Line Status Register) using direct IN access from the
UART RDR I/O Port, or by using the BIOS function Int14h/AH=3
which returns the LSR in AH. After reading the LSR check the Least
Significant Bit. If it is high then a new byte is received in the RDR and
is waiting to be read, otherwise the RDR is empty. You could read the
RDR character using the BIOS function Int14h/AH=02h or by direct
Input from the appropriate I/O port for the RDR. Finally use
Int10/AH=2 to set the cursor position to the lower half of the screen,
then use Int10/AH=9 to display the character at this position.
iii. You scroll the upper and lower half of the screen independently.
Int10h can be used for that also.
iv. The above steps should be repeated until one of the users presses the
ESC key. (The ASCII for ESC=27).
Lab 3 – 12/12