Re: [myhdl-list] attribute enum_encoding: string;
Brought to you by:
jandecaluwe
From: Christopher F. <chr...@gm...> - 2013-09-05 11:03:36
|
On 9/4/13 11:26 PM, David Holl wrote: > Thank you for looking into it Chris.  I confirm that the example code > you sent works correctly with ghdl. > > But it still triggers the "no declaration" error in ghdl when I > specify encoding='one_hot' for states: > > tensor(pts/0):~/m_think> diff old/m_think.py new/m_think.py > 5c5 > <   states = enum('IDLE', 'THINK', 'SEND_CMD', 'ADVANCE') > --- > >   states = enum('IDLE', 'THINK', 'SEND_CMD', 'ADVANCE', > encoding='one_hot') > Sorry for the confusion, yes I forgot to add the "encoding='one_hot'". I have updated the example, for me I don't get the error, here is a snip of the converted code type t_enum_states_1 is ( IDLE, THINK, SEND_CMD, ADVANCE ); attribute enum_encoding of t_enum_states_1: type is "0001 0010 0100 1000"; >> ghdl -a pck_myhdl_09.vhd m_think.vhd >> ghdl -e m_think >> ghdl -r m_think The version of GHDL I am using: ghdl -v GHDL 0.29 (20100109) [Sokcho edition] Compiled with GNAT Version: 4.4.0 20080314 (experimental) mcode code generator Written by Tristan Gingold I update the exampe: https://bitbucket.org/cfelton/examples/src/tip/state_machines/example1.py Regards, Chris > > tensor(pts/0):~/m_think> python m_think.py > ** ToVHDLWarning: Output port is read internally: sent > tensor(pts/0):~/m_think> ghdl -a pck_myhdl_08.vhd m_think.vhd    >          > m_think.vhd:15:11: no declaration for "enum_encoding" > /usr/lib/ghdl/bin/ghdl: compilation error > tensor(pts/0):~/m_think> echo $? > 1 > > I've attached the modify python code and generated vhdl. > > Thank you, > David > > > On Wed, Sep 4, 2013 at 10:57 PM, Christopher Felton > <chr...@gm... <mailto:chr...@gm...>> wrote: > > 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... > <mailto:myh...@li...> > > https://lists.sourceforge.net/lists/listinfo/myhdl-list > > > > > > ------------------------------------------------------------------------------ > 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=58041391&iu=/4140/ostg.clktrk > _______________________________________________ > myhdl-list mailing list > myh...@li... > <mailto:myh...@li...> > https://lists.sourceforge.net/lists/listinfo/myhdl-list > > > > > ------------------------------------------------------------------------------ > 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=58041391&iu=/4140/ostg.clktrk > > > > _______________________________________________ > myhdl-list mailing list > myh...@li... > https://lists.sourceforge.net/lists/listinfo/myhdl-list > |