31
1 ASSIGNMENT ECE514 (COMPUTER ORGANIZATION) ASSIGNMENT NO. 9 This is an individual assignment for ECE514. It carries a mark of 10%. The rubric of marks is given in Appendix 3. This assignment is about designing a Control Unit of a simple CPU by using a hardwired implementation. The CPU has been designed for you by using Logisim. However, the Control Unit is empty. By using Logisim, you will design the circuit for the Control Unit. After that, you have to test the CPU. Materials needed: 1) Logisim software (downloadable free at http://www.cburch.com/logisim/ or in i-learn). The size is approximately 7MB. You can run it straight from your pen drive without installation. However, your PC must be first installed with java (http://java.com – click at the Free Java Download button). 2) Logisim project file (filename: myComputerv6(9).circ) given by lecturer. Tasks: a) A CPU block diagram is given in Figure 1. The CPU can recognize 2 instructions given in Table 1 below. Table 1 Instruction Operation load address ACC Å address decb RAM[ACC] Å ACC - 1

ASSIGNMENT NO. 9halimnoor.com/wp-content/uploads/2017/05/ECE514-Assignment-de… · 5 Figure 2B: Control Unit e) Figure 2B shows the internal of CPU’s Control Unit. It consists

  • Upload
    others

  • View
    5

  • Download
    0

Embed Size (px)

Citation preview

Page 1: ASSIGNMENT NO. 9halimnoor.com/wp-content/uploads/2017/05/ECE514-Assignment-de… · 5 Figure 2B: Control Unit e) Figure 2B shows the internal of CPU’s Control Unit. It consists

ASSIGNMENT ECE514 (COMPUTER ORGANIZATION)

ASSIGNMENT NO. 9 This is an individual assignment for ECE514. It carries a mark of 10%. The rubric of marks is given in Appendix 3. This assignment is about designing a Control Unit of a simple CPU by using a hardwired implementation. The CPU has been designed for you by using Logisim. However, the Control Unit is empty. By using Logisim, you will design the circuit for the Control Unit. After that, you have to test the CPU. Materials needed: 1) Logisim software (downloadable free at http://www.cburch.com/logisim/ or in i-learn). The

size is approximately 7MB. You can run it straight from your pen drive without installation. However, your PC must be first installed with java (http://java.com – click at the Free Java Download button).

2) Logisim project file (filename: myComputerv6(9).circ) given by lecturer. Tasks: a) A CPU block diagram is given in Figure 1. The CPU can recognize 2 instructions given in

Table 1 below.

Table 1 Instruction Operation

load address

ACC address

decb

RAM[ACC] ACC - 1

Page 2: ASSIGNMENT NO. 9halimnoor.com/wp-content/uploads/2017/05/ECE514-Assignment-de… · 5 Figure 2B: Control Unit e) Figure 2B shows the internal of CPU’s Control Unit. It consists

 

 

 

 

 

 

 

 

 

 

 

 

Figure 1

Notes on the CPU diagram of Figure 1: i) PC – Program Counter Register, MAR – Memory Address Register, MDR – Memory

Data Register, ALU – Arithmetic Logic Unit, IR – Instruction Register, Temp – Temporary Register, opcode – opcode register, address – address register, ACC – accumulator register.

ii) The size of opcode register = size of address register = size of all other registers = 8 bits.

iii) The ALU can perform 4 operations – add, subtract, increment and decrement based on the values of sel0 and sel1 as shown below: If sel1 = 0 and sel0 = 0, add operation is performed (i.e. result in1 + in2). If sel1 = 0 and sel0 = 1, subtract operation is performed (i.e. result in1 - in2). If sel1 = 1 and sel0 = 0, increment operation is performed (i.e. result in1 + 1). If sel1 = 1 and sel0 = 1, decrement operation is performed (i.e. result in1 - 1).

iv) The read and write signals are connected to external RAM. v) The CPU control signals are labelled as a to m, read, write, sel0, sel1 and reset.

PC  MAR  ACC 

MDR   

ALU 

opcode  address IR

1 to 2 decoder 

+ 1  

b  c  d e 

f  g  i j

m in1  in2 

hresult 

 a 

Internal Bus  

m

 

             Control Unit 

