ProductsLogo
LogoStudy Documents
LogoAI Grader
LogoAI Answer
LogoAI Code Checker
LogoPlagiarism Checker
LogoAI Paraphraser
LogoAI Quiz
LogoAI Detector
PricingBlogAbout Us
logo

Desklib - Online Library for Study Material

Verified

Added on  2023/01/19

|9
|2530
|40
AI Summary
Desklib is an online library that provides study material such as solved assignments, essays, dissertations, and more. It offers a wide range of subjects and courses for students to access and enhance their learning.

Contribute Materials

Your contribution can guide someone’s learning journey. Share your documents today.
Document Page
Question 1 (22 marks)
This question tests your understanding of Block 1 Part 1. You must show all of your
working for full marks
a.Many digital systems store the current time as the number of seconds that have
passed since 1 January 1970, using a 32-bit sign-magnitude integer.
o i. Write the binary representation of the largest positive integer that can be
stored as a 32-bit sign-magnitude integer.
2 31 -1
0111 _ 1111_1111_1111_1111 _ 1111_1111_1111
o ii. Show that the largest positive number of seconds that can be stored as a 32-
bit sign-magnitude integer is 2,147,483,647 seconds.
231 -1 = 2,147,483,647 , any number larger than this will need more bits or if
MSB is incremented to 1, it will turn into negative number for signed
magnitude form.
o iii. What is the name given to the problem that would occur should an attempt
be made to store an integer greater than 2,147,483,647 in such a system?
Overflow. When MSB of the Number is set when it should not.
o iv. Show that the problem that you have identified in part iii will occur
sometime in 2038 in such a system.
Time since 1 January 1970 to I Jan 2038 is
= (2038 – 1970) * 365*24*60*60
= 2,144,448,000
So it is expected in year 2038 around Feb 5 , the counter will exceed
maximum value and overflow

Secure Best Marks with AI Grader

Need help grading? Try our AI Grader for instant feedback on your assignments.
Document Page
o v. IBM PC systems count the seconds passed since 1 January 1980 and store
this number of seconds as a 32-bit unsigned integer. In what year will IBM PC
systems encounter a similar problem to the 2038 problem?
For IBM PC it will take double the time of years as it used unsigned
representation for second count. Also it will happen 10 year later than other
systems because its start date is 1980. This means IBM has 68 * 2 + 1980 =
2116 years before overflow of seconds counter.
(9 marks)
b. A computer programmer notices that when she adds 0.110 to 0.110 on her computer,
the result is reported as 0.195312510. However, when she adds 0.12510 to 0.12510 on
the same computer the result is correctly shown as 0.25010.
Explain in a few sentences why the computer gives an imprecise value for the first
calculation but a precise value for the second calculation. You should use mathematical
expressions to illustrate your explanation of what is happening in each case.
The maximum word limit for Question 1(b) is 120 words.
System stores numbers in IEEE floating point format that cannot store all decimal
representations with full resolution.
.110 is stored as 0.100000001490116119384765625 in binary when using nearest accurate
value. This when added twice it gives a value not exactly equal to 0.2
But when storing 0.125, it is stored as exact decimal number and hence when calculations are
performed, correct result is returned.
(7 marks)
c. A car has three controls:
o an accelerator (A)
o a brake (B)
o a cruise control (C)
An embedded system is to be developed to activate a warning light, as follows:
Document Page
If the brake control and the accelerator control are used together the warning light should be
red. The warning light should also be red if the accelerator control is used whilst the cruise
control is activated. In all other cases the warning light is green.
o i. Complete this truth table where a 1 in the result column indicates that the
warning light is red, and a 0 indicates that the warning light is green.
Table 1
1 = Control used
0 = Control not used
Control A Control B Control C
Result (Red warning light = 1
Green warning light = 0)
0 0 0 0
0 0 1 0
0 1 0 0
0 1 1 0
1 0 0 0
1 0 1 1
1 1 0 1
1 1 1 1

