Constructive Computer Architecture Tutorial 4: Running and Debugging SMIPS Andy Wright 6.175 TA October 10, 2014http://csg.csail.mit.edu/6.175T04-1.

Slides:



Advertisements
Similar presentations
Final Presentation Part-A
Advertisements

Intro to Computer Org. Pipelining, Part 2 – Data hazards + Stalls.
Blackfin BF533 EZ-KIT Control The O in I/O Activating a FLASH memory “output line” Part 2.
Lab Assignment 2: MIPS single-cycle implementation
From: From:
Students: Nir Engelberg Ezequiel Hadid Supervisor: Mony Orbach In association with: September 28, Winter 2005.
Computer Programming and Basic Software Engineering 4. Basic Software Engineering 1 Writing a Good Program 4. Basic Software Engineering 3 October 2007.
Students: Asulin Ofir Heller Itai Supervisor: Mony Orbach In association with: June 16, summer 2006.
EE694v-Verification-Lect5-1- Lecture 5 - Verification Tools Automation improves the efficiency and reliability of the verification process Some tools,
A. Frank - P. Weisberg Operating Systems Introduction to Cooperating Processes.
SM3121 Software Technology Mark Green School of Creative Media.
Constructive Computer Architecture Tutorial 4: SMIPS on FPGA Andy Wright 6.S195 TA October 7, 2013http://csg.csail.mit.edu/6.s195T04-1.
Superscalar SMIPS Processor Andy Wright Leslie Maldonado.
MIPS I/O and Interrupt. SPIM I/O and MIPS Interrupts The materials of this lecture can be found in A7-A8 (3 rd Edition) and B7-B8 (4 th Edition).
CHAPTER 1 XNA Game Studio 4.0. Your First Project A computer game is not just a program—it is also lots of other bits and pieces that make playing the.
1 ENG236: ENG236: C++ Programming Environment (2) Rocky K. C. Chang THE HONG KONG POLYTECHNIC UNIVERSITY.
P51UST: Unix and Software Tools Unix and Software Tools (P51UST) Compilers, Interpreters and Debuggers Ruibin Bai (Room AB326) Division of Computer Science.
© Janice Regan, CMPT 128, Jan CMPT 128 Introduction to Computing Science for Engineering Students Creating a program.
Constructive Computer Architecture Tutorial 5: Programming SMIPS: Single-Core Assembly Andy Wright TA October 10, 2014http://csg.csail.mit.edu/6.175T04-1.
Infrastructure design & implementation of MIPS processors for students lab based on Bluespec HDL Students: Danny Hofshi, Shai Shachrur Supervisor: Mony.
IT253: Computer Organization Lecture 4: Instruction Set Architecture Tonga Institute of Higher Education.
GBT Interface Card for a Linux Computer Carson Teale 1.
Programming Lifecycle
Chapter 8 I/O. Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 8-2 I/O: Connecting to Outside World So far,
1 Pipelining Reconsider the data path we just did Each instruction takes from 3 to 5 clock cycles However, there are parts of hardware that are idle many.
MIPS I/O and Interrupt. .data val1:.float 0.6 val2:.float 0.8 msg_done:.asciiz "done\n".text.globl main main: li.s $f0, mfc1 $a0, $f0 jal calsqrt.
Testing and Debugging Version 1.0. All kinds of things can go wrong when you are developing a program. The compiler discovers syntax errors in your code.
Constructive Computer Architecture Tutorial 3: Debugging SMIPS Andy Wright 6.S195 TA October 4, 2013http://csg.csail.mit.edu/6.s195T03-1.
September 3, 2009L02-1http://csg.csail.mit.edu/korea Introduction to Bluespec: A new methodology for designing Hardware Arvind Computer Science & Artificial.
C++ Programming Language Lecture 2 Problem Analysis and Solution Representation By Ghada Al-Mashaqbeh The Hashemite University Computer Engineering Department.
Computer Architecture Lecture 2 System Buses. Program Concept Hardwired systems are inflexible General purpose hardware can do different tasks, given.
N from what language did C++ originate? n what’s input, output device? n what’s main memory, memory location, memory address? n what’s a program, data?
Implementing RISC Multi Core Processor Using HLS Language – BLUESPEC Final Presentation Liam Wigdor Advisor Mony Orbach Shirel Josef Semesterial Winter.
High Speed Digital Systems Lab. Agenda  High Level Architecture.  Part A.  DSP Overview. Matrix Inverse. SCD  Verification Methods. Verification Methods.
BMTRY 789 Lecture 11: Debugging Readings – Chapter 10 (3 rd Ed) from “The Little SAS Book” Lab Problems – None Homework Due – None Final Project Presentations.
Constructive Computer Architecture Tutorial 3 Debugging BSV Andy Wright TA September12, 2014http://csg.csail.mit.edu/6.175T01-1.
Infrastructure design & implementation of MIPS processors for students lab based on Bluespec HDL Students: Danny Hofshi, Shai Shachrur Supervisor: Mony.
Blackfin Array Handling Part 1 Making an array of Zeros void MakeZeroASM(int foo[ ], int N);
Lab 2 Parallel processing using NIOS II processors
12/14/2015 Concept of Test Driven Development applied to Embedded Systems M. Smith University of Calgary, Canada 1 Automated Testing Environment Concepts.
Constructive Computer Architecture Tutorial 4 Debugging Sizhuo Zhang TA Oct 23, 2015T04-1http://csg.csail.mit.edu/6.175.
Chapter 6: Computer Components Dr Mohamed Menacer Taibah University
1  1998 Morgan Kaufmann Publishers Chapter Six. 2  1998 Morgan Kaufmann Publishers Pipelining Improve perfomance by increasing instruction throughput.
1 ECE243 CPU Modification Lab. 2 You will add new insts to a CPU A CPU that implements mini ISA exists –you can compile it, load it onto DE2, run programs.
Constructive Computer Architecture Tutorial 6: Five Details of SMIPS Implementations Andy Wright 6.S195 TA October 7, 2013http://csg.csail.mit.edu/6.s195T05-1.
6.375 Tutorial 4 RISC-V and Final Projects Ming Liu March 4, 2016http://csg.csail.mit.edu/6.375T04-1.
1 Lecture 2 - Introduction to C Programming Outline 2.1Introduction 2.2A Simple C Program: Printing a Line of Text 2.3Another Simple C Program: Adding.
Lab 1: Using NIOS II processor for code execution on FPGA
User-Written Functions
Computer Terms Review from what language did C++ originate?
MIPS I/O and Interrupt.
Constructive Computer Architecture Tutorial 6: Discussion for lab6
MIPS I/O and Interrupt.
Constructive Computer Architecture: Lab Comments & RISCV
Constructive Computer Architecture Tutorial 7 Final Project Overview
6.375 Tutorial 2 Guards and Scheduling Ming Liu
Lab 4 Overview: 6-stage SMIPS Pipeline
Constructive Computer Architecture Tutorial 3 RISC-V Processor
6.375 Tutorial 5 RISC-V 6-Stage with Caches Ming Liu
EECS150 Fall 2007 – Lab Lecture #4 Shah Bawany
Debugging EECS150 Fall Lab Lecture #4 Sarah Swisher
Explaining issues with DCremoval( )
Debugging EECS150 Fall Lab Lecture #4 Sarah Swisher
PROGRAMMING FUNDAMENTALS Lecture # 03. Programming Language A Programming language used to write computer programs. Its mean of communication between.
An Introduction to Debugging
Computer Terms Review from what language did C++ originate?
Tutorial 7: SMIPS Labs and Epochs Constructive Computer Architecture
Working with the Compute Block
Constructive Computer Architecture Tutorial 1 Andy Wright 6.S195 TA
Presentation transcript:

Constructive Computer Architecture Tutorial 4: Running and Debugging SMIPS Andy Wright TA October 10, 2014http://csg.csail.mit.edu/6.175T04-1

Introduction In lab 5, you will be making modifications to an existing, functional, SMIPS processor How do you know if your processor is working? You will run an existing suite of C and assembly software test benches on your processor What could go wrong? Software and Hardware How will you debug this? October 10, 2014http://csg.csail.mit.edu/6.175T04-2

Running SMIPS October 10, 2014T04-3http://csg.csail.mit.edu/6.175

SMIPS Interface interface Proc; method ActionValue#(Tuple2#(RIndx, Data)) cpuToHost; method Action hostToCpu(Addr startpc); interface MemInitIfc iMemInit; interface MemInitIfc dMemInit; endinterface October 10, 2014T04-4http://csg.csail.mit.edu/6.175 Sub-interfaces Slightly different than the interface shown in lecture

Real SMIPS Interface October 10, 2014http://csg.csail.mit.edu/6.175T04-5 cpuToHost hostToCpu iMemInit dMemInit mkProc – BSV COP Core iMem dMem PC

SMIPS Interface cpuToHost mtc0 moves data to coprocessor registers This instruction really just writes data to a FIFO in the form (cop_reg, data) cpuToHost dequeues from that FIFO COP Registers: 18: Print data as integer 19: Print data as char 21: Send finish code  0 is passed, all other codes signal failure October 10, 2014T04-6http://csg.csail.mit.edu/6.175