Temp  

to external RAM 

k

from/to external RAM 

read 

write T0  T14 

shift register clock  reset 

sel0 

sel0 

load  decb

sel1 

sel1 

Page 3: ASSIGNMENT NO. 9halimnoor.com/wp-content/uploads/2017/05/ECE514-Assignment-de… · 5 Figure 2B: Control Unit e) Figure 2B shows the internal of CPU’s Control Unit. It consists

b) Based on Figure 1, the sequence of micro-operations for the fetch & decode cycles of the

CPU are given in Table 1A below:

Table 1A Clock cycle Activated control signals

T0 b , c T1 read , k, a T2 j , f T3 -

c) Based on Figure 1, the sequence of micro-operations for instruction load address are

given in Table 1B below: Table 1B

Clock cycle Activated control signals T4 b , c T5 read , k, a T6 j , g T7 h , d, reset

Question 1A: Based on Figure 1, write the sequence of micro-operations for instruction decb. Write your answer in page 1 of your report.

Question 1B: Based on the sequence of micro-operations in (b), (c) and Question 1A, write the Boolean equations for all the control signals (i.e. a to m, read, write, sel0, sel1 and reset). Write your answer in page 1 of your report.

Question 1C: Then, open the myComputerv6(9).circ by using Logisim (i.e. click menu item File Open). By using the Boolean equations obtained in Question 1B, create digital circuits inside the CPU’s Control Unit by using AND and OR gates. To do this, refer to steps (d) – (g) below. Make a screen capture of the completed circuit and paste it in page 2 of your report. Appendix 1 shows how to make a screen capture in Logisim.

 

Page 4: ASSIGNMENT NO. 9halimnoor.com/wp-content/uploads/2017/05/ECE514-Assignment-de… · 5 Figure 2B: Control Unit e) Figure 2B shows the internal of CPU’s Control Unit. It consists

   

Figure 2A: Project Pane  

d) After the file myComputerv6(9).circ is opened, the project pane on the left will display as shown in Figure 2A. Double - click the CONTROL UNIT to go inside the CPU’s Control Unit. The Control Unit is empty as shown in Figure 2B below.

Double Click here to go into the Control Unit

AND and OR gates

Add Wire

Page 5: ASSIGNMENT NO. 9halimnoor.com/wp-content/uploads/2017/05/ECE514-Assignment-de… · 5 Figure 2B: Control Unit e) Figure 2B shows the internal of CPU’s Control Unit. It consists

 

Figure 2B: Control Unit   

e) Figure 2B shows the internal of CPU’s Control Unit. It consists of only input pins (square shapes) and output pins (round shapes). The input pins are labelled as load, decb and T0 to T14. The output pins are labelled a to m, read, write, sel0, sel1 and reset.

f) You will create your digital circuits inside the CONTROL UNIT by connecting together

the inputs (load, decb and T0-T14) to the control signals (a to m, read, write, sel0,sel1 and reset) through AND and OR gates.

In myComputerv6(9).circ, you should view this pin as decb, not adda.

Page 6: ASSIGNMENT NO. 9halimnoor.com/wp-content/uploads/2017/05/ECE514-Assignment-de… · 5 Figure 2B: Control Unit e) Figure 2B shows the internal of CPU’s Control Unit. It consists

Figure 2C

By default, the OR gate has 5 inputs and facing east as shown in Figure 2C. If you need 2 inputs and facing north, you can change it by changing its “Facing” property to “North” and “Number of Inputs” to “2” as shown in Figure 2D.

Click OR gate

Drop OR gate here

In myComputerv6(9).circ, you should view this pin as decb, not adda.

Page 7: ASSIGNMENT NO. 9halimnoor.com/wp-content/uploads/2017/05/ECE514-Assignment-de… · 5 Figure 2B: Control Unit e) Figure 2B shows the internal of CPU’s Control Unit. It consists

Figure 2D Similar process applies to the AND gate.

The OR gate properties

In myComputerv6(9).circ, you should view this pin as decb, not adda.

Page 8: ASSIGNMENT NO. 9halimnoor.com/wp-content/uploads/2017/05/ECE514-Assignment-de… · 5 Figure 2B: Control Unit e) Figure 2B shows the internal of CPU’s Control Unit. It consists

