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

  Effort required for various project

Estimation of the effort required for various project tasks is one of the toughest assignments for a project planner. In an organization, who is the best judge for the effort needed for specific tasks? Please explain the basis for your answer.

  Explain bec corporate is department

If you were the system analyst in BEC corporate IS department and you had recieved call from Carrie douglas about her Project idea,what would you suggest to Carrie?

  Explain how to complete team roles inventory

To do this, well complete Team Roles Inventory. After you have completed inventory, what roles are you most probable to play? How do these roles compare with other?

  What does it mean to spawn a process?

1. Process can be in different states to allocate the resources better. List the symbol and meaning for each of these states

  Systems analyst modifying the sales order process

Suppose that you are a systems analyst on a project that involves modifying the sales order process. How many do you need to sample if you want 95 percent certainty that you have covered all variations?

  Describing use of request for information

Describe in scholarly detail how you would utilize RFI (Request For Information) procedures to recognize potential vendors in the acquisition process, and RFQ.

  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.

  Relationship of human service organizations and populations

How do the unique relationship between human service organizations and the populations they serve impact ethical decisions?

  The authentication process in a synchronous token system

Describe how the Kerberos authentication process work and outline the main components within the Kerberos environment, their respective functions and the level of security provided by Kerberos. Draw a diagram supporting your explanation Explain..

  What will a back-propagation network for problem

What will a back-propagation network predict for this example, assuming that it has been trained and reaches a global optimum?

  Explain implications of copyrights on usage of web site

Study and explain copyright implications associated to Web site development. Write down minimum of 350 words explaining the implications of copyrights on usage of content on Web site.

  Describe the concept of form follows function

Describe the concept of "Form Follows Function" as it pertains to the three main areas of design (FAB). Recognize ways in which portfolio designer works within limitations of media technology (Functionality).

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