Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

The primary objective of this assignment is to write the fetch-decode-execute-store cycle of the control unit in the architecture, as well as the computation in

The primary objective of this assignment is to write the fetch-decode-execute-store cycle of the control unit in the architecture, as well as the computation in the arithmetic logic unit (ALU). The memory, 8 registers, instruction register, and program counter for the machine have already been included in a class called ABCMachine.java. This class should not be altered You must first understand how the class works before attempting to write the control unit or ALU. The ABC Machine components are shown below, where each individual box represents one bit that can hold a 1 or 0.

The memory of the ABC Machine will look like this when program1.abc has been loaded into ABC Machine's memory.

There are fields in the ABCMachine class for the program counter and instruction register. Arrays are used to store the 8 register values and the 16 memory locations. Note that the integral types short (16 bits) and byte (8 bits) are being used.

The ABC machine stores a reference to the ALU and ControlUnit object. You will complete both of these classes.

The constructor of the ABC machine will accept a path to a file (program1.abc or program2.abc) that contains a memory map of the machine. The constructor then instantiates the basic components of the architecture and reads the data from the memory map into memory..

There are several getters in the ABC machine class that allow access to the control unit, ALU, PC and IR registers, memory and machine registers.

Creating the ControlUnit Class

The ControlUnit class is responsible for the fetch-decode-execute-store cycle. Once a program is loaded into memory the startProcessing() method is called on the ControlUnit. This method contains a while loop that will execute the fetch-decode-execute-store steps until a halt program instruction (all zeros) has been encountered. (this has been done for you). You are responsible for programming all the methods marked with a TODO in ControlUnit.java. There are method header comments that describe what task each method should accomplish.

  • Fetch step
    • The control unit should access the memory address of the next instruction from the PC register.
    • Using that address and the memory of the ABC machine, you should load the next instruction into the IR register.
    • You should then increment the PC register.
  • Decode step:
    • You should parse the current instruction and identify the following:
      • Opcode
      • Source and destination registers (or NZP bits for the branch instruction)
      • Address
  • Execute and Store step:
    • Your program should execute the instruction.
    • All arithmetic should be sent to the ALU for computation. This includes the values retrieved from the source registers.
    • The LD and ST instructions should update your memory or registers accordingly.
    • The Branch BR and Jump JMP instructions should update your PC register

Below is a description of the instruction set of the ABC machine:

Creating the ALU Class

The ALU class has two responsibilities:

  • The class should perform all the arithmetic ADD, SUB, MULT and DIV instructions in the operate method. The operate method receives three parameters. 2 pieces of data to perform math operations with, and an enum indicating which math operation to perform.
  • The class should store the NZP (Negative, Zero, Positive) indicator ( which is needed for the branch (BR) instruction) The NZP indicator tracks whether the last computation on the ALU resulted in a negative, zero or positive value. A getter is provided so the control unit can inspect this value for Branch BR instructions. If the NZP bits in the Branch Instruction equals the ALU status, then the PC is updated to hold the new Address in the Branch Instruction. NZP values of 100 indicates Negative, 010 indicates Zero, and 001 indicate Positive.

Testing the Machine

Test your program by running the program1.abc and program2.abc files with the ABCMachine class. You can use the provided ABCDriver class to run your machine. You should verify your results by printing the registers and memory map of the machine using methods provided in the ABCMachine class.

Here is the expected output of program1.abc:

Register dump 0000000000000111 0000000000000011 0000000000001010 0000000000000100 0000000000010101 0000000000000010 0000000000000000 0000000000000000 Memory dump 1010000000001110 1010010000001111 0000000010100000 1000100000001101 0010000010110000 0100000011000000 0110000011010000 0000000000000000 0000000000000000 0000000000000000 0000000000000000 0000000000000000 0000000000000000 0000000000001010 0000000000000111 0000000000000011

Here is the expected output of program2.abc:

Register dump 0000000000000011 0000000000000001 0000000000000000 0000000000000000 0000000000000000 0000000000000000 0000000000000000 0000000000000000 Memory dump 1010000000001111 0000000010000000 1101000000000110 1010010000001110 0000000010000000 1000000000001111 1110000000001001 0000000000000000 0000000000000000 0000000000000000 0000000000000000 0000000000000000 0000000000000000 0000000000000000 0000000000000001 0000000000000011 

JUnit Test Class

Write a JUnit Test Class to thoroughly test your ALU constructor and methods.

Extra Credit (2 points)

Write a third program that is stored in a program3.abc file. Your program should only contain machine instructions and should do the following:

  • Given three numbers in memory: M[13] = x, M[14] = y, M[15] = z
  • Calculates the product of all three numbers: x * y * z
  • If the result of the product is positive
    • your program should store the result to M[12]
  • Otherwise
    • your program should do nothing

Verify your results by printing the registers and memory map of the machine once the program has completed.

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

Step: 3

blur-text-image

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

Big Data Fundamentals Concepts, Drivers & Techniques

Authors: Thomas Erl, Wajid Khattak, Paul Buhler

1st Edition

0134291204, 9780134291208

More Books

Students also viewed these Databases questions