To create a circuit, for example, if you have a Boolean equation for output a as shown below,

a = T0 + (T1 & load)

the circuit would be as shown in Figure 2E. A wire is obtained by holding down the left mouse button and dragging the mouse from one point to another. Just make sure the “Add wire” button is selected.

 

Figure 2E

To connect wires, make sure this button is selected

In myComputerv6(9).circ, you should view this pin as decb, not adda.

Page 9: ASSIGNMENT NO. 9halimnoor.com/wp-content/uploads/2017/05/ECE514-Assignment-de… · 5 Figure 2B: Control Unit e) Figure 2B shows the internal of CPU’s Control Unit. It consists

g) IMPORTANT ! OUTPUT PINS MUST NEVER BE LEFT UNCONNECTED. For

example, as shown in Figure 2E, output pins read, write and b are output pins that are left unconnected (i.e. not connected to anywhere). Unconnected output pins have a colour of blue with “X” in it. After you have completed your circuits, if there are any output pins not connected to anywhere (i.e. having Boolean equation, for examples, b = 0, read = 0, write = 0), you MUST connect them to GROUND as shown in the example in Figure 2F for output pins read, write and b.

Figure 2F

Select GROUND under category WIRING

In myComputerv6(9).circ, you should view this pin as decb, not adda.

Page 10: ASSIGNMENT NO. 9halimnoor.com/wp-content/uploads/2017/05/ECE514-Assignment-de… · 5 Figure 2B: Control Unit e) Figure 2B shows the internal of CPU’s Control Unit. It consists

10 

The GROUND connection is selected from the Project Pane by clicking the Ground icon under the category Wiring and dropping it on the canvas as shown in Figure 2F. Note: Please SAVE your work regularly.

You can refer the Tutorials in the HELP menu for reference on using Logisim.

CPU Testing

h) After you have completed creating the circuits in the Control Unit, you will test your CPU whether it can fetch and execute instructions load and decb correctly.

To do that, you must work in the Computer view as shown in Figure 3A below.

 

Figure 3A

Double Click here to go into the COMPUTER view

Page 11: ASSIGNMENT NO. 9halimnoor.com/wp-content/uploads/2017/05/ECE514-Assignment-de… · 5 Figure 2B: Control Unit e) Figure 2B shows the internal of CPU’s Control Unit. It consists

11 

The circuit of COMPUTER is as shown in Figure 3B. It consists of a CPU connected to a RAM.

Figure 3B: The Computer

The RAM is where the instructions and data are stored. Each instruction consists of the opcode and operand part. Instructions are stored in the RAM as hex numbers. The hex numbers for each instruction is called the machine code. The machine codes for each instruction in Table 1 is shown in Table 2 below:

Table 2

Instruction Machine Code (hex) Opcode Operand

load address 00 8-bit value stated by the address decb 01 -

So, for example, instruction load 08 would be represented by hex numbers 00 08.

i) Let’s test the CPU by using the following program in Figure 3C:

load 08 ; load ACC with 08 (hex) decb ; ACC - 1. Load the result of decrement in RAM ; at location pointed by the ACC register

Figure 3C

Page 12: ASSIGNMENT NO. 9halimnoor.com/wp-content/uploads/2017/05/ECE514-Assignment-de… · 5 Figure 2B: Control Unit e) Figure 2B shows the internal of CPU’s Control Unit. It consists

12 

For instruction load 08, it is represented by hex number 00 08 (i.e. 00 is the opcode field and 08 is the operand field.)

For instruction decb, it is represented by hex number 01 (i.e. 01 is the opcode field and no operand field)

You must place 00 08 and 01 in the RAM, starting at RAM address 00 as shown in Figure 4 and Figure 5 below:

Figure 4

Right-click the RAM. Then choose “Edit Contents”.

This Hex Editor will appear after “Edit Contents” is chosen.

Page 13: ASSIGNMENT NO. 9halimnoor.com/wp-content/uploads/2017/05/ECE514-Assignment-de… · 5 Figure 2B: Control Unit e) Figure 2B shows the internal of CPU’s Control Unit. It consists

13 

 

Figure 5

After editing the content of RAM, click “Close Window” button to close the Hex Editor.

You should see the RAM contents as in Figure 6 below:

Key in 00 08 and 01 here.

Page 14: ASSIGNMENT NO. 9halimnoor.com/wp-content/uploads/2017/05/ECE514-Assignment-de… · 5 Figure 2B: Control Unit e) Figure 2B shows the internal of CPU’s Control Unit. It consists

14 

 Figure 6

Now, you are ready to run the CPU.

j) To start running the CPU, you must be in Simulation Mode. Click the Hand icon (i.e. Change values within circuit) as shown in Figure 7 to go into the Simulation Mode.

00 08 and 01 representing instructions load 08 and decb respectively.

Page 15: ASSIGNMENT NO. 9halimnoor.com/wp-content/uploads/2017/05/ECE514-Assignment-de… · 5 Figure 2B: Control Unit e) Figure 2B shows the internal of CPU’s Control Unit. It consists

15 

   

Figure 7

k) Double-click the RESET input once as shown in Figure 8. This will apply a pulse (i.e 1-0) to the RESET input pin. This will clear the PC register (i.e. PC 00) and place the CPU in the T0 state.

   

Click the hand icon to start doing the simulation

Double-click the RESET pin of CPU once.

Page 16: ASSIGNMENT NO. 9halimnoor.com/wp-content/uploads/2017/05/ECE514-Assignment-de… · 5 Figure 2B: Control Unit e) Figure 2B shows the internal of CPU’s Control Unit. It consists

16 

Figure 8

Note: At any time you want to restart the program execution (i.e. reset the PC to 00 and place the CPU at T0), double-click the RESET pin once.

l) Then, look at the sequence of micro-operations in Table 1B for instruction load address. It ends at T7.

m) You must now advance the clock to completely execute instruction load address.

This is done by double-clicking the CLOCK input of CPU 7 times (i.e. apply 1-0 seven times).

n) Then, check the content of ACC register. This is done by double-clicking the CPU block

as shown in Figure 9A:

Figure 9A

o) This will enter the CPU internals as shown in Figure 9B. Then, double-click the ACC block to see the content of the ACC register.

Double-click the CPU.

Page 17: ASSIGNMENT NO. 9halimnoor.com/wp-content/uploads/2017/05/ECE514-Assignment-de… · 5 Figure 2B: Control Unit e) Figure 2B shows the internal of CPU’s Control Unit. It consists

17 

Figure 9B

p) After the ACC is double-clicked, we can see an 8-bit ACC register as shown in Figure 9C. In this diagram, the value shown in the ACC register is 00.

Double-click the ACC.

Page 18: ASSIGNMENT NO. 9halimnoor.com/wp-content/uploads/2017/05/ECE514-Assignment-de… · 5 Figure 2B: Control Unit e) Figure 2B shows the internal of CPU’s Control Unit. It consists

18 

Figure 9C Question 2A: What is the content of ACC register after the instruction load 08 is executed ? Write your answer in page 3 of your report.

The 8-bit content of ACC register is shown here.

Page 19: ASSIGNMENT NO. 9halimnoor.com/wp-content/uploads/2017/05/ECE514-Assignment-de… · 5 Figure 2B: Control Unit e) Figure 2B shows the internal of CPU’s Control Unit. It consists

19 

q) At any time, you can check and confirm, at which T state your CPU is currently in by double-clicking the CPU block such as shown in Figure 9A.

The CPU block diagram will be shown as Figure 10A. In the diagram, look at the SHIFT REG. At the bottom of SHIFT REG, there are pins labelled 14 through 0. Pin 14 is T0, pin 13 is T1, …. , pin 0 is T14. Then, look at the colour of those pins. In Figure 10A, the pin colour light green is at T14. Light green is logic 1, while dark green is logic 0. Since the light green is at pin 14, the CPU is in T0 state. If the light green is at pin 13, the CPU is in T1 state, etc.

Figure 10A

Pin 14 of SHIFT REG is coloured light green. So, the CPU is at T0 state.

Page 20: ASSIGNMENT NO. 9halimnoor.com/wp-content/uploads/2017/05/ECE514-Assignment-de… · 5 Figure 2B: Control Unit e) Figure 2B shows the internal of CPU’s Control Unit. It consists

