ALU ROM Lab Manual

advertisement
Computer Organization and Design
Lab Experiment: USING ROM, ALU, RAM, Register File
Muhammad Jahangir Ikram
TASK 1: Study of Programming and use of Read Only Memory (ROM)
A. Objectives:
Objectives of this task are:
1. How to program a UV-ROM
2. How to write a particular data onto ROM (indefinitely or until you erase)
3. Use of Address Bus and Data Bus to read values from ROM.
A.1 Programming a ROM
DATA is written into ROM using a special EPROM Programmer. The DATA list (in
bytes) to be written are provided to the programmer and programmer writes that data
to ROM, byte by byte from starting address (000000) onwards using ROM’s Address
Bus, Data Bus and a special programming Pin (GVPP). A high voltage (21 volts) is
required on this pin. Once programmed, data stays ‘forever!’. The figure shows the
symbol and pin configuration of ROM IC M2732A. Although the chip has a capacity
of 4K bytes, we are only writing 16 bytes at the very starting address.
STEP 1. You can program your chip according to the data you want choose. Write 16
bytes you want to write to the chip:
____, _____, _____, _____, ____, _____, _____, _____, ____, _____, _____, ____,
____, _____, _____, _____,
Show these bytes to LAB engineer and he will program the ROM for this data.
STEP 2: In order to check that the data is correctly ‘saved’ on the ROM chip. Insert the
ROM chip in the TESTER board. The IC pins on the ‘TESTER’ board are connected as
follows.
1. Address lines A3 – A0 (pins 8, 7, 6, 5 of IC) are connected to switches B3 –
B0.
2. Address lines A4 – A12 are connected to ground. (Remember we are only
reading/writing first 16 bytes.
STEP 3: By changing the switches B3 – B0 change address from 0 to 16 and write the
bytes that are output by the chip on the Data Bus. Data Bus is connected to LEDs to see
data output by the chip.
____, _____, _____, _____, ____, _____, _____, _____, ____, _____, _____, ____, ____, _____, _____, _____,
STEP 4: Verify values in step 3 and 1. Are they same ? YAS/NO
Exercise: 1. What is the size of this ROM in terms of total number of bits? ____________
Exercise: 2. What is the word size (data stored at each location) _______________?
Exercise: 3. What is the address bus size. ________________?
Exercise: 4. How will you make a ROM with same address bus size but word size should be 16-bit. Draw complete circuit
diagram on back of this page. Using Symbol diagram NOT pin configuration. (Hint: You need two such chips)
Exercise:5. What is the purpose of E pin? ___________________________________
Exercise: 6. How will you make a memory double the address space of this memory but same word size. Draw complete
circuit diagram on back of this page. Using Symbol diagram NOT pin configuration. (Hint: Again you need two such chips)
TASK 2
Study of Register File
B.1 Objectives:
1. Understand the configuration of register file containing 8 registers of 8-bit each.
2. Design of register file with two read ports and one write port.
3. Writing data into registers
4. Reading data from registers onto A bus and B bus.
RegWrite
STEP1. The diagram of this register file is presented
here.
Detailed diagram will be explained in the lab.
1. Connect switches to Rd (S2, S1, S0), Rt (B2, B1,
B0), Rs (A2, A1, A0) switches.
2. Use second board and make sure ground is
common.
3. Use B3-B0, A3-A0 to connect DATA IN.
4. Connect Ck to RegWrite
5. Connect power supply.
6. Turn On both Systems
RS2 to
RS0
Rt2 to
Rt0
Register
File
Rd2 to
Rd0
A
8 LEDs
8 LEDs
8X8
B
DATA IN (8 switches)
STEP 2. Writing data on different registers.
1. Make RegWrite LOW.
2. Select register number R0 to R7 using Rd (Destination) switches. (S2, S1, S0). Select some DATA IN say 0xEE.
3. Give a pulse on RegWrite. You should see data written to the register. Verify YES/NO _____.
4. Write some more data items (all different) on different registers and show it to TA.
STEP 3. Reading and Using A and B BUS.
1. Any combination on Rs switches select a particular register and data stored in that register is
output/displayed on A- Bus. Use Rs switches to display R5 on A- BUS.
2. Similarly any combination on Rt switches select a particular register and data stored in that register is
output/displayed on B- Bus. Use Rt switches to display R2 on B- BUS.
Verfiy: ______ (yes/No)
3. Verify that you can read two registers on A and B bus simultaneously at any time by selecting appropriate
Rs and Rt switches.
Verfiy: ______ (yes/No)
Exercise 1: What is meant by the term 2 read ports? _____________________
Exercise 2: Why do we need only one write port? _________________________
Excersie 3: What is difference between Rs Field and Rs Value ? __________ Give Example._____________
Exercise 4: Can the value of Rs and Rt fileds be same? What will be the data on A and B bus _______ from
above values if Rt = Rs = 4.
Exercise 5. Can Rs or Rt and Rd field be same _______________. What happens if that is the case?
_________________
TASK 3: Study of ALU
Objectives:
1. Study of 74181 chip
2. Selection of funct from ALU
3. Logical and Arithmetic Operations
Inputs
S3 S2 S1 S0
L H H L
H L L H
M
Cn
Function
L
L
0
1
A-B
A+B
In this task we will study the use of ALU chip 74181. This is a 4-bit ALU
L L L L
H X
A’, 1’s Comp
that can perform a variety of functions. Functions are selected using select
H L H H X L
A and B
inputs. The figure on the last page shows types and how we can select
H H H L H X
A or B
any function performed by the chip (the function table). Most of these
functions are useless for our purpose. The functions we need from this chip are specified in figure on the right.
Arith/
Logic
A
A
L
L
L
STEP 1. To cascade 2 chips, Cn+4 is connected to Cn of next IC. Note that Cin is controlling the ADD/SUB function. Cin = 0,
IC performs SUB and if Cn = 1 IC performs ADD.
STEP 2. Use switches A3-A0 as 4-bit A input and B3-B0 as 4-bit B input. Use switches S3 to S0 as control inputs. Use
Switches C0 as Cn and CK as M.
STEP 3. Now fill the following table using example function and values and verify them.
A
B
M Cn
Input
Input
(decimal) (decimal)
Function
10
5
A-B
11
3
A+B
11
3
A-B
4
3
A+B
15
5
A-B
8
7
A+B
1011B
X
A’, 1’s Comp
X
A’, 1’s Comp
X
A’, 1’s Comp
1011B
0010B
A and B
1001B
1100B
A and B
0011B
1111B
A and B
1010B
0101B
A or B
1110B
0100B
A or B
1010B
0000B
A or B
Repeat all steps until you fully understand the ALU IC.
Expected Verify
Output
TASK 4. STUDY of RAM
B. Objectives:
Objectives of this task are:
1. How to connect circuit for a
RAM.
2. How to write a particular data
into RAM
3. Use of Address Bus and Data
Bus to read values from RAM.
STEP 1. Connect the two IC
74LS245 and RAM IC as shown
below:
STEP 2: Writing Data to RAM IC.
Now follow the steps as described
below:
1. Make G’ high (switch C0
down). This makes internal
data of RAM at high
impedance.
2. Make W’ high (switch Ck
down). Write data not
enabled. To write data we
must provide address and
data as done below.
3. Enable E’ of 74LS245 (switch S3 up) which is a tri-state buffer L thus connecting (or shortening) DATA In on
switches B3-B0 and A3 – A0 ) to DQ Lines for data input.
4. Select a particular data that you want to write (say 0000 1111).
5. Select Address location you want to write (switches s2 to S0) (say memory location 000000000101 = 5).
6. Apply write pulse by pulsing a LOW on W’ using Ck switch.
7. Congratulations! Your data is written in RAM at location 5.
8. Repeat step 4, 5, 6 and write data to several other location and keep a record below
_______________________________________________________________________
STEP 3. Reading from RAM. This is the time to check if the data we wrote earlier is still in the memory.
1.
2.
3.
4.
Make E’ of 74LS245 LOW (Switch S3 UP). This disconnects RAM from external DATA IN.
Make G’ LOW (Switch C0 UP) this bring RAM in read mode.
Select Address (S2 to S0) and read the data you wrote earlier on LEDs M7 to M0
Verify that data is still stored by changing address input. _____________
__________________________________________________________________________
STEP 5. Turn of the circuit and then on again. Do Not change any switch and keep RAM in Read Mode.
What are the values stored in RAM and why?
______________________________________________________________________________________
#include <REG51.h>
#include <stdio.h>
sbit LED1 = P1^0;
sbit LED2 = P1^1;
sbit sw1 = P1^3;
sbit con_enable =P1^7;
//Jahangir Ikram. April 2007.
// Microcontroller program to program a ROm
// For my records only. COPYRIGHT
char data_out[16] ={0x90,0x90, x02, 0x16, 0x37,
void main (void)
{
int i = 0;
int j = 0;
unsigned char address_counter=0;
con_enable =1;
while (1)
{
if (sw1 == 0)
{
while (address_counter < 17)
{
P3 = address_counter;
P2 = data_out[address_counter];
address_counter = address_counter+1;
LED1 = !LED1;
LED2 = !LED2;
for (j = 0; j<10; j++)// simple delay loop
{
for (i = 0; i<5000; i++);
} //end for J
LED1 = !LED1;
// flip them back
LED2 = !LED2;
con_enable = !con_enable;
or (i = 0; i<6000; i++);
con_enable = !con_enable;
}
} //end of If
} //End of while 1
} //end of main
0x88, 0x79, 0x6A, 0xA0, 0x57, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA};
// flip LEDs
Download