0% found this document useful (1 vote)
353 views

Verilog Code For Sequence Generator

This code defines a sequence generator module that outputs a 4-bit sequence on each clock cycle. It uses a flip-flop to toggle the least and most significant bits on each clock edge, generating the sequence 1100, 1010, 1001, 0110 and repeating. A testbench is provided that instantiates the sequence generator and toggles a clock every 10 time units for 200 units to simulate its operation.

Uploaded by

hellohelula
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (1 vote)
353 views

Verilog Code For Sequence Generator

This code defines a sequence generator module that outputs a 4-bit sequence on each clock cycle. It uses a flip-flop to toggle the least and most significant bits on each clock edge, generating the sequence 1100, 1010, 1001, 0110 and repeating. A testbench is provided that instantiates the sequence generator and toggles a clock every 10 time units for 200 units to simulate its operation.

Uploaded by

hellohelula
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

Design code for sequence generator

module sequence_gen(op,clk);

input clk;
output [3:0]op;
reg [3:0]op;
initial
begin
op[3:0] = 4'b1100 ;
end
always @( posedge clk)
op <= {op[3]^op[1], op[3:1]};

endmodule

Testbench
module test_sequence_gen();
reg clk;
wire [3:0] op;

sequence_gen SG1 (op,clk);

initial
begin
clk=0;
forever #10 clk = ~clk;
end

initial
begin
#200
$finish;
end
endmodule

You might also like