o A different warning system is to be used for controls D, E and F. Table 2
shows a truth table indicating whether a red light or a green light should be
activated for this new warning system:
Table 2
1 = Control used
0 = Control not used
Document Page
Control D Control E Control F
Result (Red warning light = 1
Green warning light = 0)
0 0 0 0
0 0 1 0
0 1 0 0
0 1 1 1
1 0 0 0
1 0 1 0
1 1 0 1
1 1 1 0

o ii.Using the method shown in Section 1.3.2, write a logic expression that could
be used to build a logic circuit for the truth table in Table 2. Use D for control
D, E for control E, and F for control F in your logic expression.
F = ~D & E & F | D & E & ~F
(6 marks)
Total 22 marks
Question 2 (25 marks)
This question tests your understanding of Block 1 Part 2.
Design and implement a single program:

Paraphrase This Document

Need a fresh take? Get an instant paraphrase of this document with our AI Paraphraser
Document Page
to produce a simple graphical representation of a set of nested triangles, as shown in
Figure 1. The output should consist of 4 equilateral triangles (equal sides, inside
angles of 60 degrees). The triangles should have sides of length 20, 40, 60 and 80,
respectively. Use a distance of 7 between the bottom horizontal lines of adjacent
triangles.
that, in principle, can produce larger numbers of nested triangles simply by changing
one number that specifies the number of triangles
with the turtle starting at the position that we want to be the bottom left hand corner of
the innermost triangle and the turtle pointing to the right.
a.Produce a top-level decomposition, making use of exactly one loop. At this stage
express your answer in terms of two sub-problems.
(4 marks)
b.Refine your decomposition to give an algorithm, as you include extra detail make
use of a second loop.
(8 marks)
c.Translate your algorithm into Python and run your program to ensure the output
matches Figure 1. You do not need to submit an output. Name your Python
file TM112_TMA01_Q2_OUCU.py, where ‘OUCU’ is your OU computer username,
e.g. abc123. Write your code in this file. Then include the code file in your TMA zip
file. Paste your completed Python code into your solution document as text and state
whether it is successful in producing the required output.
(13 marks)
Question 3 (25 marks)
This question tests your understanding of Block 1 Part 3.
You must show all your working for full marks.
Document Page
a.The speed at which a processor can process instructions can be increased by making
its clock speed higher, or by increasing the amount of L1 cache memory on the
processor chip.
Explain the terms clock speed and L1 cache and briefly discuss how increasing each of them
increases the speed at which instructions can be processed.
Clock is the basic event in the processor that directs all operations in the CPU. The times this
signal changes its value in a second, is called the clock speed. Every time the clock is
toggled, one operation is performed in each unit of the CPU. More the number of such
toggles, more operations are performed in CPU each given second.
L1 cache is fast speed memory available to CPU to fetch data and instructions. If CPU can
get more instructions and data to consume, it can perform better without having to wait for
data or instructions to come from main memory which is much slower compared to cache.
Hence larger cache allows it hold more data and hence more chances of CPU finding the
required data in high speed cache.
The maximum word limit for Question 3(a) is 150 words.
(6 marks)
b.You have the choice of buying two processors:
o Processor 1 has a clock speed of 4.0 GHz with 32 KiB of L1 cache.
o Processor 2 has a clock speed of 2.0 GHz with 64 KiB of L1 cache.
In order to decide which to buy, you decide to estimate the time each processor will take to
process a program with 10,000 RISC instructions. Each RISC instruction takes one clock
pulse to execute once it is in the registers and has a size of 4 bytes.
o i.Show that a program consisting of 10,000 RISC instructions will fit into 64
KiB of L1 cache but will not fit into 32 KiB of L1 cache.
10,000 instructions each taking 4 bytes needs 40,000 bytes. It can be stored in
64 x 1024 L1 (64Kib) cache easily but 32 x 1024 L1(32KiB) cache will fall
short of holding the entire instruction sequence.
o ii.It takes 1 nanosecond (1 x 10-9 s) to move an instruction from L1 cache to
the registers and 9 nanoseconds to move an instruction from L2 cache to the
Document Page
L1 cache. Assume that for Processor 2, all of the instructions can be found in
L1 cache and for Processor 1, all of the instructions that won’t fit in L1 cache
can be found in L2 cache.
How much time is needed to load all 10,000 instructions into the registers for each processor?
Write your answers in seconds, using scientific notation.
Processor 1 will need 40,000 x 1 ns + (40,000-32K) x 9ns = 40000 + 65088 = 105088 ns to
load all instructions into register for execution.
Processor 2 will need 40,000 x 1ns = 40000ns to load all instructions into register.
o iii.For each processor, calculate the time it takes to execute 10,000 RISC
instructions. Write your answers in seconds, using scientific notation.
Processor 1 execution time = 10000 * (1/(4 x 109 )) = 2.5 x 10-6 seconds
Processor 2 execution time = 10000 * (1/(2 x 109 )) = 5.0 x 10-6 seconds
o iv.Using your results from part (ii) and part (iii), for each processor, calculate
the total amount of time to load 10,000 RISC instructors from cache memory
to the registers, and then to execute them.
Total execution time for Processor 1 = 105088 ns + 2.5 x 10-6 seconds
= 107.588 x 10-6 seconds
Total execution time for Processor 2 = 40000 ns + 5.0 x 10-6 seconds
= 45 x 10-6 seconds
You may assume that no data is needed for this test program. in each case you will only need
to calculate the time to move 10,000 instructions into the registers and the time to execute the
10,000 instructions. You will then find the total time for each processor by adding these two
values.
Write your answers in seconds, using scientific notation.
(15 marks)

