Re: [myhdl-list] Unable to get a counter working
Brought to you by:
jandecaluwe
From: Andrew L. <bs...@al...> - 2008-08-18 18:47:51
|
Jan Decaluwe wrote: > Andrew Lentvorski wrote: >> Could someone please explain to me what I'm doing wrong? I'm trying to >> implement what would be a basic PC counter in a microprocessor. The >> stage has two def's: pc_logic which should basically just be a >> combinatorial adder and pc_flops which captures the state of the >> combinatorial logic on an edge. >> >> Why doesn't this work? Worse, why does the one commented line throw a >> UboundLocalError error? > > See Gunter's post for the answer in a MyHDL context. > > For clarity, I would like to add that the issue is conceptually not related > to something MyHDL-specific, but to the semantics of assignment and > local namespaces in Python. These work differently than in many other > languages and it is important to understand this clearly. See also: > > http://www.network-theory.co.uk/docs/pytut/PythonScopesandNameSpaces.html Thanks for the reference. The decorator is clearly doing something behind the scenes that I need to think about. There's no question that a lot of my issues are stupid. Both in terms of being dumb mistakes (assigning to the variable rather than the attribute) as well as due to having a faulty mental model of how MyHDL works. I'll get there, but I'm definitely losing some productivity relative to my ability to write verilog. Hopefully, I'll see some of that gained back in writing tests. -a |