0% found this document useful (0 votes)
25 views11 pages

Caap Assigment5

Caap assignment

Uploaded by

mubhuss39
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
25 views11 pages

Caap Assigment5

Caap assignment

Uploaded by

mubhuss39
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 11

Computer Systems Engineering 22-Batch, Semester 5 Roll No:

Computer Architecture and Assembly Programming


Assignment
Course: Computer Systems Engineering
Batch: 22-Batch, 22CS-, Semester 5
Instructor: [Engr.Asif Ali Wagan]
Date: October 11, 2024

Academic Integrity Statement

By submitting this assignment, you affirm that the work is your own and that you have
adhered to the university’s policies on academic honesty. Plagiarism or collaboration is
not permitted and will result in disciplinary action.

Contents
Instructions 2

Submission Guidelines 2

Grading Criteria 2

Part A: Customized Fetch and Decode Cycle Flowchart 3

Part B: Customized Instruction Timing Diagram 5

Part C: Stack-Based Expression Evaluation Based on Roll Numbers 6

Part D: Hand-Drawn Common Bus System Diagram 8

Part E: Binary Instruction Encoding and Execution Based on Roll Num-


bers 9

Conclusion 11

1
Computer Systems Engineering 22-Batch, Semester 5 Roll No:

Instructions
This assignment is designed to assess your understanding of the fetch-decode-execute
cycle, instruction timing diagrams, and assembly programming. Each task is customized
based on your roll number to ensure individual and unique handwritten solutions.
Please read each part carefully and complete all tasks. All solutions must be hand-
written to ensure originality and individual effort.

Submission Guidelines
• Deadline: [Insert Due Date Here]
• Submission Method: [Insert Submission Platform or Email]
• Format:
– All parts must be handwritten.
– Submit scanned PDFs or clear photographs of your work.
– Ensure your name and roll number are included on each page.
– Label your files appropriately (e.g., RollNumber PartA.pdf, RollNumber PartB.pdf,
etc.).

Grading Criteria

Component Marks Comments


Part A: Fetch and Decode Flowchart 5 Accuracy, completeness, neatness
Part B: Instruction Timing Diagram 5 Correct micro-operations, clarity
Part C: Assembly Programming 5 Correctness, syntax, commenting
Total 15

2
Computer Systems Engineering 22-Batch, Semester 5 Roll No:

Part A: Customized Fetch and Decode Cycle Flowchart


Marks: 5

Objective: Hand-draw a detailed flowchart illustrating the fetch and decode phases for
a customized instruction based on your roll number.

Instruction Format: The instruction has a fixed length of 16 bits, divided as follows:

• Bits 0–11: Address Field


• Bits 12–14: Opcode
• Bit 15: I Bit (Indirect Bit)

Bit 15 Bits 14–12 Bits 11–0


I Bit Opcode Address Field

Rules for Customizing the Instruction:

1. Determining the Opcode (Bits 12–14):

• Use the last digit of your roll number.


• Opcode Value: Take the last digit modulo 8 (last digit % 8) to obtain a
value between 0 and 7.
• Convert this value to a 3-bit binary number for the opcode.

Examples:

• Roll Number 22CS05: Last digit is 5 → 5 mod 8 = 5 → Opcode: 101


• Roll Number 22CS29: Last digit is 9 → 9 mod 8 = 1 → Opcode: 001

2. Determining the I Bit (Bit 15):

• Sum the last two digits of your roll number.


• I Bit: If the sum is even, set I Bit = 0; if the sum is odd, set I Bit = 1.

Examples:

• Roll Number 22CS09: Last two digits are 0 and 9 → Sum = 0 + 9 = 9 (odd)
→ I Bit: 1
• Roll Number 22CS13: Last two digits are 1 and 3 → Sum = 1 + 3 = 4 (even)
→ I Bit: 0

3. Determining the Address Field (Bits 0–11):

• For roll numbers ending in two digits (e.g., 22CS45): Use the last two digits
of your roll number.
• For roll numbers ending in three digits (e.g., 22CS105): Use the last three
digits of your roll number.
• If necessary, take modulo 4096 (since 212 = 4096) to fit into 12 bits.

3
Computer Systems Engineering 22-Batch, Semester 5 Roll No:

• Convert this value into a 12-bit binary number, padding with leading zeros if
necessary.

Examples:

• Roll Number 22CS25: Last two digits are 25 → Binary (12 bits): 000000011001
• Roll Number 22CS105: Last three digits are 105 → Binary (12 bits): 000001101001

Fetch Phase Steps:

• Step 1: AR ← PC
Load the Address Register (AR) with the content of the Program Counter (PC).
• Step 2: IR ← M[AR], PC ← PC + 1
Fetch the instruction from memory at address AR into the Instruction Register
(IR) and increment PC.

Decode Phase Steps:

• Step 3: Extract I Bit, Opcode, and Address Field from the Instruction Register
(IR).
• Step 4: Determine the Instruction Type:
– If Opcode ̸= 7 (binary 111): Memory-Reference Instruction.
– If Opcode = 7 and I Bit = 0: Register-Reference Instruction.
– If Opcode = 7 and I Bit = 1: Input/Output Instruction.
• Step 5: Decode the Address Field if applicable.

Flowchart Requirements:

• Represent each step in the fetch and decode phases using standard flowchart sym-
bols.
• Include: Registers (PC, AR, IR), Buses (Address Bus, Data Bus), Control Unit
(relevant signals).
• Ensure clarity and neatness in your drawing.
• The flowchart must be handwritten.

4
Computer Systems Engineering 22-Batch, Semester 5 Roll No:

Part B: Customized Instruction Timing Diagram


Marks: 5

Objective: Hand-draw a timing diagram showing the execution of your customized


instruction across multiple clock cycles, detailing micro-operations and control signals.

Instructions:
1. Determine Micro-Operations: Based on your custom instruction from Part A,
identify the micro-operations required during the following phases:
Fetch Phase:
• T0: AR ← PC
• T1: IR ← M[AR], PC ← PC + 1
Decode Phase:
• T2: Decode IR to extract I Bit, Opcode, and Address Field.
Execute Phase:
• Based on your opcode, determine the necessary micro-operations.
2. Clock Cycle Allocation: Assign each micro-operation to a clock cycle (e.g., T0,
T1, T2, etc.). Some micro-operations can occur simultaneously if they do not
conflict.
3. Hand-Draw the Timing Diagram: Your timing diagram should include:
• Horizontal Axis: Clock cycles (T0, T1, T2, etc.).
• Vertical Axis: Micro-operations and control signals.
• Represent the duration of each micro-operation within its assigned clock cycle.
• Include control signals such as Read, Write, Increment PC, etc.
4. Include Pipeline Considerations (Optional):
• If your course covers pipelining, illustrate how your instruction would be pro-
cessed in a pipeline.
• Identify any potential hazards or stalls due to your instruction’s characteristics.

Dummy Opcode List:


Use these opcodes for your custom instruction’s fetch-decode-execute cycle and create
the corresponding micro-operations.

Timing Diagram Requirements:


• The timing diagram must be handwritten.
• Ensure clarity and neatness in your drawing.
• Provide handwritten explanations where necessary.

5
Computer Systems Engineering 22-Batch, Semester 5 Roll No:

Opcode (Decimal) Binary Operation


0 000 Load AC from Memory (AC ← M[Address])
1 001 Store AC to Memory (M[Address] ← AC)
2 010 Add Memory to AC (AC ← AC +
M[Address])
3 011 Subtract Memory from AC (AC ← AC -
M[Address])
4 100 Input (Read data into AC from Input De-
vice)
5 101 Output (Write data from AC to Output De-
vice)
6 110 Jump to Address (PC ← Address)
7 111 Halt (Terminate Program)

Part C: Stack-Based Expression Evaluation Based on


Roll Numbers
Marks: 5

Objective: Convert mathematical expressions from **infix notation** to **postfix no-


tation**, and evaluate them using a stack based on values derived from your roll number.

