(3.31) Moved from problem set 2.
If a particular memory has 8 byte addressability and a 4 bit address space,
how many bytes of memory does that computer have?
A[1:0]
and WE
be?A[1:0]
should be 11, to read from memory the WE
bit should be (3.41)
The IEEE campus society office sells sodas for 35 cents. Suppose they install a
soda controller that only takes the following three inputs: nickel, dime, and quarter.
After you put in each coin, you push a pushbutton to register the coin. If at least 35
cents has been put in the controller, it will output a soda and proper change (if applicable).
Draw a finite state machine that describes the behavior of the soda controller. Each state
will represent how much money has been put in (Hint: There will be seven of those states).
Once enough money has been put in it, the controller will go to a final state where the person
will receive a soda and proper change (Hint: There are five such final states). From the final state,
the next coin that is put in will start the process again.
(Adapted from 3.30)
A comparator circuit has two 1-bit inputs, A and B, and three 1-bit outputs, G (greater), E (equal), and L (less than).
Refer to figures 3.40 and 3.41 in the book for this problem.
A | B | G | E | L |
---|---|---|---|---|
0 | 0 | 0 | 1 | 0 |
0 | 1 | 0 | 0 | 1 |
1 | 0 | 1 | 0 | 0 |
1 | 1 | 0 | 1 | 0 |
Suppose that an instruction cycle of the LC-3 has just finished and another one is about to begin. The following table describes the values in select LC-3 registers and memory locations:
Register | Value |
---|---|
IR | x3001 |
PC | x3003 |
R0 | x3000 |
R1 | x3000 |
R2 | x3002 |
R3 | x3000 |
R4 | x3000 |
R5 | x3000 |
R6 | x3000 |
R7 | x3000 |
Memory Location | Value |
x3000 | x62BF |
x3001 | x3000 |
x3002 | x3001 |
x3003 | x62BE |
For each phase of the new instruction cycle, specify the values that PC
, IR
, MAR
, MDR
, R1
, and R2
will have at the end of the phase in the following table:
PC | IR | MAR | MDR | R0 | R1 | R2 | R3 | R4 | R5 | R6 | R7 | |
---|---|---|---|---|---|---|---|---|---|---|---|---|
Fetch | ||||||||||||
Decode | ||||||||||||
Evaluate Address | ||||||||||||
Fetch Operands | ||||||||||||
Execute | ||||||||||||
Store Result |
Hint: Example 4.2 illustrates the LDR
instruction of the LC-3. Notice that values of memory locations x3000
, 3002
, and 3003
can be interpreted as LDR
instructions.
PC | IR | MAR | MDR | R0 | R1 | R2 | R3 | R4 | R5 | R6 | R7 | |
---|---|---|---|---|---|---|---|---|---|---|---|---|
Fetch | x3004 | x62BE | x3003 | x62BE | x3000 | x3000 | x3002 | x3000 | x3000 | x3000 | x3000 | x3000 |
Decode | x3004 | x62BE | x3003 | x62BE | x3000 | x3000 | x3002 | x3000 | x3000 | x3000 | x3000 | x3000 |
Evaluate Address | x3004 | x62BE | x3003 | x62BE | x3000 | x3000 | x3002 | x3000 | x3000 | x3000 | x3000 | x3000 |
Fetch Operands | x3004 | x62BE | x3000 | x62BF | x3000 | x3000 | x3002 | x3000 | x3000 | x3000 | x3000 | x3000 |
Execute | x3004 | x62BE | x3000 | x62BF | x3000 | x3000 | x3002 | x3000 | x3000 | x3000 | x3000 | x3000 |
Store Result | x3004 | x62BE | x3000 | x62BF | x3000 | x62BF | x3002 | x3000 | x3000 | x3000 | x3000 | x3000 |
OPCODE | DR | SR1 | SR2 | UNUSED |
If there are 255 opcodes and 120 registers, and every register is available as a source or destination for every opcode,
OPCODE
?DR
)?UNUSED
bits in the instruction encoding?Memory Location | Value |
---|---|
X3000 | 0101000000100000 |
X3001 | 0001000000100101 |
X3002 | 0010001000000100 |
X3003 | 0001000000000000 |
X3004 | 0001001001111111 |
X3005 | 0000001111111101 |
X3006 | 1111000000100101 |
X3007 | 0000000000000100 |
PC | x3006 |
R0 | x0050 |
R1 | x0000 |
R2 | x0000 |
R3 | x0000 |
R4 | x0000 |
R5 | x0000 |
R6 | x0000 |
R7 | x0000 |
N | 0 |
Z | 1 |
P | 0 |
Memory Location | Value | Instruction | Cycles takes to exectue once | number of times executed | Total Cycles for instruction |
---|---|---|---|---|---|
X3000 | 0101000000100000 | AND | 9 | 1 | 9 |
X3001 | 0001000000100101 | ADD | 9 | 1 | 9 |
X3002 | 0010001000000100 | LD | 15 | 1 | 15 |
X3003 | 0001000000000000 | ADD | 9 | 4 | 36 |
X3004 | 0001001001111111 | ADD | 9 | 4 | 36 |
X3005 | 0000001111111101 | Branch | 9 if not taken 10 if taken | 3 times taken 1 time not taken | 39 |