[myhdl-list] [newb] modelling question
Brought to you by:
jandecaluwe
From: Neal B. <ndb...@gm...> - 2009-02-20 19:40:51
|
Simple question. Model an accumulator. The accumulator has state (call it 'sum'). Most examples are an RTL style. My imitation of this style might be: def accum (x, result, _sum, count, clock, n): @always (clock.posedge) def accum_logic(x): _sum.next += x if count == n-1: result.next = _sum _sum.next = 0 return accum_logic _sum is an internal variable. Does it need to be one of the parameters passed to accum, as I showed above? Perhaps this could be: def accum (x, result, count, clock, n): _sum = Signal (0) @always (clock.posedge) def accum_logic(x): _sum.next += x if count == n-1: result.next = _sum _sum.next = 0 return accum_logic What if I prefer object oriented style? The manual mentions this (the fifo examples). I wonder if this style will work properly with the rest of myhdl? For example, there are some functions that 'infer' inputs and outputs. Does this work if I use this object-oriented style? There must be some constraints. |