Implementation for the r-type instructions add, or, and and

Assignment Help Basic Computer Science
Reference no: EM13163854

figuring out how to add an implementation for the R-type instructions ADD, OR, and AND. This is a MIPS architecture.

// Incomplete behavioral model of MIPS pipeline

 

module mipspipe(clock);

// in_out

input clock;

 

// Instruction opcodes

parameter LW = 6'b100011, SW = 6'b101011, BEQ = 6'b000100, nop = 32'b00000_100000, ALUop = 6'b0;

reg [31:0] PC, // Program counter

Regs[0:31], // Register file

IMemory[0:1023], DMemory[0:1023], // Instruction and data memories

IFIDIR, IDEXA, IDEXB, IDEXIR, EXMEMIR, EXMEMB, // pipeline latches

EXMEMALUOut, MEMWBValue, MEMWBIR; // pipeline latches

 

wire [4:0] IDEXrs, IDEXrt, EXMEMrd, MEMWBrd, MEMWBrt; // fields of pipeline latches

wire [5:0] EXMEMop, MEMWBop, IDEXop; // opcodes

wire [31:0] Ain, Bin; // ALU inputs

 

// Define fields of pipeline latches

assign IDEXrs = IDEXIR[25:21]; // rs field

assign IDEXrt = IDEXIR[20:16]; // rt field

assign EXMEMrd = EXMEMIR[15:11]; // rd field

assign MEMWBrd = MEMWBIR[15:11]; // rd field

assign MEMWBrt = MEMWBIR[20:16]; // rt field -- for loads

assign EXMEMop = EXMEMIR[31:26]; // opcode

assign MEMWBop = MEMWBIR[31:26]; // opcode

assign IDEXop = IDEXIR[31:26]; // opcode

 

// Inputs to the ALU come directly from the ID/EX pipeline latches

assign Ain = IDEXA;

assign Bin = IDEXB;

reg [5:0] i; //used to initialize registers

reg [10:0] j,k; //used to initialize registers

 

initial begin

PC = 0;

IFIDIR = nop;

IDEXIR = nop;

EXMEMIR = nop;

MEMWBIR = nop; // no-ops placed in pipeline latches

// test some instructions

for (i=0;i<=31;i=i+1) Regs[i] = i; // initialize registers

IMemory[0] = 32'h8c210003;

IMemory[1] = 32'hac020000;

IMemory[2] = 32'h00642820;

for (j=3;j<=1023;j=j+1) IMemory[j] = nop;

DMemory[0] = 32'h00000000;

DMemory[1] = 32'hffffffff;

for (k=2;k<=1023;k=k+1) DMemory[k] = 0;

end

always @ (posedge clock)

begin

// FETCH: Fetch instruction & update PC

IFIDIR <= IMemory[PC>>2];

PC <= PC + 4;

 

// DECODE: Read registers

IDEXA <= Regs[IFIDIR[25:21]];

IDEXB <= Regs[IFIDIR[20:16]]; // get two registers

 

IDEXIR <= IFIDIR; // pass along IR

 

// EX: Address calculation or ALU operation

if ((IDEXop==LW) |(IDEXop==SW)) // address calculation

EXMEMALUOut <= IDEXA +{{16{IDEXIR[15]}}, IDEXIR[15:0]};

else if (IDEXop==ALUop) begin // ALU operation

case (IDEXIR[5:0]) // R-type instruction

  48: EXMEMALUOut <= Ain + Bin; // add operation

default: ; // other R-type operations [to be implemented]

 

endcase

end

EXMEMIR <= IDEXIR; EXMEMB <= IDEXB; //pass along the IR & B

// MEM

if (EXMEMop==ALUop) MEMWBValue <= EXMEMALUOut; //pass along ALU result

else if (EXMEMop == LW) MEMWBValue <= DMemory[EXMEMALUOut>>2]; // load

else if (EXMEMop == SW) DMemory[EXMEMALUOut>>2] <=EXMEMB; // store

MEMWBIR <= EXMEMIR; //pass along IR

// WB

if ((MEMWBop==ALUop) & (MEMWBrd != 0)) // update registers if ALU operation and destination not 0