20 

You can go back to the COMPUTER view by double-clicking the COMPUTER item as shown in Figure 10B:

Figure 10B

r) Then, look at the sequence of micro-operations for instruction decb you obtained in Question 1A.

Question 2B: At what clock cycle T does instruction decb complete execution ? Write your answer in page 3 of your report.

Double-click the COMPUTER item.

Page 21: ASSIGNMENT NO. 9halimnoor.com/wp-content/uploads/2017/05/ECE514-Assignment-de… · 5 Figure 2B: Control Unit e) Figure 2B shows the internal of CPU’s Control Unit. It consists

21 

s) Depending on your answer in Question 2B above, if your instruction decb completes execution at TX, you have to apply a total of X+1 clock pulses (i.e. double-clicking the CLOCK input pin of CPU for X+1 times). For example, if the instruction decb finish at T8, then you must double-click the CLOCK input pin of CPU for 8+1 = 9 times as shown in Figure 11C below:

 Figure 11C

t) After double-clicking the CLOCK for X+1 times, check the content of the RAM at location 08 as shown in Figure 11C above.

Question 2C: What is the content of RAM location 08 after the instruction decb is executed ? Write your answer in page 3 of your report.

Double-click the CLOCK input X+1 times.

After the CLOCK is double-clicked X+1 times, check content of RAM location 08.

Page 22: ASSIGNMENT NO. 9halimnoor.com/wp-content/uploads/2017/05/ECE514-Assignment-de… · 5 Figure 2B: Control Unit e) Figure 2B shows the internal of CPU’s Control Unit. It consists

22 

Assignment Submission:

You must submit a 4-page report. The report consists of:

i. Front page containing title “ ECE514 Computer Organization Assignment No. _____”, your full name, your Student ID., your group, and date of submission.

ii. Page 1- Answers for Questions 1A and 1B. (4 marks)

iii. Page 2- Answer for Question 1C. (i.e. the screen capture of the completed Control Unit. (Refer to Appendix 2 on how to obtain the screen capture of Control Unit)).

(4 marks) iv. Page 3 - The testing result of the CPU (i.e. Answers for Question 2A, 2B and 2C).

(2 marks)

Appendix 2 shows an example of the report. Submit your report at your lecturer’s room latest by Friday 26 December 2014.

THANK YOU

Saiful Fadzli bin Salian (Room 7.27) Mohd Daud Alang Hassan (Room BA3.10) Ahmad Puad Ismail (Room BA2.7)  

 

 

 

Page 23: ASSIGNMENT NO. 9halimnoor.com/wp-content/uploads/2017/05/ECE514-Assignment-de… · 5 Figure 2B: Control Unit e) Figure 2B shows the internal of CPU’s Control Unit. It consists

23 

APPENDIX 1: SCREEN CAPTURE OF CONTROL UNIT

Your circuit of your Control Unit might be huge. You may not able to “Print Screen” it by pressing the PrtScn button. Alternatively, you may obtain the screen capture image of the Control Unit circuit by using the Logisim built-in utility as explained below.

a) Go to CONTROL UNIT view by double-clicking the “Control Unit” text in the project pane as shown in Figure A2(a).

Figure A2(a)

Double-click “CONTROL UNIT”

Page 24: ASSIGNMENT NO. 9halimnoor.com/wp-content/uploads/2017/05/ECE514-Assignment-de… · 5 Figure 2B: Control Unit e) Figure 2B shows the internal of CPU’s Control Unit. It consists

24 

b) From the Logisim menu, click File Export Image as shown in Figure A2(b).

Figure A2(b)

c) An “Export Image” dialog box pops-up as shown in Figure A2(c) below. Leave the default. Just click OK.

Click “Export Image”

Page 25: ASSIGNMENT NO. 9halimnoor.com/wp-content/uploads/2017/05/ECE514-Assignment-de… · 5 Figure 2B: Control Unit e) Figure 2B shows the internal of CPU’s Control Unit. It consists

25 

  

Figure A2(c)

d) A “Select Export File” dialog box appear as shown in Figure A2(d). Choose the directory location and filename of your choice to save the Control Unit image.

