3. 14 marks) In this assignment you will design an arithmetie logie unit (ALU) w
ID: 2267655 • Letter: 3
Question
3. 14 marks) In this assignment you will design an arithmetie logie unit (ALU) which can be used readily in a MIPS processor. In particular, we focus on the arithmetic logic instructions among MIPS R-type instructions. Each machine instruction in a MIPS processor has a 6 bit field called F(denoted briefly by F here). A MIPS coupatible ALU takes Fso as a control input. This control input determines the relation between the data inputs A and B, and the output Y as per Table 4, which is a part of the set of MIPS R-type instructions A step by step design process is described in the ecture slides. Note that the ALU hardware inclades an adder. For this assignment you are Eree to choose any adder implementatio including the behavioural one using System Verikg operator. (8 marks) Design an n bit wide parameterized ALU module as per Table 4. The ALU should have two additional outputs Cod and OV to flag the carry out and arithmetic overflow in arithmetic operations. (6 marks) Design an appropriate test-bench to sinnalate the functionality of your de- signed circuit on some simulator like Modelsim. 0000 A+ 0001 AB (unsigned addition) 0010 A-(signed subtraction) 00 A-B (unsigned subtraction) 0100 A& B (AND) 0101 AB (OR) 0110 | A eB (XOR) 0111 (AB) (NOR) 1010 | if(AExplanation / Answer
Design of ALU: i have implemented this alu code in xlinx vivado 2016.2 ...the code is as follows with respect to the table given:
module all(
input a,
input b,
input cin,
input [3:0] f,
output y,
output cout,
output ov
);
reg y,cout,ov;
always@(f)
begin
if(f==4'b0000)
{cout,y}=a+b+cin;
else if(f==4'b0001)
{cout,y}=a+b+cin;
else if(f==4'b0010)
{ov,y}=a-b;
else if(f==4'b0011)
{ov,y}=a-b;
else if(f==4'b0100)
y=a&b;
else if(f==4'b0101)
y=a|b;
else if(f==4'b0110)
y=a^b;
else if(f==4'b0111)
y=~(a|b);
else if(f==4'b1010)
begin
if(a<b)
y=1;
else
y=0;
end
else if(f==4'b1011)
begin
if(a<b)
y=1;
else
y=0;
end
Test bench:
i have simulated the code for two test vector that is for additon(f=0001) and subtraction(f=0010) ...if you want for other values of F for arbitarary values of A and B(either 0 or 1),just put the values of F and A and B in always statement and run the test bench.
module all_tb();
reg a;
reg b;
reg cin;
reg [3:0]f;
wire y;
wire cout;
wire ov;
all UUT(a,b,cin,f,y,cout,ov);
initial
begin
f=4'b0000;a=1'b0;b=1'b0;cin=1'b0;
end
always
begin
#5 f=4'b0001;a=1'b1;b=1'b1;
#5 f=4'b0010;a=1'b0;b=1'b1;
end
endmodule
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.