0% found this document useful (0 votes)
54 views

Lab5_Week5

Uploaded by

thanhnam0810.tnl
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
54 views

Lab5_Week5

Uploaded by

thanhnam0810.tnl
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 7

Faculty of Science, Engineering and Technology

Computer Systems
Week 5
Overview
In this laboratory session we start look at memory, encoders and stacks.
Purpose: To consolidate your knowledge of Memory and Stacks
Task:

Time: This lab is due by the start of your week 6 lab.


Assessment: This lab is worth 1% (up to a maximum of 5%) of your assessment
for this unit, and only if demonstrated to your lab demonstrator in the
week it is due.
Resources: ■ This week's lecture videos

Submission Details
You must submit the following files to Canvas:

A document containing all required work as described below.
Computer Systems Week 5 Laboratory

Instructions

Theory (Memory, Architectures, Interrupts and Stacks)


1. Review the lecture slides on types of memory and provide a short answers to the
following questions (using your own words):
1.1. What is ROM and what is its primary purpose ?
- ROM (Read-Only Memory) is a type of non-volatile memory used to store data that does not change,
even when the system is powered off. Its primary purpose is to store firmware or boot instructions, like the
BIOS in a computer, which is required to start the system and load the operating system.
1.2. What is RAM and how is it different from ROM ?
- RAM (Random Access Memory) is volatile memory, meaning it loses its data when power is turned
off. RAM is used for temporary storage of data that is actively being used or processed by the CPU.
Unlike ROM, RAM can be read from and written to, making it suitable for running applications and
storing temporary files.
1.3. What is the difference between static RAM and dynamics RAM ?
- Static RAM (SRAM): Retains data as long as power is supplied without needing to be refreshed, but is
more expensive and consumes more power. It is faster and typically used for cache memory.
- Dynamic RAM (DRAM): Needs to be periodically refreshed to retain data, but is cheaper and denser,
allowing for more memory in a smaller space. DRAM is typically used for the system's main memory
(RAM).
1.4. What type of memory is typically used in USB thumb drives ? Why
shouldn’t we rely on this for critical data storage ?
- USB drives typically use flash memory, a type of non-volatile memory. It's not ideal for
critical data storage due to limited write cycles and potential for data corruption or physical
damage.
2. Consider a computer with 1GB RAM (1024 MB). Given memory addressing
is for each byte, how many bits are needed to address all bytes in the system’s
RAM ?

- Given 1GB (1024MB) of RAM, and that each byte in memory needs to be addressed:

 1GB = 1024MB = 1024×1024×1024=1,073,741,8241024


 The number of bits required to address all the bytes can be calculated as log_2(1,073,741,824),
which equals 30 bits. Therefore, 30 bits are needed to address all bytes in a 1GB RAM system.

3. Give a brief description of the Von Neumann and Harvard computing


architectures. What are the fundamental differences between the two and for
what is is each designed to achieve ?
 Von Neumann Architecture: This design has a single memory space for both data and instructions,
meaning that the CPU fetches both program instructions and data from the same memory. It is simple
but can create a bottleneck known as the "Von Neumann bottleneck" due to the shared bus for both.
 Harvard Architecture: This architecture separates memory for data and instructions, allowing
simultaneous access to both. This can improve performance, especially in real-time applications, by
eliminating bottlenecks, but it is more complex to implement.

Page 2 of 8
Computer Systems Week 5 Laboratory
- Fundamental difference: Von Neumann uses a single memory for both instructions and
data, while Harvard separates them. Von Neumann is simpler and more common in general-
purpose computers, while Harvard is used in specialized systems like microcontrollers.
4. What is cache memory and what is its primary role ?
Cache memory is a small, high-speed memory located close to the CPU. Its primary role is to store
frequently accessed data and instructions, reducing the time it takes for the CPU to access data from the
slower main memory (RAM). Cache is typically divided into levels (L1, L2, L3), with L1 being the fastest
and closest to the CPU.
5. Explain the concept of an interrupt, and list four common types.
- An interrupt is a signal sent to the CPU by hardware or software indicating that immediate attention is
needed. The CPU stops its current execution, handles the interrupt through an interrupt service routine
(ISR), and then resumes normal processing.

