You are on page 1of 6

# Computer Architecture

## Midterm exam 30 March 2015

Paul Mellies
Exercise 1.
The current-voltage characteristic functions of three resistors A, B and C are de-
picted below.

i ( current )
A
120A
B
100A

80A

60A

40A
C
20A

0A V
0V 1V 2V 3V 4V 5V ( voltage )

1a. Compute for each of them the value of their resistance (in Ohm, noted ).
1b. We recall that when an NMOS transistor is in linear mode, the relationship
between the drain-source current i and the drain-source voltage V is given by the
formula
V
i = K ( VGS VTN ) V
2
where the threshold voltage VTN and the transductance parameter K are two con-
stants depending on the NMOS transistor, and where VGS is the gate-source voltage.
Give an explicit formula describing the resistance of the NMOS transistor at lin-
ear mode and at very low voltage, when V is close to zero and much smaller than
VGS VTN , as a function of K, VGS and VTN .

Exercise 2.
2a. Explain why one applies the following name convention for the three ports of
the NMOS and of the PMOS transistors, and more specifically, why one chooses to
reverse the names source and drain in the NMOS and PMOS transistors.

drain source

gate gate

source drain
NMOS transistor PMOS transistor
2b. Draw the CMOS inverter circuit consisting of an NMOS transistor and of a
PMOS transistor.
2c. Given the current-voltage characteristic functions for an NMOS transistor and
for a PMOS transistor depicted below, draw the voltage-voltage transfer function of
the corresponding CMOS inverter. Note that we take VDD = 5V.

i ( current )

180A 5V

160A
i ( current )
140A

120A 120A
4V
3.5V 100A
100A

80A 80A
3.5V
60A 3V 60A

40A 40A 3V
2.5V
20A 2V
20A 2.5V
1.5V 2V
0A V 0A V
0V 1V 2V 3V 4V 5V ( voltage ) 0V 1V 2V 3V 4V 5V ( voltage )

## NMOS transistor PMOS transistor

with threshold 1 V with threshold 1.5 V

2d. Indicate on the voltage-voltage transfer function of the CMOS inverter for which
states the NMOS and the PMOS transistors are in cut-off, in linear or in saturated
mode.
2e. Indicate (even approximatively) the positions of the two unity gain points of the
inverter. From this, deduce the input low and high voltages VIL and VIH as well as
the output low and high voltages VOL and VOH .
2f. From this, deduce the value of the noise margins NML and NMH for low and high
voltages.
2g. Suppose that the NMOS transistor is replaced by a resistor R with the following
current-voltage characteristic function:

i ( current )

180A

160A

140A

120A

100A

80A

60A

40A

20A

0A V
0V 1V 2V 3V 4V 5V ( voltage )

Resistor
One obtains in this way the following inverter:

V
DD

A PMOS transistor

resistor R

GND

2h. Draw the voltage-voltage transfer function associated to the inverter just con-
structed.
2i. Indicate on the voltage-voltage transfer function of the inverter on which states
the PMOS transistor is in cut-off, in linear or in saturated mode.

Exercise 3.
3a. Draw a ternary NAND gate using a CMOS circuit.
3b. Remember that a minority gate is a logical gate with three inputs A, B, C and
one output Y whose value is 1 precisely when there is a minority of input ports (that
is, zero or one input port, not two or three) whose value is equal to 1. Draw a minority
gate using a CMOS circuit.
3c. Can you draw the minority gate with only 5 NMOS transistors and 5 PMOS
transistors?

Exercise 4.
4. Can you find a simple argument explaining why the zincblende lattice structure
of the Gallium Arsenic

Ga gallium of valence 3

As arsenic of valence 5

is the superposition of two face-centered cubic (fcc) lattice structures of arsenic and
gallium:
fcc lattice of arsenic fcc lattice of gallium

Exercise 5.
Suppose that you bought an old computer at the Baoshan Lu Cybermart in Shanghai,
whose signed and unsigned integer are represented using 8 bits integers.
5a. What are the maximal and minimal unsigned integers which can be represented
as an 8-bits integer of the machine?
5b. What are the maximal and minimal signed integers which can be represented
as an 8-bits integer of the machine?
5c. Suppose that you add (as signed integers) the signed integer 97 to the signed
integer 88 in this old machine. Could you describe what happens?

Now, suppose that you have bought a slightly more recent computer whose signed
and unsigned integer are represented using 16 bits integers.
5d. What are the maximal and minimal unsigned integers which can be represented
as a 16-bits integer of the machine?
5e. What are the maximal and minimal signed integers which can be represented
as a 16-bits integer of the machine?
5f. Suppose you add (as signed integers) the signed integer 97 to the signed integer
88 in this more recent machine. Could you describe what happens?

Exercise 6.
6a. Translate the following decimal numbers into binary numbers:

## 12 180 673 2015 6142

6c. Translate the decimal numbers into signed binary numbers of length 12 bits:

## 1 12 180 673 2015

6d. Explain what one means by sign extension from 16 bits to 32 bits.
Exercise 7.
In all this exercise, we consider the following structure type cell whose purpose is
to represent linked lists of character strings:

struct cell {
char *key;
struct cell *next;
};

7a. A bug is hidden in the code below of the function cons on a linked list of strings,
whose intended purpose is to append a string of characters string to a list list.
Can you detect the bug, explain what bad effect could happen at run time, and sug-
gest how to correct it?

## struct cell *cons(char *string, struct cell *list) {

struct cell *newlist;
newlist=(struct cell *)malloc(sizeof(struct cell *));
newlist->key = strdup(string);
newlist->next = list;
return newlist;
}

7b. A bug is hidden in the code below for the function free_list whose intended
purpose is to deallocate a linked list of strings. Can you find the bug and explain how
to correct it?

## void free_list(struct cell *list){

struct cell *ptr;
while (list != NULL){
ptr = list;
list = list->next;
free(ptr);
}
return;
}

7c. Worse, two bugs are hidden in the code below of the function clone_list whose
intended purpose is to clone a linked list of character strings, that is, produce two
equal but absolutely independent lists list and clone_list(list) in the end.
Can you find the bugs and explain how to correct them?
struct cell *clone_list(struct cell *list){
struct cell *head=(struct cell *)malloc(sizeof(struct cell));
struct cell *newlist=(struct cell *)malloc(sizeof(struct cell));
newlist = head;
while (list != NULL){
newlist->key = list->key;
if (list->next != NULL){
newlist->next = (struct cell *)malloc(sizeof(struct cell));
newlist = newlist->next;
}
else{
newlist->next = NULL;
}
list = list->next;
}
return head;
}

7d. More generally, explain why it makes more sense to think of a linked list as a
pointer to a structure of type cell than (more simply) as a structure of type cell.

Exercise 8.
8a. Explain in a sufficiently detailed way how the following implementation of
getchar works.

## /* getchar: simple buffered version */

int getchar(void){
static char buf[BUFSIZ];
static char *bufp = buf;
static int n = 0;

## if (n == 0){ /* buffer is empty */

n = read(0, buf, sizeof buf);
bufp = buf;
}
return (--n >= 0) ? (unsigned char) *bufp++ : EOF;
}

8b. Explain in particular how to parse the very last instruction of the function, and
what it does exactly.

Exercise 9.
9a. Can you explain (in a few words) the difference between a CISC and a RISC
architecture?
9b. Can you explain (in a few words) the notion of memory leak encountered in
our study of the programming language C ?
9c. Can you explain (in a few words) the difference between a file descriptor in
UNIX and a file pointer in C ?