aboutsummaryrefslogtreecommitdiff
path: root/examples/smoke_test/FibOne.bsv
blob: 64c65b4fb338f5ee8e92e38ee0ff926f37ac4974 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
(* synthesize *)
module mkFibOne();
   // register containing the current Fibonacci value
   Reg#(int) this_fib();              // interface instantiation
   mkReg#(0) this_fib_inst(this_fib); // module instantiation
   // register containing the next Fibonacci value
   Reg#(int) next_fib();
   mkReg#(1) next_fib_inst(next_fib);

   rule fib;  // predicate condition always true, so omitted
      this_fib <= next_fib;
      next_fib <= this_fib + next_fib;  // note that this uses stale this_fib
      $display("%0d", this_fib);
      if ( this_fib > 10000 ) $finish(0) ;
  endrule: fib
endmodule: mkFibOne