On 2/16/06, Phil Tomson <ptkwt / aracnet.com> wrote: > class Counter < RHDL > inputs :clk, :rst > outputs :count_out > variables :count=>0 > > define_behavior { # body of define_behavior references 'count' > } > end Recapping, your stated problem is that you need access to count in the block for define_behavior. > I suppose another way to do it would be to do: > > class Counter < RHDL > inputs :clk, :rst > outputs :count_out > > def initialize > count = 0 > define_behavior { > #.... do something with count ... > } > end > end > > This is sort of how RHDL is now. There's no need for a 'variables' method > since you just declare your variables in the 'initialize' method. I was trying > to get away from the explicit 'initialize' definition. Why not something like this then? class Counter < RHDL inputs :clk, :rst outputs :count_out count = 0 define_behavior { #.... do something with count ... } end Pretty much what it comes to is this: anycode you could put outside the class definition can also go inside the class definition. This includes local variables. It's just another scope in that manner. 'count' in the example above is a local variable that goes out of scope when you 'end' the class definition. The variable gets captured in the block to define_behavior, however, so it remains available there (and only there), keeping state between invocations of the block. Jacob Fugal