[myhdl-list] Johnson counter page
Brought to you by:
jandecaluwe
From: George P. <ge...@ga...> - 2006-01-10 22:35:37
|
Thanks for the example of the Johnson Counter. http://myhdl.jandecaluwe.com/doku.php/cookbook:jc2 Could you have used an @always block if you pulled the state variables out of the logic() function and put them in the enclosing scope, as illustrated below? I noticed that the state variables are not manipulated by the .next operator, but instead directly assigned (combinatorially, as you say). I didn't know this was possible with variables that would end up in the verilog output! Please tell us more about your preferred coding style and why you recommend it! Thanks, George from myhdl import * ACTIVE = 0 DirType = enum('RIGHT', 'LEFT') def jc2(left,right,stop,clk,q): ... ... ... dir = Signal(DirType.LEFT) run = Signal(bool(False)) @always(clk.posedge) def logic(): if right == ACTIVE: dir = DirType.RIGHT run = True ... ... ... return instances() |