You are on page 1of 14

module controlcircuit(A, B,C, s,m,pl, alu_out, cin);

input [7:0]A,B,C;
input cin;
input m;
input [2:0]pl;
LOGIC MODE SELECTION

//ARITHEMATIC &

input [3:0]s;

//SELECT INPUTS

wire [7:0]W1,W2,W3,W4,W5,W6,W7,W8,W10,W11,W13,W14,W17,W18;
wire [8:0]W9,W12,W15,W16,wi11;
wire [15:0]W19,W20,W21;

wire [7:0]wi1,wi2,wi3,wi4,wi5,wi6,wi7,wi8,wi9,wi10,wi12;

output [15:0]alu_out;
mux16_1 U1(W1, W2,W3,W4, W5,W6,wi1,wi2,wi3,wi4,wi5,wi6,wi7,wi8,wi9,wi10,s,W20);
//

0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15

mux16_1 U2 (W7,W8,W9,W10,W11,W12,W13,W14,W15,W16,W17,W18,W19,0,wi11,wi12,s,W21);

or_gt U3(A,B,W1);
and_gt U4(A,B,W2);
nor_gt U5(A,B,W3);
nand_gt U6(A,B,W4);
xor_gt U7(A,B,W5);
xnor_gt U8(A,B,W6);

inhibition_abyb_gt E1(A,B,wi1);
implication_abyb_gt E2(A,B,wi2);
inhibition_bbya_gt E3(A,B,wi3);
implication_bbya_gt E4(A,B,wi4);
nand3_gt E5(A,B,C,wi5);
nor3_gt E6(A,B,C,wi6);
or3_gt E7(A,B,C,wi7);
and3_gt E8(A,B,C,wi8);
xor3_gt E9(A,B,C,wi9);
xnor3_gt E10(A,B,C,wi10);

not_gt U9(A,W7);
buff_gt U10(A,W8);
incrementby_one U11(A,W9);
decrementbyone U12(A,W10);
left_shift U13(A,W11);
right_shift U14(A,W12);
rotate_leftt U15(A,cin,W13);
rotate_right U16(A,cin,W14);
add_withoutcarry U17(A,B,W15);
add_withcarry U18(A,B,cin,W16);
substraction_withoutborrow U19(A,B,W17);

substraction_withborrow U20(A,B,cin,W18);
multiplicationof_two8bitnumbers U21(A,B,W19);

twoscomplement E11(A,wi11);
bitmodify E12(A,cin,pl,wi12);

mux2_1 U22(W20,W21,m,alu_out);
endmodule
module mux16_1(i0,i1,i2,i3,i4,i5,i6,i7,i8,i9,i10,i11,i12,i13,i14,i15,s,y);
input [15:0]i0,i1,i2,i3,i4,i5,i6,i7,i8,i9,i10,i11,i12,i13,i14,i15;
input [3:0]s;
output [15:0]y;
reg [15:0]y;
always@(*)
begin
if(s==0)
y=i0;
else if (s==1)
y=i1;
else if (s==2)
y=i2;
else if (s==3)
y=i3;
else if (s==4)
y=i4;

else if (s==5)
y=i5;
else if (s==6)
y=i6;
else if (s==7)
y=i7;
else if (s==8)
y=i8;
else if (s==9)
y=i9;
else if (s==10)
y=i10;
else if (s==11)
y=i11;
else if (s==12)
y=i12;
else if (s==13)
y=i13;
else if (s==14)
y=i14;
else if (s==15)
y=i15;
end
endmodule

/////////////////////////////////////////////////////////////////////////////
module or_gt(a,b, y1);
input [7:0] a,b;
output [7:0] y1;
assign y1=a|b;
endmodule
////////////////////////////////////////////
module and_gt(a,b, y2);
input [7:0] a,b;
output [7:0] y2;
assign y2=a&b;
endmodule
///////////////////////////////////////////
module nor_gt(a,b, y3);
input [7:0] a,b;
output [7:0] y3;
assign y3=~(a|b);
endmodule
////////////////////////////////////////////
module nand_gt(a,b, y4);
input [7:0] a,b;
output [7:0] y4;
assign y4=~(a&b);
endmodule
/////////////////////////////////////////////////

module xor_gt(a,b, y5);


input [7:0] a,b;
output [7:0] y5;
assign y5=a^b;
endmodule
////////////////////////////////////////////
module xnor_gt(a,b, y6);
input [7:0] a,b;
output [7:0] y6;
assign y6=~(a^b);
endmodule
////////////////////////////////////////////
module inhibition_abyb_gt(a,b,ye1);
input [7:0] a,b;
output [7:0] ye1;
assign ye1=(a)&(~b);
endmodule
//////////////////////////////////////////////
module implication_abyb_gt(a,b,ye2);
input [7:0] a,b;
output [7:0] ye2;
assign ye2=(a)|(~b);
endmodule
/////////////////////////////////////////////
module inhibition_bbya_gt(a,b,ye3);

input [7:0] a,b;