SMIPS Interface Other Methods/Subinterfaces hostToCpu Tells the processor to start running from the given address iMemInit/dMemInit Used to initialize iMem and dMem Can also be used to check when initialization is done Defined in MemInit.bsv October 10, 2014T04-7http://csg.csail.mit.edu/6.175

Connecting to the SMIPS interface Previous labs have used testbenches written in BSV to connect with modules we wanted to test. Now we want a more advanced program testing the processor Want to be able to load multiple files from the user and display printed output How do we do this? Use a SceMi interface to connect a testbench written in C++ with a module written in BSV October 10, 2014T04-8http://csg.csail.mit.edu/6.175

SceMi Testbench Interface October 10, 2014http://csg.csail.mit.edu/6.175T04-9 tb – C++mkProc – BSV COP Core iMem dMem PC

Loading Programs October 10, 2014http://csg.csail.mit.edu/6.175T04-10 tb – C++ test.vmh mkProc – BSV COP Core iMem dMem PC

Starting the Processor October 10, 2014http://csg.csail.mit.edu/6.175T04-11 mkProc – BSV COP Core iMem dMem tb – C++ Starting PC 0x1000 PC

Printing to Console October 10, 2014http://csg.csail.mit.edu/6.175T04-12 tb – C++mkProc – BSV COP Core iMem dMem PC Get write to reg 18 and 19 18: Print int x 19: Print char x

Finishing Program October 10, 2014http://csg.csail.mit.edu/6.175T04-13 tb – C++mkProc – BSV COP Core iMem dMem PC Get write to reg 21 x == 0: “PASSED” x != 0: “FAILED x”

SceMi Testbench Interface Simulation October 10, 2014http://csg.csail.mit.edu/6.175T04-14 tb – C++mkProc – BSV COP Core iMem dMem PC Compiled Program: tb Compiled BSim Executable: bsim_dut TCP

Building the SMIPS processor October 10, 2014http://csg.csail.mit.edu/6.175 $ cd scemi/sim $ build –v onecycle building target onecycle... … lots of compiler messages … done building target onecycle. T04-15 Builds./bsim_dut and./tb

Running SMIPS Simulations October 10, 2014http://csg.csail.mit.edu/6.175 $./bsim_dut > sim.out & $./tb../../programs/build/qsort.bench.vmh../../programs/build/qsort.bench.vmh Cycles = Insts = PASSED SceMi Service thread finished! T04-16 Printed by SMIPS mtc0 instructions through tb executable Writes BSV output to sim.out

Running SMIPS Simulations October 10, 2014http://csg.csail.mit.edu/6.175 $./bsim_dut –V test.vcd > /dev/null & $./tb../../programs/build/qsort.bench.vmh../../programs/build/qsort.bench.vmh Cycles = Insts = PASSED SceMi Service thread finished! T04-17 Dumps VCD waveform to test.vcd Ignores BSV output

Running all SMIPS Tests October 10, 2014http://csg.csail.mit.edu/6.175 $./run_assembly … runs all assembly tests … $./run_benchmarks../../programs/build/median.bench.vmh Cycles = 6871 Insts = /../programs/build/multiply.bench.vmh Cycles = Insts = /../programs/build/qsort.bench.vmh Cycles = Insts = … SceMi Service thread finished! T04-18

SceMi Testbench Interface Hardware October 10, 2014http://csg.csail.mit.edu/6.175T04-19 tb – C++mkProc – BSV COP Core iMem dMem PC Compiled Program: tb Compiled FPGA Design running on an FPGA dev board PCIe The same SceMi Testbench can be used to test hardware FPGA designs too!