Common types of interrupts:

1. Hardware interrupts: Triggered by hardware devices (e.g., keyboard, mouse).


2. Software interrupts: Triggered by programs when they need to request system resources.
3. Timer interrupts: Generated by system timers to manage multitasking or schedule tasks.
4. I/O interrupts: Generated by input/output devices to signal that data is available to be processed.

5.1. Polling is an alternative to interrupts ? Briefly explain polling and why it


is not com- monly used.
- Polling is an alternative to interrupts where the CPU repeatedly checks (polls) a device or
condition to see if it requires attention. It is inefficient because it wastes CPU cycles while
waiting for events, whereas interrupts only engage the CPU when necessary, which is why
polling is less commonly used.
6. Explain the general concept of a stack - how do they work, and what is their
primary pur- pose.
- A stack is a data structure that operates on a last-in, first-out (LIFO) basis. Data is pushed
onto the stack (added) and popped from the stack (removed) in reverse order. Stacks are
useful for managing temporary data, function calls, and local variables.
6.1. How are stacks useful for handling interrupts ?
- When an interrupt occurs, the CPU pushes the current program counter and state onto the stack before
jumping to the interrupt handler. Once the interrupt is handled, the CPU pops the state and program
counter from the stack to resume its previous task. This allows the system to handle interrupts without
losing track of its current work.
6.2. How are stacks useful in programming ?
- Stacks are essential for managing function calls, recursion, and local variables. When a function is
called, its return address and local variables are pushed onto the stack, and when the function finishes
execution, these are popped off. This ensures that functions execute in the correct order and that their data
is managed properly.

Provide all the answers to the above questions in your submission document.

Practical - Stacks of Stacks !


Page 3 of 8
Computer Systems Week 5 Laboratory
7. Start Logisim and open a new canvas
8. Review the lecture slides on building a stack at the top of this lab sheet. We are
going to build a 5-bit deep, 1-bit wide stack.
9. Start by building a simple shift register that moves bits from one flip flop to the
next each clock pulse. For this you will need a “Data In” pin which sets the
next bit to be pushed to the stack, and a clock to invoke the shifting.

10. For your shift register to work as a stack, it needs to be bi-directional. This
means the in- put to any Flip Flop could come from two places - the left or the
right. In lectures we dis- cussed a simple “encoder” circuit that selects which of
two data inputs is allowed through,

Page 4 of 8
Computer Systems Week 5 Laboratory

based on a third selection bit. Design the logic for this 2-bit encoder, and
demonstrate it to your lab demonstrator.

11. Now incorporate your encoder above to allow bi-directional shifting of your
stack. Your stack should:
11.1. push and pop bits onto and off the stack, using clock pulses and a
direction toggle switch
11.2. show the state of each Flip Flop using LEDs.

Export your circuit as an image and include it in your submission document.


Demon- strate your working stack to your lab demonstrator.

12. Modify your stack so that it has the option to read out its contents in parallel to a
sepa- rate register of D Flip Flops. This should only occur when a “stack dump”
toggle switch (i.e., pin) is enabled. When the toggle is disabled, the register of D
Flip Flops should re- tain the last state read in (and should have LEDs connected
Page 5 of 8
Computer Systems Week 5 Laboratory
to each Flip Flop out showing its state).

Export your circuit as an image and include it in your submission document.


Demon- strate your working stack to your lab demonstrator.

When complete:

Submit your answers (screen shots, etc) in a single document using Canvas

Show your lab demonstrator your working circuits in class (you must do this to
get the 1%). Your lab demonstrator may request you to resubmit if issues exist.

Page 6 of 8

You might also like