Write yourself the sixth phase of CPU (4)--Verify the performance of the mobile operation instruction

Source: Internet
Author: User

Will be uploaded I wrote a new book, "Write Your Own CPU" (not yet published), today is the 23rd, I try to four weekly


6.4Test Program

This section will verify that the mobile operation instructions added to the Openmips processor are implemented correctly with a test program as follows, corresponding to the book with the CD code\chapter6\asmtest The Inst_rom in the directory . S file.

. org 0x0.set Noat.global _start_start://Give register $, $, $, $4 assign initial value lui $1,0x0000 # $ = 0x00000000 lui $2,0xffff # $ = 0xffff0000 lui $3,0x0505 # $ = 0x05050000 lui $4,0x0000 # $4 = 0x00000000//For M The ovz instruction, because the register is $0, assigns the value of $ to $4 movz $4,$2,$1 # $4 = 0xffff0000//For MOVN instructions, because the register is $0, it is not assigned, and $4 remains the same movn  $4,$3,$1 # $4 = 0xffff0000//For the MOVN instruction, because the register is not 0, the value of $ $ is assigned to $4 movn $4,$3,$2 # $4 = 0x05050000//   For the movz instruction, since the register $0 is not assigned, the value of $4 remains constant Movz $4,$2,$3 # $4 = 0x05050000//Continuous three mthi instructions, respectively, to save the value of the register, $, $, $ $, to the HI Register Mthi $ # hi = 0x00000000 Mthi $ # hi = 0xffff0000 mthi $ # hi = 0x05 050000//Read the value of the Hi register to $4 and verify that the data-related issues with Hi and LO registers are handled correctly mfhi $4 # $4 = 0x05050000//Continuous three instruction Mtlo, respectively, the register $                $ $, $ value saved to lo register Mtlo $ # lo = 0x05050000 mtlo $ # lo = 0xffff0000 Mtlo $ # lo = 0x00000000// Reads the value of the LO register to $4, while verifying that the data-related issues brought by Hi and Lo registers are handled correctly Mflo $4 # $4 = 0x00000000         

The program's comments give the expected effect and the aboveInst_rom. Sdocument, with the section4Chapter established theBin2Mem.exe,Makefile,Ram.ldthese three files are copied toUbuntuthe same directory in the virtual machine, open the terminal, use theCDcommand to enter the directory, and then enter make all, you can get it forModelsimsimulation of the instruction memory initialization fileInst_rom.data.

Create a new project in Modelsim, add all the . V files that are included with the CD code\Chapter6 directory , and then compile. Copy the above inst_rom.data file to the modelsim project directory and you can simulate it.

Modelsim Simulation Output 6-7,6-8, observe $4,HI, The change in the LO register value can be known that openmips correctly implements the move operation instruction.




Well, the mobile Operation command has already been implemented, and the verification passed, the next step will implement the arithmetic operation instructions, please pay attention!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.