Java程序辅导

C C++ Java Python Processing编程在线培训 程序编写 软件开发 视频讲解

客服在线QQ:2653320439 微信:ittutor Email:itutor@qq.com
wx: cjtutor
QQ: 2653320439
Project 1 – Single Cycle MIPS – Spring 2018 CSCI 320 Computer Architecture ↓ Skip to Main Content CSCI 320 Computer Architecture Department of Computer Science Search for: Home Syllabus Schedule Projects Project 0 – Lab Intro Project 1 – Single Cycle MIPS Project 2 – Pipelined CPU Project 3 – Research Project Resources Google Docs Home › Projects › Project 1 – Single Cycle MIPS Project 1 – Single Cycle MIPS Posted on January 23, 2018 by admin Posted in Projects Due: Friday, 2/16/2018. The goal of this project is to implement the MIPS single cycle CPU from activity 06. This header file defines many/all of the MIPS bits/vectors and is useful when completing this assignment. Below is how to include this file in Verilog. `include "mips.h" // various defines 1 `include "mips.h" // various defines The Patterson & Hennessy single cycle CPU (FIGURE 4.24) is shown above. This datapath can execute most instructions, missing is support for the JAL and JR instructions (you can add these later). We have already developed the instruction fetch, jump, and control logic. We are left with the registers, ALU, and data memory. (note: we moved ALU control internal to the control module). Implementing the registers and data memory is very similar to instruction memory. Each defines an array of bit vectors and accesses them accordingly. In behavioral Verilog modeling for the ALU is very simple, a case statement on the control input is sufficient (see activity 05 for a table of the control signals). The goal of this activity is to finish the basic single cycle CPU. Your system must be able to execute basic MIPS code (see Building MIPS binary code below). You must simulate two syscalls: print integer (1), and exit (10). You do not have to implement any delays. At the end of the simulation (syscall 10), print a summary of simulation statistics. At a minimum include total simulation time, number of clock cycles, number of instructions executed, and IPC (instructions per clock). Notes The GNU C compiler, gcc, assumes there is a one-instruction branch delay slot. Your simulator must be able to deal with this correctly (i.e., always execute the instruction following a branch or jump before setting the PC to the new target). Building MIPS binary code To test your program we need to generate binary machine code to load into your memory module. We could hand write machine code (not fun), or use the GNU assembler to help us out. If you save the program add_test.s you can use the following Makefile to compile it to a Verilog-compatible $readmemh format file. First, you’ll want to add the path  /usr/remote/mipsel/bin  to your path (e.g., for bash do:  export PATH=$PATH:/usr/remote/mipsel/bin). This is the location of the MIPS cross compiler and other utilities. add_test.s # This test program loads two immediate values # and prints the sum using a syscall. .global __start # export start symbol .text __start: # define entry point for gcc li $t0, 1 li $t1, 2 li $v0, 1 # setup for print integer syscall add $a0, $t1, $t0 # syscall prints value in a0 syscall li $v0, 10 # exit syscall syscall 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 # This test program loads two immediate values # and prints the sum using a syscall.   .global __start # export start symbol .text   __start:         # define entry point for gcc li $t0, 1 li $t1, 2   li $v0, 1 # setup for print integer syscall add $a0, $t1, $t0 # syscall prints value in a0 syscall   li $v0, 10 # exit syscall syscall Makefile # Makefile to generate bare metal code to run on a simulated (Verilog) processor # from assembly code. # Bucknell University # Alan Marchiori 2014 AS=mipsel-linux-as LD=mipsel-linux-ld SREC=srec_cat # these are the flags we need for bare metal code generation CFLAGS=-mno-abicalls -fpic -nostdlib -static LDFLAGS=-L/usr/remote/mipsel/lib/gcc/mipsel-buildroot-linux-uclibc/4.6.3 -lgcc # change this line as needed ASMSOURCE=add_test.s SREC_OUTPUT=$(ASMSOURCE:.s=.srec) VERILOG_OUTPUT=$(ASMSOURCE:.s=.v) OBJECTS=$(ASMSOURCE:.s=.o) all: $(OBJECTS) # now link to a motorola SRecord $(LD) $(LDFLAGS) --oformat=srec $(OBJECTS) -o $(SREC_OUTPUT) # convert the SRecord file into a Verilog file $(SREC) $(SREC_OUTPUT) -Byte-swap 4 -o $(VERILOG_OUTPUT) -VMem %.o: %.s # assemble to a motorola srecord file $(AS) $< -o $@ clean: @echo $(OBJECTS) rm -f $(OBJECTS) $(SREC_OUTPUT) $(VERILOG_OUTPUT) 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 # Makefile to generate bare metal code to run on a simulated (Verilog) processor # from assembly code. # Bucknell University # Alan Marchiori 2014   AS=mipsel-linux-as LD=mipsel-linux-ld SREC=srec_cat   # these are the flags we need for bare metal code generation CFLAGS=-mno-abicalls -fpic -nostdlib -static LDFLAGS=-L/usr/remote/mipsel/lib/gcc/mipsel-buildroot-linux-uclibc/4.6.3 -lgcc   # change this line as needed ASMSOURCE=add_test.s   SREC_OUTPUT=$(ASMSOURCE:.s=.srec) VERILOG_OUTPUT=$(ASMSOURCE:.s=.v) OBJECTS=$(ASMSOURCE:.s=.o)   all: $(OBJECTS) # now link to a motorola SRecord $(LD) $(LDFLAGS) --oformat=srec $(OBJECTS) -o $(SREC_OUTPUT) # convert the SRecord file into a Verilog file $(SREC) $(SREC_OUTPUT) -Byte-swap 4 -o $(VERILOG_OUTPUT) -VMem   %.o: %.s   # assemble to a motorola srecord file $(AS) $< -o $@   clean: @echo $(OBJECTS) rm -f $(OBJECTS) $(SREC_OUTPUT) $(VERILOG_OUTPUT) When you run  make the output should look like this: $ make # assemble to a motorola srecord file mipsel-linux-as add_test.s -o add_test.o # now link to a motorola SRecord mipsel-linux-ld -L/usr/remote/mipsel/lib/gcc/mipsel-buildroot-linux-uclibc/4.6.3 -lgcc --oformat=srec add_test.o -o add_test.srec # convert the SRecord file into a Verilog file srec_cat add_test.srec -Byte-swap 4 -o -VMem /* 00000003: add_test.srec */ @00100000 00000314 00000000 00000000 00000000 00000000 00000000 @00100008 24080001 24090002 24020001 01282020 0000000C 2402000A 0000000C @0010000F 00000000 1 2 3 4 5 6 7 8 9 10 11 $ make # assemble to a motorola srecord file mipsel-linux-as add_test.s -o add_test.o # now link to a motorola SRecord mipsel-linux-ld -L/usr/remote/mipsel/lib/gcc/mipsel-buildroot-linux-uclibc/4.6.3 -lgcc --oformat=srec add_test.o -o add_test.srec # convert the SRecord file into a Verilog file srec_cat add_test.srec -Byte-swap 4 -o  -VMem /* 00000003: add_test.srec */ @00100000 00000314 00000000 00000000 00000000 00000000 00000000 @00100008 24080001 24090002 24020001 01282020 0000000C 2402000A 0000000C @0010000F 00000000 Because we are compiling on a little-endian Intel CPU, we have to byte-swap the output to big-endian format. You can now use $readmemh to load this program from the add_test.v file into your simulated CPU’s program memory. You should have noticed this program uses two syscalls, 1 (print integer) and 10 (exit). The generated machine code for the syscall is 0x0000000C. Your simulator should check for this value from program memory and handle the syscall accordingly. For example, when you read syscall and $v0 == 1, you will have to $display (or $strobe) something from Verilog. If $v0 == 10, you will call $finish. Also, notice the first few bytes are a binary header (call the .reginfo section) added by the GNU assembler. Your MIPS processor should skip these lines and begin executing at word address 0x00100008 (byte address 0x00400020). Test See the shortcut at the end of this section. One of the first recursive functions we use in CSCI203 generates the Fibonacci sequence. This is intuitive to implement recursively. This will also be a good test of our processor’s ability to properly handle branches and the stack. The C code is below. You should be able to code this in assembly (you can test with MARS using the 206 lab for reference). Your MIPS assembly Fibonacci program should generate (print) a few Fibonacci numbers and stop. You can check CSCI206’s Lab 5/Lab 6 for basic MIPS stack usage. Remember that you need to implement a memory module to store the stack segment and that you will have to initialize the stack pointer ($sp) to this segment! Also, remember you will have to implement all instructions on your Verilog CPU needed to execute this code! int fibonacci(int n) { if ( n == 0 ) return 0; else if ( n == 1 ) return 1; else return ( fibonacci(n-1) + fibonacci(n-2) ); } 1 2 3 4 5 6 7 8 9 int fibonacci(int n) {    if ( n == 0 )       return 0;    else if ( n == 1 )       return 1;    else       return ( fibonacci(n-1) + fibonacci(n-2) ); } SHORTCUT:   Here is a start to the fibonacci MIPS assembly code: however, it only prints the value of one hard-coded Fibonacci number (Test it out in MARS). You should remind yourself of MIPS to the degree you can modify it to print out the first few Fibonacci numbers (say 10 for example). Submit Submit a zip/tgz file of your entire project working folder to your google drive. You should include all Verilog files including a testbench that runs add_test and/or Fibonacci and a readme file that explains the design, compilation, execution, and testing methodology (i.e., explain how you know it’s working “it outputs 3” is not sufficient). Grading Rubric Sophisticated [10] Competent [8] Still Improving [6 or less] Design [10] Modular, logical, concise, module parameters used. No single “big” module. Some modularity (as in sophisticated) but one module with a disproportionate amount of code. Insufficient modularity, more than one long/ overly complex module. Documentation [10] Readme sufficiently explains the design, compilation, execution, and testing methodology. The code contains module-level comments and inline comments where appropriate. Readme missing one feature, or no module-level comments, or no inline comments Missing more than 1 of the previously listed items. Programs (add_test, Fibonacci) [10] Fibonacci executes and generates correct output. After simulation useful statistics are displayed in a visually appealing format. Fibo/add_test works but produces some unwanted output or post-execution statistics need improvement Fibo does not execute correctly but add_test is working. (score 0 if neither program works.) ‹ Welcome to Computer Architecture! Project 2 – Pipelined CPU › © 2021 Spring 2018 CSCI 320 Computer Architecture Responsive Theme powered by WordPress Top