Decoder by using 74 138
Program Code :
module simpledecoder(
input [1:0] A,
output reg [3:0] O
);
always @*
begin
case(A)
2'b00: O<=4'b0001;
2'b01: O<=4'b0010;
2'b10: O<=4'b0100;
2'b11: O<=4'b1000;
default O<=4'b0000;
endcase
end
endmodule
Simple Decoder 2 by 2 using Structural Modelling :module simpledecoderusingstructuralm(
input [1:0] A,
output [3:0] O
);
Decoder 3 to 8 using CASE Statementmodule decoder3to8usingbehavioural(
input [2:0] A,
output reg [7:0] O,
input [0:0] EI
);
Program Code :
module simpledecoder(
input [1:0] A,
output reg [3:0] O
);
always @*
begin
case(A)
2'b00: O<=4'b0001;
2'b01: O<=4'b0010;
2'b10: O<=4'b0100;
2'b11: O<=4'b1000;
default O<=4'b0000;
endcase
end
endmodule
Simple Decoder using DATA FLOW MODELLING 2 by 2 Decoder
module simpledecoder(
input [1:0] A,
output reg [3:0] O
);
always @*
begin
case(A)
2'b00: O<=4'b0001;
2'b01: O<=4'b0010;
2'b10: O<=4'b0100;
2'b11: O<=4'b1000;
default O<=4'b0000;
endcase
end
endmodule
input [1:0] A,
output reg [3:0] O
);
always @*
begin
case(A)
2'b00: O<=4'b0001;
2'b01: O<=4'b0010;
2'b10: O<=4'b0100;
2'b11: O<=4'b1000;
default O<=4'b0000;
endcase
end
endmodule
Simple Decoder 2 by 2 using Structural Modelling :module simpledecoderusingstructuralm(
input [1:0] A,
output [3:0] O
);
decode call(A,O);
endmodule
module decode(
input [1:0]a,
output reg [3:0]o
);
always@*
begin
if(a==2'b00)
o<=4'b0001;
if(a==2'b01)
o<=4'b0010;
if(a==2'b10)
o<=4'b0100;
if(a==2'b11)
o<=4'b1000;
end
endmodule
module decode(
input [1:0]a,
output reg [3:0]o
);
always@*
begin
if(a==2'b00)
o<=4'b0001;
if(a==2'b01)
o<=4'b0010;
if(a==2'b10)
o<=4'b0100;
if(a==2'b11)
o<=4'b1000;
end
endmodule
3 to 8 Decoder Using Behavioural Modellingmodule decoder3to8activehigh(
input [2:0] A,
output reg [7:0] O,
input [0:0] EI
);
wire a,b,c;
assign a=A[0],
b=A[1],
c=A[2];
always@*
input [2:0] A,
output reg [7:0] O,
input [0:0] EI
);
wire a,b,c;
assign a=A[0],
b=A[1],
c=A[2];
always@*
if(EI)
begin
O<=8'b00000000;
O[7]<=a&b&c;
O[6]<=a&b&(~c);
O[5]<=a&(~b)&c;
O[4]<=a&(~b)&(~c);
O[3]<=(~a)&b&c;
O[2]<=(~a)&b&(~c);
O[1]<=(~a)&(~b)&c;
O[0]<=(~a)&(~b)&(~c);
end
endmodule
begin
O<=8'b00000000;
O[7]<=a&b&c;
O[6]<=a&b&(~c);
O[5]<=a&(~b)&c;
O[4]<=a&(~b)&(~c);
O[3]<=(~a)&b&c;
O[2]<=(~a)&b&(~c);
O[1]<=(~a)&(~b)&c;
O[0]<=(~a)&(~b)&(~c);
end
endmodule
Decoder 3 to 8 using CASE Statementmodule decoder3to8usingbehavioural(
input [2:0] A,
output reg [7:0] O,
input [0:0] EI
);
always @*
if(EI)
begin
case(A)
3'b000: O<=8'b00000001;
3'b001: O<=8'b00000010;
3'b010: O<=8'b00000100;
3'b011: O<=8'b00001000;
3'b100: O<=8'b00010000;
3'b101: O<=8'b00100000;
3'b110: O<=8'b01000000;
3'b111: O<=8'b10000000;
default O<=8'b00000000;
endcase
end
else
O<=8'b00000000;
endmodule
if(EI)
begin
case(A)
3'b000: O<=8'b00000001;
3'b001: O<=8'b00000010;
3'b010: O<=8'b00000100;
3'b011: O<=8'b00001000;
3'b100: O<=8'b00010000;
3'b101: O<=8'b00100000;
3'b110: O<=8'b01000000;
3'b111: O<=8'b10000000;
default O<=8'b00000000;
endcase
end
else
O<=8'b00000000;
endmodule
74138 Decoder using Case statement
module decoder74138usingbehaviouralmodelling(
input [2:0] A,
output reg [7:0] O_L,
input [0:0] G1,
input [0:0] G2A_L,
input [0:0] G2B_L
);
always @*
if(G1&(~G2A_L)&(~G2B_L))
begin
case(A)
3'b000: O_L<=8'b11111110;
3'b001: O_L<=8'b11111101;
3'b010: O_L<=8'b11111011;
3'b011: O_L<=8'b11110111;
3'b100: O_L<=8'b11101111;
3'b101: O_L<=8'b11011111;
3'b110: O_L<=8'b0111111;
3'b111: O_L<=8'b01111111;
default O_L<=8'b11111111;
endcase
end
else
O_L<=8'b11111111;
endmodule
input [2:0] A,
output reg [7:0] O_L,
input [0:0] G1,
input [0:0] G2A_L,
input [0:0] G2B_L
);
always @*
if(G1&(~G2A_L)&(~G2B_L))
begin
case(A)
3'b000: O_L<=8'b11111110;
3'b001: O_L<=8'b11111101;
3'b010: O_L<=8'b11111011;
3'b011: O_L<=8'b11110111;
3'b100: O_L<=8'b11101111;
3'b101: O_L<=8'b11011111;
3'b110: O_L<=8'b0111111;
3'b111: O_L<=8'b01111111;
default O_L<=8'b11111111;
endcase
end
else
O_L<=8'b11111111;
endmodule
3 to 8 encoder using Data Flow modelling
module decoder74138dataflow(
input [2:0] A,
output [7:0] O,
input [0:0] G1,
input [0:0] G2A,
input [0:0] G2B
);
wire a,b,c;
assign a=A[2],
b=A[1],
c=A[0];
assign O[0]=~((G1)&(~G2A)&(~G2B)&(~a)&(~b)&(~c));
assign O[1]=~((G1)&(~G2A)&(~G2B)&(~a)&(~b)&(c));
assign O[2]=~((G1)&(~G2A)&(~G2B)&(~a)&(b)&(~c));
assign O[3]=~((G1)&(~G2A)&(~G2B)&(~a)&(b)&(c));
assign O[4]=~((G1)&(~G2A)&(~G2B)&(a)&(~b)&(~c));
assign O[5]=~((G1)&(~G2A)&(~G2B)&(a)&(~b)&(c));
assign O[6]=~((G1)&(~G2A)&(~G2B)&(a)&(b)&(~c));
assign O[7]=~((G1)&(~G2A)&(~G2B)&(a)&(b)&(c));
input [2:0] A,
output [7:0] O,
input [0:0] G1,
input [0:0] G2A,
input [0:0] G2B
);
wire a,b,c;
assign a=A[2],
b=A[1],
c=A[0];
assign O[0]=~((G1)&(~G2A)&(~G2B)&(~a)&(~b)&(~c));
assign O[1]=~((G1)&(~G2A)&(~G2B)&(~a)&(~b)&(c));
assign O[2]=~((G1)&(~G2A)&(~G2B)&(~a)&(b)&(~c));
assign O[3]=~((G1)&(~G2A)&(~G2B)&(~a)&(b)&(c));
assign O[4]=~((G1)&(~G2A)&(~G2B)&(a)&(~b)&(~c));
assign O[5]=~((G1)&(~G2A)&(~G2B)&(a)&(~b)&(c));
assign O[6]=~((G1)&(~G2A)&(~G2B)&(a)&(b)&(~c));
assign O[7]=~((G1)&(~G2A)&(~G2B)&(a)&(b)&(c));
endmodule
Comments
Post a Comment