//Main module for control unit
module control(op,clk,rst,s,d,sd,alucon,decode);
input [9:0]op;
input clk;
output [2:0]s,d;
output [5:0]decode;
output [3:0]alucon;
output rst,sd;
reg [3:0]in;
reg [5:0]decode;
reg [9:0]r;
reg [3:0]alucon;
reg[2:0]s,d;
reg rst,sd;
initial
begin
decode=6'b100000;
end
always@(posedge clk)
begin
if(decode==6'b100000)
begin
in=op[9:6];
s=op[2:0];
r=op;
decode={1'b0,decode[5:1]};
case(in)
0 : begin//clr
rst=1'b1;
sd=1'b1;
d=3'b000;
alucon=4'b0000;
end
1 : begin//mov
rst=1'b0;
sd=1'b1;
d=op[5:3];
alucon=4'b0000;
end
2 : begin//add operation
rst=1'b0;
sd=1'b0;
d=3'b001;
alucon=4'b0001;
end
3 : begin//subtraction operation
rst=1'b0;
sd=1'b0;
d=3'b001;
alucon=4'b0010;
end
4 : begin//multiplication operation
rst=1'b0;
sd=1'b0;
d=3'b001;
alucon=4'b0011;
end
5 : begin//division operation
rst=1'b0;
sd=1'b0;
d=3'b001;
alucon=4'b0100;
end
6 : begin//and operation
rst=1'b0;
sd=1'b0;
d=3'b001;
alucon=4'b0101;
end
7 : begin//or operation
rst=1'b0;
sd=1'b0;
d=3'b001;
alucon=4'b0110;
end
8 : begin//xor operation
rst=1'b0;
sd=1'b0;
d=3'b001;
alucon=4'b0111;
end
9 : begin//left shfit
rst=1'b0;
sd=1'b0;
d=3'b001;
alucon=4'b1000;
end
10 : begin//right shift
rst=1'b0;
sd=1'b0;
d=3'b001;
alucon=4'b1001;
end
11 : begin//rotate left
rst=1'b0;
sd=1'b0;
d=3'b001;
alucon=4'b1010;
end
12 : begin//rotate right
rst=1'b0;
sd=1'b0;
d=3'b001;
alucon=4'b1011;
end
default: $display("invalid operation");
endcase
end
else if(decode==6'b0)
begin
if(r==op)
decode=6'b000000;
else
decode=6'b100000;
end
else
decode={1'b0,decode[5:1]};
end
endmodule
Please tell the full form of labels used :-
ReplyDeletes, sd, d, r
can you please send me the verilog code of floating point multiplier?
ReplyDeleteCan you please send me(tajmul.cuet@yahoo.com) the test bench of this code?
ReplyDelete