Answered step by step
Verified Expert Solution
Link Copied!
Question
1 Approved Answer

What is a branch delay slot and why does it arise? [7 marks] How can branch delays be avoided? If a processor exhibited one branch

What is a branch delay slot and why does it arise? [7 marks] How can branch delays be avoided? If a processor exhibited one branch delay slot how would you reorder (and possibly modify) the instructions in the following loop to gain a performance advantage? ldr r2,r3,#4 % r2=load(r3), r3=r3+4 add r4,r4,r2 % r4=r4+r2 add r1,r1,#1 % r1=r1+1 cmp r1,#10 % compare r1 with constant 10 bne loop % branch if not equal to loop Digital Communication I X A B C D Y Hosts X and Y are communicating through the data network provided by the switches A, B, C and D and the links interconnecting them as shown above. Initially all packets are travelling through switches A, C and D. (a) A packet is corrupted on the link between C and D. Describe the events that take place to recover from the error when (i) an end to end flow and error control protocol is in operation (ii) flow and error control are performed on a hop by hop basis [5 marks] (b) Switch C fails. Describe the events that follow to recover when (i) the network is a datagram network (ii) the network is connection orientedYour answer should cover the use of hierarchies of classes overriding methods interfaces inner classes spatial hierarchy [4 marks each] 4 Compiler Construction Consider the grammar S -> E E -> T + E E -> T T -> x where S is the starting symbol, is a special token marking end of input and x is a terminal. Explain and find the left, right and follow sets for all non-terminals in the grammar. [5 marks] he parsing tables is to create the characteristic finite state machine (sometimes known as the LR(0) states). , explaining your working clearly. You do not need to complete the SLR parsing tables. [10 marks] Now, assuming that the parsing tables have been constructed, show what values will be placed on a stack and comment about internal state while an SLR parser using this grammar processes the input text x+x+x.D A nave Verilog programmer has made two attempts at implementing a RandomBits module. The module is supposed to generate a pseudo-random sequence of bits. module RandomBitsA( rand_bits ); output rand_bits; wire [3:0] shift_reg; wire newbit = ~(shift_reg[3] ^ shift_reg[1] ^ shift_reg[0]); assign shift_reg[3] = shift_reg[2]; assign shift_reg[2] = shift_reg[1]; assign shift_reg[1] = shift_reg[0]; assign shift_reg[0] = newbit; assign rand_bits = newbit; endmodule module RandomBitsB( clk, rand_bits ); input clk; output rand_bits; reg [3:0] shift_reg; wire newbit = ~(shift_reg[3] ^ shift_reg[1] ^ shift_reg[0]); always @(posedge clk) begin shift_reg[3] <= shift_reg[2]; shift_reg[2] <= shift_reg[1]; shift_reg[1] <= shift_reg[0]; shift_reg[0] <= newbit; end assign rand_bits = newbit; endmodule // TestRandom is the top level module module TestRandom( clk, tstA, tstB ); input clk; // input clock output tstA, tstB; // output test bits RandomBitsA randa( tstA ); RandomBitsB randb( clk, tstB ); endmodule (a) In Verilog, what is the difference between continuous assignment and non-blocking assignment? [4 marks] (b) What are the circuit diagrams corresponding to

