LAB 3 Report
LAB 3 Report
input a, b, c, d;
begin
2'b00 : out = a;
2'b01 : out = b;
2'b10 : out = c;
2'b11 : out = d;
endcase
end
endmodule
TESTBENCH:
module mux_4x1_behav_tb();
reg a, b, c, d;
wire out;
integer i;
mux_4x1_behav DUT(a,b,c,d,s0,s1);
initial
begin
for (i=0;i<4;i=i+1)
begin
{s0,s1}=i;
#10;
end
end
endmodule
2.write behavioural description for 3:8 decoder and verify using test bench.
module decoder3to8(
Data_in,
Data_out
);
always @(Data_in)
case (Data_in)
endcase
endmodule
TESTBENCH:
module tb_decoder;
decoder3to8 uut (
.Data_in(Data_in),
.Data_out(Data_out)
);
initial begin
end
endmodule
3. Write an behavioural description and testbench 8:3 priority encoder.
module prienc8x3_behav(I,y,valid);
input [7:0]I;
output [2:0]y;
output valid;
always @(I)
begin
if(I[7]==1'b1) begin
y=3'b111;
valid=1'b1;
end
y=3'b110;
valid=1'b1;
end
y=3'b101;
valid=1'b1;
end
y=3'b100;
valid=1'b1;
end
y=3'b011;
valid=1'b1;
end
y=3'b010;
valid=1'b1;
end
elseif (I[1]==1'b1) begin
y=3'b001;
valid=1'b1;
end
y=3'b000;
valid=1'b1;
end
else
begin
y=3'bz;
valid=1'b0;
end
endmodule
TESTBENCH:
module prienc8x3_behav_tb();
reg [7:0]I;
wire [2:0]y;
wire valid;
prienc8x3_behav DUT(I,y,valid);
task init;
begin
I=0;
end
endtask
begin
I=i;
end
endtask
task delay;
begin
#10;
end
endtask
initial
begin
initialize;
prienc_inp(8'b10000100);
delay;
prienc_inp(8'b11100010);
delay;
end
initial
Endmodule