VERILOG MODULE module fibonacci(clock,reset,value); input clock,reset; output [31:0]value; reg [31:0]previous,current; //Reset the circuit always@(posedge reset)
begin previous<=32d0; current<=32d1; end always@(posedge clock) begin //increment current index current=current+previous; previous=current-previous; end //Read the value of the nth fibonacci number assign value=previous; endmodule
TEST BENCH module fibtb(); reg clock,reset; wire [31:0]value; fibonacci f1(value,clock,reset); initial begin reset=1; #10 reset=0; end initial begin clock=0; forever #10 clock=~clock; end initial begin #500 $finish; end endmodule
OUTPUT