Unformatted text preview:

Project 1 Part B Assemble and Simulate CSE 141L Fall 2008 Richard Strong Due October 27 2008 11 59pm You are encouraged to work on this project in teams of 2 Overview Although you have already designed an ISA you need to validate and revise the ISA before expending the extensive effort required to sign and implement it In project 1b you will implement two essential components for architectural validation and verification assembler and simulator An assembler translates your program written in your ISA into binary code a simulator performs a simulation upon a provided binary code Collectively they form essential infrastructure for your processor design For the implementation of the assembler and the simulator you are free to choose any high level language including scripting languages Assembler It is difficult and error prone to manually write machine code To address this problem people usually use an assembler which automatically generates a machine code from an assembly file Moreover many C compilers first generate assembly files and then simply feed it to an assembler to get the executable machine code For these reasons you should write an assembler for your ISA Your assembler reads a program written in an assembly language then translates it into binary code and generates two output files containing executable machine code You will use the generated output files for both the simulator and the actual hardware you will implement Required Features First examine the following sample assembly code text la 1 table0 load the address of a label table0 pseudo instruction lw 2 1 2 0x000C0FFEE lw 3 table0 load the value at label table0 pseudo instruction 3 0x000C0FFEE lw 4 3 table0 4 table1 lw 5 1 4 5 0x1DEADBEEF sw 5 1 1 0x001COFFEE is overwritten to 0x1DEADBEEF li 6 0xC0FFEE load immediate pseudo instruction 6 0xC0FFEE data table0 word 0x000C0FFEE word 0x001C0FFEE word 0x002C0FFEE word table1 table1 word 0x0DEADBEEF word 0x1DEADBEEF word 0x2DEADBEEF word 0x3DEADBEEF word 0x4DEADBEEF 0x5DEADBEEF 0x6DEADBEEF fill 10 0x0 Your assembler must support the following keywords and reserved words used in the example code above The following list is the minimal required set you may extend it with other keywords text Indicates the start of the text section consisting of instructions text can appear many times in an assembly file but they must be merged into a single section in the output of the assembler The input to the assembler text addr will specify the address that the assembler will assume the resulting text section is loaded at data Indicates the start of the data section Similar to text there can be multiple data in an assembly file The input to the assembler data addr will specify the address that the assembler will assume the resulting data section is loaded at word Specifies the word data at a memory location It can be followed by multiple one or more words to describe data for multiple words fill Duplicates a data many times For example fill 10 0x0 duplicates 0x0 ten times label Represents an instruction or data memory address similar to labels in other languages can be used in instructions to specify a specific address e g la 0 table0 When you use labels you can minimize the amount of manual modifications in your assembly code upon insertions or deletions of instructions and or data For example suppose that word 0x003COFFEE is insterted after word 0x002C0FFEE in the previous sample code the only needed change is the fourth instruction from lw 4 3 table0 to lw 4 4 table In other words labels make the code maintenance cost more manageable by keeping the effect of a code modification be local to a label In addition to the keywords listed above the assembler must support at least four pseudo instructions equivalent to the following MIPS pseudo instructions appeared in the previous example code la rd offset label Loads the address of label offset into rd lw rd offset label Loads the data located at label offset into rd li rd immediate Loads the immediate value into rd sw rs offset label Stores the value of rs to the address label offset These pseudo instructions will make programmers life easier by allowing programmers not to concern absolute addresses instead they can describe most addresses with label and offset Note that pseudo instructions might be equivalent to multiple instructions in your ISA Also note that the addresses used in pseudo instructions can be either an instruction memory address or a data memory address depending on the location of the label You may change pseudo instruction names if needed but the semantics of instructions should be the same Code Stub To execute a benchmark in your simulator you will need to create a small code stub that sets up the environment including Stack Pointer Make sure that the stack pointer is properly set so that the tested function benchmark can use the stack Global Pointer A program often accesses global data and or constants by using the global pointer gp in MIPS which is also set by the code stub Like the stack pointer a code stub should properly set the global pointer before the execution of a tested function Input Data Many of the benchmark programs require a few arguments To test these benchmarks a code stub must properly set registers and or the stack memory depending on the way your ISA passes function arguments You should modify your code stub when you want to test a benchmark with different arguments In addition to function arguments Virtual Machine benchmark needs test data You have to include test data in your code stub for Virtual Machine using the previously mentioned word keyword When all the environmental settings are properly done the code stub should call a benchmark function Since code stub should be the first code executed upon power on the text section of the code stub should be placed at 0x0 of the instruction memory in the output file of the assembler Assume that your processor starts by fetching an instruction from 0x0 upon reset Before you implement a program you should finish the stub in Project 1B always assemble with a code stub Input and Output Requirements Your assembler should accept the following input parameters o stub stub name a single s assembly code stub file optionally used when the output files are intended for simulation purposes o src name a single s assembly test bench file o text addr addr the start address of the text section in the instruction memory do not need to specify when stub is used o


View Full Document

UCSD CSE 141L - Project 1 Part B

Loading Unlocking...
Login

Join to view Project 1 Part B and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Project 1 Part B and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?