Instructions:
1. **Roll Number-Based Value Extraction:**
Based on your roll number, follow the **generalized rules** below to determine **Num1**
and **Num2**:
- **For roll numbers in the form ‘22CS0X‘ (e.g., ‘22CS01‘, ‘22CS03‘):** - **Num1** =
The last digit of your roll number. - **Num2** = ‘10‘ (fixed value for single-digit roll
numbers).
- **For roll numbers in the form ‘22CSXY‘ (e.g., ‘22CS13‘, ‘22CS67‘):** - **Num1** =
The first digit of the two-digit number (‘X‘). - **Num2** = The second digit of the
two-digit number (‘Y‘).
- **For roll numbers in the form ‘22CSXXX‘ (e.g., ‘22CS105‘, ‘22CS117‘):** - **Num1**
= The first two digits of the three-digit number (‘XX‘). - **Num2** = The last digit of
the three-digit number (‘X‘).
- **For roll numbers in the form ‘22-21CSXY‘ (e.g., ‘22-21CS39‘, ‘22-21CS81‘):** -
**Num1** = The first digit of ‘XY‘. - **Num2** = The second digit of ‘XY‘.

2. **Expressions to Convert and Evaluate:**


Convert the following **infix expressions** to **postfix**, and evaluate them step-by-
step using a stack. Make sure to replace **Num1** and **Num2** with the values
derived from your roll number.

**Expression 1:**

(Num1 + ASCII of C) × (ASCII of S − Num2)

6
Computer Systems Engineering 22-Batch, Semester 5 Roll No:

- **Example (for ‘22CS45‘ where Num1 = 4, Num2 = 5):**

(4 + 67) × (83 − 5)

- **Postfix Notation:**
4 67 + 83 5 − ×
- **Evaluate using a stack.**
Step Stack (Top to Bottom) Operation
1 4 Push 4
2 67, 4 Push 67
3 71 Add 4 + 67 = 71
Stack Evaluation:
4 83, 71 Push 83
5 5, 83, 71 Push 5
6 78, 71 Subtract 83 - 5 = 78
7 5538 Multiply 71 × 78 = 5538


3. **Unsolved Expressions for Students:**
a) **Expression 2:**
(Num2 + 22) × ASCII of S
- Convert to postfix notation and evaluate using a stack.
b) **Expression 3:**

(Num1 × Num2) + (ASCII of C − Num1)

- Convert to postfix notation and evaluate using a stack.


c) **Expression 4:**
 
ASCII of C
+ (ASCII of S mod Num2)
Num1

- Convert to postfix notation and evaluate using a stack.

7
Computer Systems Engineering 22-Batch, Semester 5 Roll No:

Part D: Hand-Drawn Common Bus System Diagram


Marks: 5

Objective: Draw a detailed block diagram of a common bus system, where the number
of registers is determined by your roll number and each register contains 8 bits. The
system should be designed using multiplexers, and registers should be connected to the
bus for data transfer.

Rules for Customizing the System:

1. Number of Registers:

• Add the first and second digits of your roll number.


• Divide the result by 2 to get the number of registers.
• Cap the number of registers at 8 (maximum), and set it to 2 if the result is
less than 2.

Examples:

• Roll Number 22CS19: First digit = 1, Second digit = 9 → 1+9 = 10, 10/2 = 5
→ **5 registers**.
• Roll Number 22CS05: First digit = 0, Second digit = 5 → 0 + 5 = 5, 5/2 = 2.5
→ **3 registers**.
• Roll Number 22CS31: First digit = 3, Second digit = 1 → 3 + 1 = 4, 4/2 = 2
→ **2 registers**.

2. Number of Bits per Register:

• Each register will contain 8 bits.

Diagram Requirements:
• Draw the determined number of registers based on your roll number.

• Use a multiplexer to select which register’s output is placed on the bus.

• The width of the bus should match the 8-bit width of each register.

• Show control signals to select registers for reading or writing.

• Include buses, control signals, and registers in the diagram.

Example Diagrams:

• Roll Number 22CS19 → 5 registers, each with 8 bits, connected to the bus using
a multiplexer.

• Roll Number 22CS45 → 8 registers, each with 8 bits, connected to the bus using
a multiplexer.

8
Computer Systems Engineering 22-Batch, Semester 5 Roll No:

• Roll Number 22CS01 → 2 registers, each with 8 bits, connected to the bus using
a multiplexer.

Submission Requirements:

• Submit a hand-drawn diagram of your system.

• Ensure clarity and neatness.

• Include all required components (registers, bus, multiplexer, control signals).

