From: Pit Capitain Date: 2006-02-17T21:17:46+09:00 Subject: Re: recontextualizing a block (looking for deep magic) Phil Tomson schrieb: > ... > > class Counter < RHDL > inputs :clk, :rst > outputs :count_out > variables :count=>0 > > define_behavior { > process(clk) { > if clk.event and clk == 1 > if rst == 1 > count = 0 > else > count += 1 > end > count_out << count > end > } > } > end > > ... > > However, notice the 'variables' method. The idea there is that there could be > some variables used in the define_behavior block (and this was the case with > the previous incarnation of RHDL, so I didn't want to lose that functionality). > Now by 'variable' here I mean that I want a variable that also has scope > within the define_behavior block. The define_behavior block will be called > many, many times during a simulation and I don't want the variable to be > re-initialzed on each call. > > ... Phil, I don't understand the usage of variables. When should they be initialized? What should be their scope (class, instance, thread, other)? Can't you use instance variables with accessor methods? Regards, Pit