Re: [myhdl-list] attribute enum_encoding: string;
Brought to you by:
jandecaluwe
From: Christopher F. <chr...@gm...> - 2013-09-05 02:57:17
|
The following works without issue: from myhdl import * def m_think(clock,reset,thinking,sending,sent): states = enum('IDLE', 'THINK', 'SEND_CMD', 'ADVANCE') state = Signal(states.IDLE) @always_seq(clock.posedge, reset=reset) def rtl(): thinking.next = False sending.next = False if state == states.IDLE: state.next = states.THINK elif state == states.THINK: thinking.next = True state.next = states.SEND_CMD elif state == states.SEND_CMD: sending.next = True state.next = states.ADVANCE elif state == states.ADVANCE: sent.next = sent+1 state.next = states.IDLE else: assert False, "Invalid states %s"%(state) return rtl def convert(): clock = Signal(bool(0)) reset = ResetSignal(0,active=0,async=True) thinking = Signal(bool(0)) sending = Signal(bool(0)) sent = Signal(intbv(0,min=0,max=10e12)) toVHDL(m_think,clock,reset,thinking,sending,sent) if __name__ == '__main__': convert() >> ghdl -a pck_myhdl_09.vhd m_think.vhd >> ghdl -e m_think https://bitbucket.org/cfelton/examples/src/tip/state_machines/example1.py?at=default Note, I didn't test that the above example worked functionally. I just put it together to demonstrate the "enum" type in VHDL is working. In addition I am using a development snapshot but there hasn't been any changes in this area in the development, it is identical to the 0.8. Regards, Chris On 9/3/13 2:48 PM, David Holl wrote: > Hello, When using ghdl for syntax checks, I get the following error for > any state machine where encoding="one_hot": > pcie_drx.vhd:137:11: no declaration for "enum_encoding" > > I can resolve ghdl's complaints by adding > Â attribute enum_encoding: string; > to the generated .vhd file. > > Is there a way to have this line included automatically in .vhd output? > Â I could add it via a shell script, but I'm wondering if there is > "better way" to do it. Â (or is GHDL in error?) > > > For example, here is an trimmed-down excerpt from the top of the .vhd > file showing where I add the line: > > package pck_pcie_drx is > Â Â attribute enum_encoding: string; Â <--- I need to add this line. > > Â Â type t_enum_t_state_22 is ( > > Â Â IDLE, > > Â Â THINK, > > Â Â SEND_CMD, > > Â Â ADVANCE > > ); > > attribute enum_encoding of t_enum_t_state_22: type is "0001 0010 > 0100 1000"; > > Â Â type t_enum_t_state_23 is ( > Â Â CMD, > Â Â MWR_H0H1, > Â Â MWR32_H2D0, > Â Â MWR32_D1D2, > Â Â MWR32_D3XX, > Â Â MWR64_H2H3, > Â Â MWR64_D0D1, > Â Â DROP > ); > attribute enum_encoding of t_enum_t_state_23: type is "00000001 > 00000010 00000100 00001000 00010000 00100000 01000000 10000000"; > end package pck_pcie_drx; > library IEEE; > etc... > > > > > - David > Â ps: Â Thank you for the fantastic MyHDL. > > > > ------------------------------------------------------------------------------ > Learn the latest--Visual Studio 2012, SharePoint 2013, SQL 2012, more! > Discover the easy way to master current and previous Microsoft technologies > and advance your career. Get an incredible 1,500+ hours of step-by-step > tutorial videos with LearnDevNow. Subscribe today and save! > http://pubads.g.doubleclick.net/gampad/clk?id=58040911&iu=/4140/ostg.clktrk > > > > _______________________________________________ > myhdl-list mailing list > myh...@li... > https://lists.sourceforge.net/lists/listinfo/myhdl-list > |