The quantum teleportation protocol is a means by which one party, Alice, can send a quantum state to another party, Bob, by transmitting just two classical bits, provided that the two already share an entangled 2-qubit state. Explain how the quantum teleportation protocol works, sketching any circuit that may be used. [6 marks] (c) The Deutsch-Jozsa problem assumes that we are given a function f : {0, 1} {0, 1} in the form of a quantum black box performing a unitary operation Uf : |abi 7 |a(b f(a))i. Sketch a circuit with only one use of Uf that determines whether f is constant or balanced. Explain carefully what measurement is performed and why it gives the desired result. [8 marks] 4 CST.2008.9.5 5 Artificial Intelligence II A friend of mine likes to ... [9:30 PM, 4/19/2022] fridahkathambi71: Fortran gives semantic meaning to parentheses, i.e. a+b+c permits compiler re-arrangement whereas (a+b)+c does not. This matters for floating point. However, since Fortran '+' is left associative the above two expressions yield the same parse tree, and we have a contradiction. (d) Two alternatives to conservative garbage collection are liberal garbage collection or new labour style de-allocation. (e) Any type 3 (regular) grammar is also a type 2 (context-free) grammar. Hence any lexer generated by lex (or JLex) could instead be generated by yacc (or Cup). (f ) When a compiler for a language like Java compiles e1+e2, it computes the types of e1 and e2 so that it can treat it as e1+(float)e2 if e1 is of type float and e2 is of type int. (g) A syntax-tree interpreter can fail (give an error) when evaluating a variable name which does not appear in the current environment. Any program which fails using static scoping will fail using dynamic scoping. (h) A syntax-tree interpreter can fail (give an error) when evaluating a variable name which does not appear in the current environment. Any program which fails using dynamic scoping will fail using static scoping. (i) A dynamically-typed language is one in which the type of a value is carried around at run-time; a type error is given at run-time if values are used inappropriately. Such languages must be dynamically linked otherwise type errors will occur. (j) Java .class files and ELF-style .o (or .obj) object files represent similar information, i.e. compiled code, a list of symbols made available to other functions, and a list of undefined symbols which the file expects to be defined elsewhere. [2 marks each] 6 CST.2003.6.7 7 Artificial Intelligence I A simple game works as follows. We have a board divided into n by m square cells. We also have an unlimited number of L-shaped tiles, each made to cover exactly three squares. The tiles can appear in any of the four possible orientations. Our aim is to cover the board completely with non-overlapping tiles. (a) A single tile on the board can be described using a list such as [[1,1],[1,2],[2,1]] containing three tuples, specifying the position of each part of the tile on the board. Consider the following Prolog predicate, which is true if the six variables describe a correct, L-shaped tile. tile([[A,B],[C,D],[E,F]]) :- C is A+1, D is B, E is A, F is B-1; C is A+1, D is B, E is A, F is B+1; C is A-1, D is B, E is A, F is B+1; C is A-1, D is B, E is A, F is B-1. Explain what happens in response to a query of the form tile([[4,5],[B,C],[D,E]]). Keep in mind the effects of backtracking. [2 marks] (b) Write a Prolog predicate goodplace([[A,B],[C,D],[E,F]],[N,M]) that is true if [[A,B],[C,D],[E,F]] is a validly shaped tile and all of its parts lie within an N by M board. Your predicate should behave under backtracking in such a way that the response to a query of the form goodplace([[10,4],[B,C],[D,E]],[10,10]). is to find the unspecified values for all tiles which have a valid shape and fall within the board. In this example there would be two such tiles. [6 marks] (c) Write a Prolog predicate tiling(Available,Solution,Size). Here, Size is the size of the board represented as above, Solution is a list of tiles that solves the problem, and Available is a list of available positions on a board of the given size. For example, if Size is [2,2] then Available is [[1,1],[1,2],[2,1],[2,2]]. Your predicate should be true if the Solution given is a valid one, and should be capable of finding a valid Solution in response to a query such as tiling([[1,1],[1,2],...,[10,10]],X,[10,10]). Full marks will only be given for predicates that can exploit backtracking to find all possible solutions.

Write program that receives a positive integer n from the user and then calculates the sum below by using a loop. Your program needs to ask the user to re-enter a different number if the user enters a non-positive one. a program that asks the user for a positive integer number. If the user enters anything else, the program would ask the user to re-enter a number or enter -1 to quit. If it is a positive number, the program then prints out a multiplication table that goes up to that number.

become a gambling cheat. He has a biased coin with Pr(head) = p and two dice. The first die is biased with Pr(n) = pn for the nth outcome with n {1, 2, 3, 4, 5, 6}. The second die is also biased, and has different numbers: its distribution is Pr(n) = qn with n {4, 5, 6, 7, 8, 9}. Evil Robot flips the coin. If he gets a head then he rolls the first die, otherwise he rolls the second. He then tells you the outcome. You see only the number obtained and nothing else. He does this m times, so you observe a sequence of m numbers in the range 1 to 9. Your aim is to estimate p and the distributions of each die, given the m numbers. In the following, n is the vector of m observed numbers (n1 nm) T , is the set of parameters {p, p1, . . . , p6, q4, . . . , q9} and we define q = 1 p. (a) Write down an expression for the distribution Pr(n|) where n {1, . . . , 9}.

(a) (i) Calculate gcd(144, 77), the greatest common divisor of 144 and 77, as an integer linear combination of 144 and 77. [4 marks] (ii) What is the multiplicative inverse of 77 in Z144 and the multiplicative inverse of 67 in Z77? [2 marks] (iii) Describe all integers x that solve the following two congruences

77 x 1 (mod 144) 67 x 3 (mod 77) Indicate how one may calculate the least natural number solution to the above. [4 marks] Justify your answers. (b) For a string w {1, 2} , let P(w) N denote the sum of all the numbers in it. For instance, P() = 0 for the null string, and P(1212) = 6. For every n N, define Sn =