Page 26: ASSIGNMENT NO. 9halimnoor.com/wp-content/uploads/2017/05/ECE514-Assignment-de… · 5 Figure 2B: Control Unit e) Figure 2B shows the internal of CPU’s Control Unit. It consists

26 

Figure A2(d)

e) Paste the image inside your report. Resize it accordingly so that the text is clearly seen.  

 

 

 

 

 

 

 

 

Page 27: ASSIGNMENT NO. 9halimnoor.com/wp-content/uploads/2017/05/ECE514-Assignment-de… · 5 Figure 2B: Control Unit e) Figure 2B shows the internal of CPU’s Control Unit. It consists

27 

 

APPENDIX 2: REPORT EXAMPLE

ECE514 COMPUTER ORGANIZATION

ASSIGNMENT NO. _______ NAME

STUDENT ID.

GROUP

DATE OF SUBMISSION

Page 28: ASSIGNMENT NO. 9halimnoor.com/wp-content/uploads/2017/05/ECE514-Assignment-de… · 5 Figure 2B: Control Unit e) Figure 2B shows the internal of CPU’s Control Unit. It consists

28 

ANSWER TO QUESTION 1A: SEQUENCE OF MICRO-OPERATIONS OF INSTRUCTION ____________

Clock Cycles Activated Control Signals T4 T5 : : :

ANSWER TO QUESTION 1B: BOOLEAN EQUATIONS OF THE LISTED CONTROL SIGNALS: a = b = c = d = e = f = g = h = i = j = k = l = m = read = write = sel0 = sel1 = reset =

Page 29: ASSIGNMENT NO. 9halimnoor.com/wp-content/uploads/2017/05/ECE514-Assignment-de… · 5 Figure 2B: Control Unit e) Figure 2B shows the internal of CPU’s Control Unit. It consists

29 

ANSWER TO QUESTION 1C: CONTROL UNIT CIRCUIT

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Page 30: ASSIGNMENT NO. 9halimnoor.com/wp-content/uploads/2017/05/ECE514-Assignment-de… · 5 Figure 2B: Control Unit e) Figure 2B shows the internal of CPU’s Control Unit. It consists

30 

QUESTION 2A: What is the content of ACC register after the instruction load 08 is executed ?

Answer:________________________ QUESTION 2B: At what clock cycle T does instruction decb complete execution ?

Answer:________________________ QUESTION 2C: What is the content of RAM location 08 after the instruction decb is executed ?

 

 

Answer:________________________

Page 31: ASSIGNMENT NO. 9halimnoor.com/wp-content/uploads/2017/05/ECE514-Assignment-de… · 5 Figure 2B: Control Unit e) Figure 2B shows the internal of CPU’s Control Unit. It consists

31 

APPENDIX 3

ECE514 ASSIGNMENT RUBRIC

Criteria 0 Mark 1 Mark 2 Marks 3 Marks 4 MarksSequence of Micro-Operations & Boolean Equations Correctly listed the sequence of micro-operations in Question 1A and write correct Boolean equations in Question 1B.

Did not write any Boolean equation and sequence of micro-operations in page 1 of report.

More than 2 incorrect sequence of micro-operations, OR More than 6 incorrect Boolean equations

2 incorrect sequence of micro-operations, OR 4 – 6 incorrect Boolean expressions

Only 1 incorrect sequence of micro-operations, OR 1 – 3 incorrect Boolean expressions

Correct writing of all sequence of micro-operations AND all Boolean equations.

Control Unit Circuit Correctly create the circuit of Control Unit based on the above Boolean expressions using Logisim. (Question 1C)

Did not put any screen capture of the Control Unit circuit from Logisim in page 2 of report.

More than 6 incorrect control signal circuit.

4 – 6 incorrect control signal circuit.

1 – 3 incorrect control signal circuit.

Correct circuit for all control signals.

CPU Testing Testing correctly the CPU by correctly answering the given questions (i.e. Questions 2A – 2C) in CPU Testing section.

Incorrect / Did not answer any Questions 2A – 2C in CPU Testing section.

Correct answer for either Questions 2A OR Questions 2C.

Correct answer for all Questions 2A – 2C.

-

-