Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Simulate the following program by converting each instruction to corresponding machine code. Then store the machine code in memory starting from location 1 0 :

Simulate the following program by converting each instruction to corresponding machine code. Then store the
machine code in memory starting from location 10: module SIMCOMP (clock, PC, IR, MBR, AC, MAR);
input clock;
output PC, IR, MBR, AC, MAR;
reg [15:0] IR, MBR, AC;
reg [11:0] PC, MAR;
reg [15:0] Memory [0:63];
reg [2:0] state;
parameter load =4'b0011, store=4'b1011, add=4'b0111;
initial begin
// program
Memory [10]=16'h3020;
Memory [11]=16'h7021;
Memory [12]=16'hB014;
// data at byte addres
Memory [32]=16'd7;
Memory [33]=16'd5;
//set the program counter to the start of
PC =10; state =0;
end
always @(posedge clock) begin
case (state)
0: begin
MAR = PC;
state=1;
end
1: begin // fetch the instruction from mem
IR = Memory[MAR];
PC = PC +1;
state=2; //next state
end
2: begin //Instruction decode
MAR =IR[11:0];
state=3;
end
3: begin // Operand fetch
state=4;
case (IR[15:12])
load : MBR = Memory[MAR] ;
add : MBR = Memory[MAR] ;
store: MBR=AC;
endcase
end
4: begin //execute
if (IR[15:12]==4'h7) begin
AC= AC+MBR;
state =0;
end
else if (IR [15:12]==4'h3) begin
AC = MBR;
state =0; // next state
end
else if (IR[15:12]==4'hB) begin
Memory[ MAR]= MBR;
state =0;
end
end
endcase
end
endmodule
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Marketing The Ultimate Marketing Tool

Authors: Edward L. Nash

1st Edition

0070460639, 978-0070460638

More Books

Students also viewed these Databases questions

Question

Please help me evaluate this integral. 8 2 2 v - v

Answered: 1 week ago