Please follow exactly what is ask, otherwise I wont get the credit. (NO LIBRARY FUNCTIONS) It is important to note that you are not allowed to use library functions, you need to write the necessary...

1 answer below »
Please follow exactly what is ask, otherwise I wont get the credit. (NO LIBRARY FUNCTIONS)





It is important to note that you are not allowed to use library functions, you need to write the necessary functions to implement those.



, I want you to assume char takes 1 byte, and String takes 1*length.



regarding Color, you can consider it as a 32-bit sequence. Alpha + Red + Blue + Green


Let say Color object is created as color= new Color(255,0,0) -> means that Red is 255 (0xFF), Blue (0x00) and Green (0x00). So, there is no blue and green in the color, so it is a pure red







CS351_Winter20_Assignment1 CS 351 Computer Architecture I Jan 17, 2020 Assignment-1 1 Instructor: Dr.Fatma C Serce Due Date: January 31, 2020 A Simple Main Memory Implementation In this assignment, you are asked to design and develop a main memory of a simple CPU. You are given an interface class, MemoryInterface, which gives the abstraction of main memory. You are asked to create a class, MainMemory, which implements MemoryInterface. public interface MemoryInterface { // load the memory with sample data given in input file // after main memory is loaded, it will print its content to the console public void loadMemory(String inputFile) throws FileNotFoundException; // set memory[address] = data if address is valid, otherwise throw exception public void writeByte(int address, byte data) throws SecurityException; public void writeShort(int address, short data) throws SecurityException; public void writeInt(int address, int data) throws SecurityException; public void writeDouble(int address, double data) throws SecurityException; public void writeChar(int address, char data)throws SecurityException; public void writeString(int address, String data)throws SecurityException; public void writeColor(int address, Color data)throws SecurityException; // return memory[address] if address is valid, otherwise throw exception public byte readByte(int address)throws SecurityException; public short readShort(int address)throws SecurityException; public int readInt(int address)throws SecurityException; public double readDouble(int address)throws SecurityException; public char readChar(int address)throws SecurityException; //updated public String readString(int address, int length)throws SecurityException; public Color readColor(int address)throws SecurityException; } Here are assumptions and requirements for implementing main memory: • MainMemory is an array of bytes and index of an array element represents the address of each byte in the memory • Assume that memory is byte-aligned • MainMemory object is constructed by setting the initial byte capacity, size of memory in bytes. • MainMemory provides implementation for all the methods provided in the MethodInterface. The core functions of MainMemory are: o Load: initializes the content of main memory from an input file o Write: writes the data into a memory address o Read: reads the data from a memory address Important: While performing conversions, you are NOT allowed to use library classes and/or methods. You are supposed to design and develop the algorithms to make the necessary conversions. You are also provided with a Junit Test Case in the Appendix. You can add more test cases and test your implementation. CS 351 Computer Architecture I Jan 17, 2020 Assignment-1 2 Sample input file that might be used to initialize the contents of the main memory. Each line represents one byte. 11101001 00000000 01111000 00000000 00000000 00000000 00100010 00000000 00000000 00000000 00000000 00000000 00000000 00000100 11010010 01000010 10101010 01000000 00000000 00000000 00000000 00000000 00000000 01100110 01000011 01010011 00000000 11001000 01100100 00110010 CS 351 Computer Architecture I Jan 17, 2020 Assignment-1 3 HOW TO SUBMIT You are supposed to submit only MainMemory implementation via CANVAS and codepost. Please use the following file format while naming the zip file: LastNameFirstnameX_Y.zip where LastNameFirstname is your last name with the first letter in capital, followed by your first name with the first letter in capital; the X is the course code; the Y is the assignment #. (ex: SerceFatmaCS351_1.zip) HOW TO EVALUATE: The following rubric describes how your work will be evaluated. Correctness (90 points) • [90] Program is correct in object oriented design and function; meets specification; and utilizes heap memory well • [75] Program output is correct but elements of specification missing, e.g. variable/method declarations. • [45] Part of the specification has been implemented, e.g. one out of two required • subprograms. • [20] Program has elements of correct code but does not assemble/compile. Readability (10 points) • [10] Programmer name and assignment present. Sufficient comments to illustrate program logic. Well-chosen identifiers. • [7] Programmer name present, most sections have comments. Fair choice of identifiers • [5] Few comments, non-meaningful identifiers • [0] No programmer name. No comments. Poor identifiers CS 351 Computer Architecture I Jan 17, 2020 Assignment-1 4 Appendix: @Test public void testReadString() { String expected = "CS"; String actual = mem.readString(24,2); assertEquals(expected, actual); } CS 351 Computer Architecture I Jan 17, 2020 Assignment-1 5 @Test public void testReadColor() { Color expected = new Color(200, 100, 50); Color actual = mem.readColor(26); assertEquals(expected, actual); } @Test public void testWriteByte() { byte data = -23; int address = 0; mem.writeByte(address, data); byte expected = -23; byte actual = mem.readByte(address); assertEquals(expected, actual); } //… more test cases for write operations… }
Answered Same DayJan 25, 2021

Answer To: Please follow exactly what is ask, otherwise I wont get the credit. (NO LIBRARY FUNCTIONS) It is...

Arun Shankar answered on Jan 30 2021
129 Votes
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here