Regs[MEMWBrd] <= MEMWBValue; // ALU operation

else if ((MEMWBop == LW)& (MEMWBrt != 0)) // Update registers if load and destination not 0

Regs[MEMWBrt] <= MEMWBValue;

end

 

 

Reference no: EM13163854

Questions Cloud

Compute the work when moles of methane react with oxygen : Calculate the work (in kJ) when 2.20 moles of methane react with excess oxygen at 384 K: CH4(g) + 2O2(g) ? CO2(g) + 2H2O(l) Hint
How "direction" can be used in an effective publication? : What are four examples of how "direction" can be used in an effective publication?
Write an essay on your communication in your team : Analyse each team member's team contribution, including yourself, using the ‘Five simple rules for being an effective team member' to guide your comments. Provide specific examples to support your viewpoint.
Prevent from the loss of confidentiality caused by malware? : 1. Cybercirminals can use malware to steal files and information from computer, if this happens have loss of confidentiality. Explain how antivirus can be help to prevent from the loss of confidentiality caused by malware?
Implementation for the r-type instructions add, or, and and : figuring out how to add an implementation for the R-type instructions ADD, OR, and AND. This is a MIPS architecture. // Incomplete behavioral model of MIPS pipeline
What is the order of the public key? : the weaknesses that arise in Elgamal encryption if a public key of small order is used. We look at the following example. Assume Bob uses the group Z ? 29 with the primitive element ?= 2. His public key is ?= 28.
Design a java program that simulates a slot machine : Design a java program that simulates a slot machine. When the program runs, it should do the following: Ask the user to enter the amount of money he or she wants to insert into the slot machine. ? Instead of displaying images, the program will random..
Characteristics of quicksort : familiarize  with the performance characteristics of Quicksort under normal and worst case conditions. The assignment will require some programming and interpretation of the results.
What is the total amount paid by the corporation : A U.S. corporation has purchased currency call options to hedge a 70,000 pound payable. The premium is $.02 and the exercise price of the option is $.50. If the spot rate at the time of maturity is $.65, what is the total amount paid by the corporati..

Reviews

Write a Review

Basic Computer Science Questions & Answers

  Write program to make change for cost of item

Write down a C# program to make change. Enter cost of item which is less than one dollar. Output coins given as change, by using quarters, dimes, nickels, and pennies.

  Recursive multiplication

Recursive Multiplication Write a main program that uses a recursive function. This function accepts two arguments into the parameters x and y.

  What are the drawbacks of your changes?

Describe what changes could be made to an operating to break the conditions of non-preemption and hold and wait for deadlock prevention. What are the drawbacks of your changes?

  How cultural differences in colors and images are perceived

What are some examples of cultural differences in how colors and images are perceived? How would you change the colors and images on your website to appeal to a wider global audience.

  Write command to determine users on active directory from xp

Write down the command to determine all users on Active Directory from XP. Write down the query to look up a user on Active Directoy and see the user's property.

  Following class definition

Given the following class definition, describe the type of variables used by the arguments and return values of the following member functions (values, pointers, or references):

  Determine complement of sum of these eight-bit bytes

UDP and TCP use 1s complement their checksums. Assume you have following three 8-bit bytes: 01010011, 01010100, 01110100. Determine 1s complement of sum of these eight-bit bytes?

  How virtual memory relies on locality of reference principle

TLB entries are different than page table entries. Describehow they differ and why they differ. Virtual memory relies on a locality of reference principle. Describe.

  How many bits are in logical address

Consider a simple paging system with the following parameters: 2^32 bytes of physical memory, page size of 2^10 bytes, and 2^16 pages of logical address space. How many bits are in a logical address?

  Business reprocess engineering-strategic information system

Some people may say that Business Reprocess Engineering (BPR) is special case of strategic information system, whereas, others may say opposite is true. Describe this statement in scholarly detail.

  The progresses report

The progresses report is a chance to highlight and discuss any issues that you are having in meeting the project plans. Discuss any changes to the original proposal and if needed propose a renegotiate plan on what is to be achieved for the project in..

  Explaining straight-line depreciation method

Explain in scholarly detail how to carry out Straight-line Depreciation Method calculations.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd