Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Computer Engineering Expert

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

 

 

Computer Engineering, Engineering

  • Category:- Computer Engineering
  • Reference No.:- M9453973

Have any Question?


Related Questions in Computer Engineering

A 200g sample of acetylsalicylic acid better known

A 2.00g sample of acetylsalicylic acid, better known asaspirin, is dissolved in 100mL of water and titrated with 0.200mol/L NaOH(aq) to the end point. The volume of base required is 55.5mL. Calculate the molar mass of ac ...

Question 1 why is it critical for an organization to have a

Question: 1. Why is it critical for an organization to have a DoS attack response plan well before it happens? 2. Please discuss the techniques used by malware developers to disguise their code and prevent it from being ...

Please explain which formula i should use to complete the

Please explain which formula I should use to complete the following probability question: The probability that a family will buy a vacation home in Miami, malibu, or newport is 0.25, 0.10 and 0.35. What is the probabilit ...

C programminghelp with a program positivec that include the

***C PROGRAMMING*** Help with a program positive.c that include the following function: void extract(int *a, int n, int *positive, int *size); The function should use pointer arithmetic, not subscripting. The extract fun ...

You have been recently promoted to it security manager your

You have been recently promoted to IT Security Manager. Your first job is to document the older hardware and software your company is currently using in the IT department. State the strengths and weaknesses with the curr ...

Each of the following lists has an average of 50 for which

Each of the following lists has an average of 50. For which one is the spread of the numbers around the average biggest?smallest? a. 0, 20, 40, 50, 60, 80, 100 b. 0, 48, 49, 50, 51, 52, 100 c. 0, 1, 2, 50, 98, 99, 100 Gu ...

Question you are shopping for a new computer you will be

Question: You are shopping for a new computer. You will be using the computer for everything you do, such as school, socializing, gaming, and communicating. Your total budget before tax is $1,000.00. Considerations: • Bu ...

Some statistics students were interested in finding out in

Some Statistics students were interested in finding out in there was a relationship between the number of hours of study for a chapter and the score on that test. On the basis of the number of hours their classmates stud ...

Question research the options for creating a gui on a sun

Question : Research the options for creating a GUI on a Sun Solaris platform that can be duplicated on a Windows platform. Select a tool for creating a dual platform product and specify how much time would be needed for ...

Consider a valleyed array a1 2 middot middot middot n with

Consider a valleyed array A[1, 2, · · · , n] with the property that the subarray A[1..i] has the property that A[j] > A[j + 1] for 1 ≤ j (a) What is a recursive algorithm that takes asymptotically sub-linear time to find ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As