Task: Based on your roll number, follow the steps above to design and draw a common
bus system diagram. Ensure the number of registers and bits per register adhere to the
provided rules.

Part E: Binary Instruction Encoding and Execution


Based on Roll Numbers

Objective: Customize a 16-bit binary instruction based on your roll number, encode
it, and execute it step-by-step using the appropriate assembly-like operations. This will
include calculating values from your roll number and applying the operations on the
registers.

Instruction Format: You are provided a 16-bit instruction format with the following
breakdown:

• Bits 0–7: Operand (8 bits)

• Bits 8–11: Opcode (4 bits)

• Bits 12–15: Register Address (4 bits)

Operations (Opcodes): The Opcode (Bits 8–11) will dictate the operation to be
performed. Based on your roll number, generate an instruction and execute it.

• 0000 (0): Load Operand into Register

• 0001 (1): Add Operand to Register

• 0010 (2): Subtract Operand from Register

• 0011 (3): Multiply Register by Operand

• 0100 (4): Divide Register by Operand

• 0101 (5): AND Register with Operand

9
Computer Systems Engineering 22-Batch, Semester 5 Roll No:

• 0110 (6): OR Register with Operand

• 0111 (7): XOR Register with Operand

• 1000 (8): NOT (Bitwise Complement of Operand)

• 1001 (9): Shift Left Register by Operand

• 1010 (10): Shift Right Register by Operand

• 1011 (11): Increment Register by Operand

• 1100 (12): Decrement Register by Operand

• 1101 (13): Jump to Operand Address (if condition is true)

• 1110 (14): Halt

• 1111 (15): No Operation (NOP)

Roll Number-Based Value Extraction:

• Operand (Bits 0–7): Use the sum of the last two digits of your roll number,
convert it into an 8-bit binary number.

• Opcode (Bits 8–11): Use the last digit of your roll number, take modulo 16, and
convert it into a 4-bit binary number (this will select the operation).

• Register Address (Bits 12–15): Use the first digit of your roll number, take
modulo 8, and convert it into a 4-bit binary number (this will select the register to
operate on).

Register Selection: Each student will have to use one of the following registers based
on the **first digit** of their roll number (after applying the modulo 8 rule):

• Register 0000: Register A

• Register 0001: Register B

• Register 0010: Register C

• Register 0011: Register D

• Register 0100: Register E

• Register 0101: Register F

• Register 0110: Register G

• Register 0111: Register H

Example (for Roll Number 22CS19):

10
Computer Systems Engineering 22-Batch, Semester 5 Roll No:

• Operand (Bits 0–7): Sum of the last two digits = 1 + 9 = 10. 8-bit binary
representation of 10 is: 00001010.

• Opcode (Bits 8–11): Last digit of roll number is 9, so 9 mod 16 = 9. 4-bit


binary representation of 9 is: 1001 (Shift Left Register by Operand).

• Register Address (Bits 12–15): First digit of roll number is 1, so 1 mod 8 = 1.


4-bit binary representation of 1 is: 0001 (Register B).

Final 16-bit Instruction: 0001 1001 00001010 This means:

• Shift Register B left by 10 positions.

Unsolved Tasks for Students: Based on your roll number, follow these steps:

1. Task 1: Instruction 1 (Load and Add) Generate an instruction that loads the
operand into a register and then adds another operand to it. Perform the binary
encoding and show the register update after executing the instruction.

2. Task 2: Instruction 2 (Shift and Multiply) Generate an instruction that shifts


the register left or right, and then multiplies the value by the operand. Perform the
binary encoding and execute the operation step-by-step.

3. Task 3: Instruction 3 (Logical Operations) Create an instruction that applies


logical operations (AND, OR, XOR) between the register and the operand. Show
the changes in the register values after the operation.

Submission Requirements:

• Step 1: Generate the 16-bit binary instruction based on the given roll-number-
based rules.

• Step 2: Execute the instruction step-by-step, showing the register value updates
after each operation.

• Step 3: Submit a handwritten solution, including the binary encoding, operation,


and final result in decimal.

Conclusion
Good luck with your assignment! Apply your knowledge thoroughly, and ensure that
your handwritten work reflects your understanding of the concepts.

11

You might also like