-
We have an
always
block that is sensitive to the rising edge of the clock (clk
) and the rising edge of the reset signal (rst
). -
Inside the
always
block, when the reset signal (rst
) is asserted, we initialize the Fibonacci sequence with the first two Fibonacci numbers (1 and 1) and reset temporary storage variables. -
During normal operation (when not in reset), we update the current Fibonacci number (
current
) with the next Fibonacci number (next
) and calculate the newnext
value by adding the current value to the previous Fibonacci number (fib_1
). We also update the temporary storage variablesfib_1
andfib_2
. -
The
fib
output wire provides the current Fibonacci number for external use.
Make sure to connect this module to your clock and reset signals appropriately in your larger Verilog design. Additionally, you may need to modify the data width of the fib
output and internal variables to suit your specific requirements.