Secure Best Marks with AI Grader

Need help grading? Try our AI Grader for instant feedback on your assignments.
Document Page
Question 4 (23 marks)
This question tests your understanding of Block 1 Part 4.
A given grocery shop opens on a weekday at 0900 and closes at 1700. On Saturday it opens
at 0900 and closes at 1300. It is closed on Sunday. So, at precisely 9:00 it is open and
precisely 17:00 (or 13:00 on Saturday) it is closed.
You have been asked to provide a program that takes a string 'weekday', 'sat' or 'sun' and a
time, as an integer, between 0 and 23 (including 0 and 23), representing the whole hour
component of a 24-hour time, and reports whether the shop is open or closed.
You are given the following test data and an incomplete and erroneous program. We are only
going to test the program for inputs relating to weekdays (but in practice it should be tested
thoroughly).
Input Expected Output
weekday 7 closed
weekday 8 closed
weekday 9 open
weekday 12 open
weekday 16 open
weekday 17 closed
weekday 18 closed
# Problem: check shop opening times # Input: day – as week, sat, or sun # Input: hour, an
integer from 0 to 23 inclusive day = 'sat' hour = 8 # Output: a string, either 'open' or 'closed' if
day == 'weekday' if hour > 9 and hour > 17 : print('open') else : print('closed') if day == 'sat' :
if hour >= hour 9 and hour < 13 : print('open') else : print('closed') if day == 'sun'
print('closed')
a.
o i.What are the inputs and outputs of this problem and their types?
o ii.What are the admissible values for the inputs?
Document Page
(5 marks)
b.
o i.What are the syntax errors in this program? Consider no other errors at this
point.
o ii.Once they are corrected, which of the above tests would the program still
fail and why?
o iii.Give an explanation for the choice of input values in the test table.
(8 marks)
c.The above program is based on the use of Pattern 4.3. Explain why Pattern
4.4 would be better at expressing the multiple cases. Provide an algorithm for the
above program, that both corrects the errors identified in b ii) and uses Pattern 4.4.
Note that steps 4 (and 4a) and 7 in Pattern 4.4 are optional.
(5 marks)
d.This part of the question involves writing Python code. Name your Python
file TM112_TMA01_Q4_OUCU.py, where ‘OUCU’ is your OU computer username,
e.g. abc123. Write your code in this file. Then include the code file in your TMA zip
file.
Produce code corresponding to your algorithm. Make your code as simple as possible.
Include comments. Use the test table to check your code works. You do not need to submit
test outputs.
Paste your completed Python code into your solution document as text.
(5 marks)Total 23 mark
1 out of 9
[object Object]

Your All-in-One AI-Powered Toolkit for Academic Success.

Available 24*7 on WhatsApp / Email

[object Object]