output [7:0] ye3;
assign ye3=(~a)&(b);
endmodule
//////////////////////////////////////////////
module implication_bbya_gt(a,b,ye4);
input [7:0] a,b;
output [7:0] ye4;
assign ye4=(~a)|(b);
endmodule
///////////////////////////////////////////////////////////////////////////
module nand3_gt(a,b,c, ye5);
input [7:0] a,b,c;
output [7:0] ye5;
assign ye5=~((a&b)&c);
endmodule
//////////////////////////////////////////////////////////////////////////
module nor3_gt(a,b,c, ye6);

input [7:0] a,b,c;


output [7:0] ye6;
assign ye6=~((a|b)|c);
endmodule
////////////////////////////////////////////////////////////////////////////////////////////
module or3_gt(a,b,c, ye7);

input [7:0] a,b,c;


output [7:0] ye7;
assign ye7=(a|b|c);
endmodule
/////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////
module and3_gt(a,b,c, ye8);
input [7:0] a,b,c;
output [7:0] ye8;
assign ye8=(a&b&c);
endmodule
//////////////////////////////////////////////////////////////////////////////////
module xor3_gt(a,b,c, ye9);

input [7:0] a,b,c;


output [7:0] ye9;
assign ye9=(a^b^c);
endmodule
//////////////////////////////////////////////////////////////////////////////////
module xnor3_gt(a,b,c, ye10);

input [7:0] a,b,c;


output [7:0] ye10;
assign ye10=~(a^b^c);
endmodule

//////////////////////////////////////////////////////////////////////////////////
module not_gt(a,y7);
input [7:0] a;
output [7:0] y7;
assign y7=~a;
endmodule
//////////////////////////////////////////////////////////////////////////////////
module buff_gt(a,y8);
input [7:0]a;
output [7:0]y8;
assign y8= a;
endmodule
//////////////////////////////////////////////////////////////////////////////////
module incrementby_one(a,y9);
input [7:0]a;
output [8:0]y9;
assign y9=(a+8'b00000001);
endmodule
//////////////////////////////////////////////////////////////////////////////////
module decrementbyone(a,y10);
input [7:0]a;
output [7:0]y10;
assign y10=(a-8'b00000001);
endmodule
//////////////////////////////////////////////////////////////////////////////////

module left_shift(a,y11);
input [7:0]a;
output [7:0]y11;
assign y11={a[6:0],1'b0};
endmodule
//////////////////////////////////////////////////////////////////////////////////
module right_shift(a,y12);
input [7:0]a;
output [8:0]y12;
assign y12={a[0],1'b0,a[7:1]};
endmodule
//////////////////////////////////////////////////////////////////////////////////
module rotate_leftt(a,cin,y13);
input [7:0]a;
input cin;
output [7:0]y13;
assign y13={a[7:0],cin};
endmodule
//////////////////////////////////////////////////////////////////////////////////

module rotate_right(a,cin,y14);
input [7:0]a;
input cin;
output [7:0]y14;
assign y14={a[0],cin,a[7:1]};

endmodule
//////////////////////////////////////////////////////////////////////////////////
module add_withoutcarry(a,b,sum);
input [7:0]a,b;
output [8:0]sum;
assign sum=(a+b);
endmodule
//////////////////////////////////////////////////////////////////////////////////
module add_withcarry(a,b,cin,sum);
input [7:0]a,b;
input cin;
output [8:0]sum;
assign sum=(a+b+cin);
endmodule
//////////////////////////////////////////////////////////////////////////////////
module substraction_withoutborrow(a,b,diff);
input [7:0]a,b;
output [7:0]diff;
assign diff=(a-b);
endmodule
//////////////////////////////////////////////////////////////////////////////////
module substraction_withborrow(a,b,cin,diff);
input [7:0]a,b;
input cin;
output [7:0]diff;

assign diff=(a-b+(~cin));
endmodule
//////////////////////////////////////////////////////////////////////////////////
module multiplicationof_two8bitnumbers(a,b,value);
input [7:0]a,b;
output [15:0]value;
assign value=(a*b);
endmodule
//////////////////////////////////////////////////////////////////////////////////
This place for division try it out >>>>>>>>>>>>

///////////////////////////////////////////////////////////////////////////////////////
module twoscomplement(a,ye11);

input [7:0]a;
output [8:0]ye11;
wire [7:0]w;
assign w=(~a);
assign ye11=(w+8'b00000001);
endmodule
//////////////////////////////////////////////////////////////////////////////////
module bitmodify(a,c,place,modify);
input [7:0]a;

input c;
input [2:0]place;
output reg [7:0]modify;
always@(*)
begin
if (place==0)
assign modify={a[7:1],c};
else if (place==1)
assign modify={a[7:2],c,a[0]};
else if (place==2)
assign modify={a[7:3],c,a[1:0]};
else if (place==3)
assign modify={a[7:4],c,a[2:0]};
else if (place==4)
assign modify={a[7:5],c,a[3:0]};
else if (place==5)
assign modify={a[7:6],c,a[4:0]};
else if (place==6)
assign modify={a[7],c,a[5:0]};
else if (place==7)
assign modify={c,a[6:0],c};
end
endmodule

//////////////////////////////////////////////////////////////////////////////////

module mux2_1(i0,i1,s,y);
input [15:0]i0,i1;
input s;
output [15:0]y;
reg [15:0]y;
always@(*)
begin if(s==0)
y=i0;
else if(s==1)
y=i1;
end
endmodule
//////////////////////////////////////////////////////////////////////////////////////////////////

You might also like