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

  Identifies the cost of computer

identifies the cost of computer components to configure a computer system (including all peripheral devices where needed) for use in one of the following four situations:

  Input devices

Compare how the gestures data is generated and represented for interpretation in each of the following input devices. In your comparison, consider the data formats (radio waves, electrical signal, sound, etc.), device drivers, operating systems suppo..

  Cores on computer systems

Assignment : Cores on Computer Systems:  Differentiate between multiprocessor systems and many-core systems in terms of power efficiency, cost benefit analysis, instructions processing efficiency, and packaging form factors.

  Prepare an annual budget in an excel spreadsheet

Prepare working solutions in Excel that will manage the annual budget

  Write a research paper in relation to a software design

Research paper in relation to a Software Design related topic

  Describe the forest, domain, ou, and trust configuration

Describe the forest, domain, OU, and trust configuration for Bluesky. Include a chart or diagram of the current configuration. Currently Bluesky has a single domain and default OU structure.

  Construct a truth table for the boolean expression

Construct a truth table for the Boolean expressions ABC + A'B'C' ABC + AB'C' + A'B'C' A(BC' + B'C)

  Evaluate the cost of materials

Evaluate the cost of materials

  The marie simulator

Depending on how comfortable you are with using the MARIE simulator after reading

  What is the main advantage of using master pages

What is the main advantage of using master pages. Explain the purpose and advantage of using styles.

  Describe the three fundamental models of distributed systems

Explain the two approaches to packet delivery by the network layer in Distributed Systems. Describe the three fundamental models of Distributed Systems

  Distinguish between caching and buffering

Distinguish between caching and buffering The failure model defines the ways in which failure may occur in order to provide an understanding of the effects of failure. Give one type of failure with a brief description of the failure

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