Running SMIPS Hardware October 10, 2014http://csg.csail.mit.edu/6.175 $ programfpga … programs the FPGA … $ runtb./tb../../programs/build/qsort.bench.vmh../../programs/build/qsort.bench.vmh Cycles = Insts = PASSED T04-20 programfpga takes care loading the design, and runtb takes care of communicating with the FPGA board Your current design can’t run on FPGA boards and won’t be able to run on them until later labs.

Debugging SMIPS October 10, 2014T04-21http://csg.csail.mit.edu/6.175

Step 1 – Fail a test October 10, 2014http://csg.csail.mit.edu/6.175T04-22 $./run_assembly …../../programs/build/smipsv1_lw.asm.vmh FAILED 1 … $./run_benchmarks …../../programs/build/vvadd.bench.vmh Executing unsupported instruction at pc: Exiting … We need more feedback from the processor! Error Code BSV Error message $fwrite(stderr, “Executing unsupported …

Step 2 – Think about it Just because you failed smipsv1_lw.asm.vmh doesn’t mean your problem is only with the lw instruction Are other programs failing? October 10, 2014T04-23http://csg.csail.mit.edu/6.175

Step 3 – Investigate October 10, 2014T04-24http://csg.csail.mit.edu/6.175 $./bsim_dut –V test.vcd > test.out & $./tb../../programs/build/smipsv1_lw.asm.vmh../../programs/build/smipsv1_lw.asm.vmh FAILED 1 Save VCD fileSave BSV output Look at../../programs/build/smipsv1_lw.asm.vmh to see the program running (the source is in../../programs/src/assembly/) Look at test.out for any BSV messages you outputted Look at test.vcd to see the firing rules and the state of the processor Also look at targetname_compile_for_bluesim.log for compiler warnings

Step 3 – Investigate Programs Test Benches can be written in assembly or in C Assembly examples:  baseline.S  smipsv2_addu.S C example:  vvadd The.vmh files are the compiled versions with some human readable assembly as comments October 10, 2014http://csg.csail.mit.edu/6.175T04-25

Step 3 – Investigate BSV Output The BSV output may look something like this: To debug further, you can add more $display(…) statements October 10, 2014http://csg.csail.mit.edu/6.175 … Cycle pc: inst: (03e00008) expanded: jr ‘h1f Cycle pc: inst: (aaaaaaaa) expanded: nop T04-26

Step 3 – Investigate Waveforms “build –v testname” generates testname.bspec Open the bluespec workstation using “bluespec testname.bspec &” Open the module viewer to explore the VCD file as mentioned in the previous tutorial Can view states and rule signals CAN_FIRE tells you if rule gaurds are true WILL_FIRE tells you if rules are actually firing October 10, 2014http://csg.csail.mit.edu/6.175T04-27

Step 3 – Investigate Compiler Output The compiler will output many warnings when compiling the SMIPS processor Most of them are because of the SceMi interface All mkProc warnings will appear before any of the SceMi warnings The compiler gives a warning when Two rules conflict A rule never fires Many other useful situations… October 10, 2014http://csg.csail.mit.edu/6.175T04-28

Step 4 – Get More Information Create new programs New assembly programs can just be added to programs/src/assembly and then build by running “make” in programs/ New C programs require adding targets to the makefile./run_assembly and./run_benchmarks will find all *.asm.vmh and all *.bench.vmh files that have been built October 10, 2014T04-29http://csg.csail.mit.edu/6.175

Step 4 – Get More Information Add more debug outputs from the processor New display statements will show up in stdout $fwrite(stderr, “…”) messages will show up in stderr Add Probes to your module to get more information in the waveform viewer October 10, 2014T04-30http://csg.csail.mit.edu/6.175

Step 4 – Get More Information: Probes A Probe has an interface similar to a register, but it can’t be read Import Probe::*; Probe#(t) myprobe <- mkProbe(); myprobe <= my_value; (only inside rules) Probes will be preserved by the compiler and you will be able to see them in the VCD viewer Possible probe idea: Create a vector of probes to output the state of a FIFO in logical order (probe[0] is the first element in the fifo, and so on) October 10, 2014T04-31http://csg.csail.mit.edu/6.175

Step 5 – Fix the bug (hopefully you found it by this point) October 10, 2014T04-32http://csg.csail.mit.edu/6.175

Questions? October 10, 2014T04-33http://csg.csail.mit.edu/6.175