Assignment #1, Due April 18th

Prerequisite

Before you start this project, you should complete this tutorial.

Project

You are to design using Verilog a controller/datapath that accepts as input a number n on the port input_s, and a clock to drive the controller FSM, and outputs fibo_out, the nth Fibonacci number, some number of clocks later. 

The nth Fibonacci number is the sum of the (n-1)th and (n-2)th Fibonacci number, and the first two numbers in the sequence are 1 and 1.  So the Fibonacci sequence is:

A reset signal is necessary to initialize the first two numbers of the sequence to 1 and 1 when reset is high.  Your reset can be asynchronous or synchronous.  Your design should accept the input value of n on the port input_s when a start signal called begin_fibo is high and reset is low.  After begin_fibo transitions from low to high, the design does not require any more inputs other than the clock clk.  The output consists of the nth Fibonacci number on the port fibo_out and a done signal of 1 indicates that the output is valid.  When the done signal is 0, then output can be anything. 

The 23rd Fibonacci number is 46,368 (b520 in hex), which is the largest number you are required to generate.  So the input is 5 bits wide (to accomodate the number 23), while the output is 16 bits wide (to accomodate 46,368).  A list of the first 24 Fibonacci numbers is provided for you.  The testbench that you write to test your design should have at least three different values of input_s and these should differ from each other by at least 4.  Your timing diagram should show the testing of each of the three input_s values.

 Note:Your fibonacci calculator must calculate the nth fibonacci number.   Using a ROM with stored fibonacci numbers is not permitted.

Synthesis note: The loop limit for a for loop or a while loop cannot be variable.  The loop limit must be constant.

Synthesis note:While in general, functions are synthesizable, recursive functions are not.

You should use this module declaration:

                     module fibonacci_calculator (input_s, reset, begin_fibo, clk, done, fibo_out) ;
                         input  [4:0] input_s ;
                         input  reset ;
                         input  begin_fibo ;
                         input  clk ;
                         output done ;
                         output [15:0] fibo_out ;  
                     endmodule

If you use state machine design style 1, no registers will be synthesized in the combinational (unclocked) always block.  You will need to instantiate the needed registers to hold the n-1 and n-2 fibonacci number to be included with your state machine in your fibonacci module.  To use a single process to do the algorithm and synthesize the needed registers, you can use state machine design style 4, where signals assigned to in the clocked process are synthesized as registers.  You can code the datapath operations in the state machine, which is called the functional rtl design style.  An example is functional_rtl.v,

Signals, unless optimized out by the synthesis tool, that assigned to in an unclocked always block, will be synthesized as wires if no memory is inferred or as latches if memory is inferred.  To avoid unwanted latches from the use of unclocked always blocks, signals assigned to in the unclocked process should be assigned a value for each branch in an if or case statement to avoid inferring memory.  Signals, unless optimized out by the synthesis too, that are assigned to in a clocked always block, will be synthesized as registers.

The grading criteria for this project will be correctness.  If the design performs correctly and you turn in the items listed below, that is enough.  For this project, criteria such as design area and delay will not be considered in the grading. To complete this project, you should hand in:

  1. Hard copy of your Verilog HDL source code for the fibonacci module


  2. Hard copy of your Verilog HDL testbench source code to test the fibonacci module


  3. Hard copy of the timing diagram


  4. Hard copy of area report


  5. Hard copy of the timing report




April 18, 2002