w {1, 2} | P(w) = n

. In particular, S0 and 1212 S6. (i) List the elements of Sn for each n {0, 1, 2, 3, 4, 5}. [2 marks] (ii) What is the cardinality of Sn for each n N? Prove your claim. [5 marks] (iii) For all m, n N, define a bijective function

(Sm+1 Sn+1) ] (Sm Sn)

Sm+n+2

Explain (a) a technique that you could use to implement a pure functional programming language using applicative order (eager) evaluation; [6 marks] (b) a technique suitable if your implementation must use some form of lazy or normal-order evaluation. [6 marks] Comment on whether the behaviour of your implementation (b) is strictly and exactly the same as normal order evaluation in lambda-calculus. [3 marks] Comment about similarities and differences between your two techniques and any predictions you can make about their relative simplicity, performance or convenience. [5 marks] 11 Complexity Theory (a) For each k, the k-clique problem is defined as the following decision problem: Given a graph G, does it contain a clique with at least k vertices? Show that k-clique is in P for each k. [6 marks] (b) The problem Clique is defined as the following decision problem: Given a graph G and an integer k, does G contain a clique with at least k vertices? Show that Clique is NP-complete, using the assumption that 3-SAT is NP-complete. [10 marks] (c) Explain why, if P=NP then there is a polynomial time algorithm for factorising numbers.

Explain mathematically why this is the case and show how to calculate the location on the screen of the vanishing point for lines in a particular direction. [5 marks] [Hint: It may be helpful to represent lines parametrically in vector form as P(s) = A + sV where V is a direction and A is any point on the line.] 4 Computer Graphics and Image Processing Consider a curve defined by polynomial parametric segments Pi(s) for i = 1, 2, . . . m that interpolates a set of points {Ai}0im in three dimensions. (a) What is meant by Ck continuity at the junction of two segments? [3 marks] (b) What is the least order of the polynomials that must be used to achieve Ck continuity at the junctions? [2 marks] (c) Derive the Overhauser formulation for a set of weighting functions w2(s), w1(s), w0(s) and w1(s) so that the cubic curve segment joining Ai1 and Ai can be expressed as Pi(s) = w2(s)Ai2 + w1(s)Ai1 + w0(s)Ai + w1(s)Ai+1 for 1 < i < m. [10 marks] (d) Extend this formulation to give a set of parametric patches Pi,j (s, t) for 1 < i < m and 1 < j < n interpolating a surface through an array of points {Ai,j}0im,0jn. [5 marks]

A full adder for a single bit has three inputs, a, b and cin, and two outputs, s and cout for the sum and carry-out. State the formulae for s and cout in disjunctive normal form. [2 marks] (b) Explain the operation of the following three approaches for handling carry in n-bit word adders, deriving formulae for the signals involved and explaining the limiting factors on their speed: (i) ripple carry, [2 marks] (ii) carry-skip with fixed-size blocks, and [6 marks] (iii) carry-skip with variable-size blocks. [4 marks] (c) Assuming a delay of for a round of combinational logic consisting of negation, conjunction and disjunction, estimate the delays for the three designs applied to a 48-bit adder. [3 2 marks] 3 Digital Communication II (a) In the context of Quality of Service (QoS) in networking, what do we mean by elastic and inelastic applications? [2 marks] (b) Give two examples of each type of application and discuss the application attributes and QoS requirements. [8 marks] (c) Discuss the problems faced by traditional Internet routers in dealing with inelastic traffic. [6 marks] (d) How do the IntServ and DiffServ architectures differ in offering QoS, and how might they be employed together to provide an end-to-end QoS? [4 marks] 3 (TURN OVER) CST.2008.9.4 4 Quantum Computing (a) The no-cloning theorem is a statement that is often said to show that a quantum state |i cannot be exactly duplicated. (i) Give a mathematically precise statement of the no-cloning theorem. [2 marks] (ii) Give a proof of the no-cloning theorem. [4 marks](i) What perceptual effects would you need to simulate in the tone-mapping operator? [4 marks] (ii) Illustrate a high-level design of such an operator on a diagram showing major processing blocks. Use a similar notation to that used in the lectures: blocks for processing, arrows for data. Describe the processing pipeline succinctly, stating the purpose and output of each processing block. Note that the problem can be solved in many ways and there is no single correct solution. [8 mark

answer the question clearly

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image
Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Practical financial management

Authors: William r. Lasher

5th Edition

0324422636, 978-0324422634

More Books

Students explore these related Programming questions