CS Electrical And Electronics
@cselectricalandelectronics

Write a verilog code for Mealy?

All QuestionsCategory: VerilogWrite a verilog code for Mealy?
CS Electrical And Electronics Staff asked 4 years ago

I need code.

1 Answers
CS Electrical And Electronics Staff answered 4 years ago

module mealyprog_tb;

// Inputs

reg CLK;
reg RST;
reg x;

// Outputs

wire z;

// Instantiate the Unit Under Test (UUT)

mealyprog uut (
.CLK(CLK),
.RST(RST),
.x(x),
.z(z)
);
initial begin

// Initialize Inputs

CLK = 0;
RST = 0;
x = 0;

// Wait 100 ns for global reset to finish

#100;

// Add stimulus here

#10 x=1;
#10 x=0;
#10 x=0;
#10 x=1;
#10 x=1;
#10 x=0;
#10 x=1;
#10 x=0;
#10 x=0;
#10 x=0;
#10 x=1;
#10 x=1;

end
always @(x)
begin
forever #5 CLK=~CLK;
end
endmodule

//TEST BENCH

module mealyprog_tb;

// Inputs

reg CLK;
reg RST;
reg x;

// Outputs

wire z;

// Instantiate the Unit Under Test (UUT)

mealyprog uut (
.CLK(CLK),
.RST(RST),
.x(x),
.z(z)
);
initial begin

// Initialize Inputs

CLK = 0;
RST = 0;
x = 0;

// Wait 100 ns for global reset to finish

#100;

// Add stimulus here

#10 x=1;
#10 x=0;
#10 x=0;
#10 x=1;
#10 x=1;
#10 x=0;
#10 x=1;
#10 x=0;
#10 x=0;
#10 x=0;
#10 x=1;
#10 x=1;
end
always @(x)
begin
forever #5 CLK=~CLK;
end
endmodule