Thread: [myhdl-list] Can't compare Signal(enum)
Brought to you by:
jandecaluwe
From: Thomas H. <th...@ct...> - 2014-07-28 12:08:54
|
I cannot compare signals containing enum instances; this looks like a bug to me: c:\Users\thomas\ip>py -2.7-32 Python 2.7.7 (default, Jun 1 2014, 14:17:13) [MSC v.1500 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import myhdl >>> >>> state = myhdl.enum("foo", "bar") >>> >>> a = myhdl.Signal(state.foo) >>> b = myhdl.Signal(state.bar) >>> >>> print a == b Traceback (most recent call last): File "<stdin>", line 1, in <module> File "C:\Python27\lib\site-packages\myhdl\_Signal.py", line 479, in __cmp__ return cmp(self._val, other) File "C:\Python27\lib\site-packages\myhdl\_enum.py", line 109, in _notImplementedCompare raise NotImplementedError NotImplementedError >>> Thomas |
From: Christopher F. <chr...@gm...> - 2014-07-28 15:27:06
|
On 7/28/2014 7:08 AM, Thomas Heller wrote: > I cannot compare signals containing enum instances; this looks like a > bug to me: > > c:\Users\thomas\ip>py -2.7-32 > Python 2.7.7 (default, Jun 1 2014, 14:17:13) [MSC v.1500 32 bit > (Intel)] on win32 > Type "help", "copyright", "credits" or "license" for more information. > >>> import myhdl > >>> > >>> state = myhdl.enum("foo", "bar") > >>> > >>> a = myhdl.Signal(state.foo) > >>> b = myhdl.Signal(state.bar) > >>> > >>> print a == b > Traceback (most recent call last): > File "<stdin>", line 1, in <module> > File "C:\Python27\lib\site-packages\myhdl\_Signal.py", line 479, in > __cmp__ > return cmp(self._val, other) > File "C:\Python27\lib\site-packages\myhdl\_enum.py", line 109, in > _notImplementedCompare > raise NotImplementedError > NotImplementedError > >>> > Yes, I would agree this is unexpected behavior. The problem is the use of the "cmp" function in the Signal class. The cmp(x, y) [1] function performs a x > y which is not implemented in the enum class (good reason). The use-case of a Signal(enum) == Signal(enum) probably has not been used, but I agree it is a valid case. import myhdl state = myhdl.enum("foo", "bar") a = myhdl.Signal(state.foo) b = myhdl.Signal(state.bar) print a == state.foo print a == state.bar print b == state.foo print b == state.bar print a == b Only the Signal(enum) == Signal(enum) fails because the Signal comparison calls. This should be added as an issue in the repo tracker [2]. Regards, Chris [1] https://docs.python.org/2/library/functions.html?highlight=cmp#cmp [2] https://bitbucket.org/jandecaluwe/myhdl/issues?status=new&status=open |
From: Thomas H. <th...@ct...> - 2014-07-29 09:43:25
|
Am 28.07.2014 17:26, schrieb Christopher Felton: > On 7/28/2014 7:08 AM, Thomas Heller wrote: >> I cannot compare signals containing enum instances; this looks like a >> bug to me: > Yes, I would agree this is unexpected behavior. [...] > This should be added as an issue in the repo tracker [2]. Done: https://bitbucket.org/jandecaluwe/myhdl/issue/9/ |
From: Jan C. <jen...@mu...> - 2014-07-29 16:42:32
|
On 29/07/14 10:43, Thomas Heller wrote: > > Done: https://bitbucket.org/jandecaluwe/myhdl/issue/9/ Thanks Thomas, I also had found this problem, but just worked round it with simple constants. Jan Coombs. -- |
From: Christopher F. <chr...@gm...> - 2014-07-29 12:59:09
|
On 7/29/2014 4:43 AM, Thomas Heller wrote: > Am 28.07.2014 17:26, schrieb Christopher Felton: >> On 7/28/2014 7:08 AM, Thomas Heller wrote: >>> I cannot compare signals containing enum instances; this looks like a >>> bug to me: >> Yes, I would agree this is unexpected behavior. > [...] > >> This should be added as an issue in the repo tracker [2]. > > Done: https://bitbucket.org/jandecaluwe/myhdl/issue/9/ Perfect, thanks! |
From: Edward V. <dev...@sb...> - 2014-07-29 16:54:27
|
Chris In the stimulus the first loop was 3. I changed it to finally 17 and now increases but the state remained at IDLE see below. With the now print("%8d %s" % (now(), pix)) instead of print(pix) this what I getting. python add_shift.py this is with 3 70 IDLE 550 IDLE 830 IDLE 1110 IDLE [vidal@ws009 ipython_fixbv]$ python add_shift.py this is with 5 110 IDLE 590 IDLE 870 IDLE 1150 IDLE [vidal@ws009 ipython_fixbv]$ python add_shift.py this is with 7 150 IDLE 630 IDLE 910 IDLE 1190 IDLE [vidal@ws009 ipython_fixbv]$ python add_shift.py this is with 17 350 IDLE 830 IDLE 1110 IDLE 1390 IDLE The delay is longer than test code. This what I get in the test code. python t_x.py 0 IDLE 1 UPDATE_SAMPLE 2 TRANSFER_OUT 3 TRANSFER_IN Regards Edward Vidal Jr. e-mail dev...@sb... 915-595-1613 On Tuesday, July 29, 2014 6:59 AM, Christopher Felton <chr...@gm...> wrote: On 7/29/2014 4:43 AM, Thomas Heller wrote: > Am 28.07.2014 17:26, schrieb Christopher Felton: >> On 7/28/2014 7:08 AM, Thomas Heller wrote: >>> I cannot compare signals containing enum instances; this looks like a >>> bug to me: >> Yes, I would agree this is unexpected behavior. > [...] > >> This should be added as an issue in the repo tracker [2]. > > Done: https://bitbucket.org/jandecaluwe/myhdl/issue/9/ Perfect, thanks! ------------------------------------------------------------------------------ Infragistics Professional Build stunning WinForms apps today! Reboot your WinForms applications with our WinForms controls. Build a bridge from your legacy apps to the future. http://pubads.g.doubleclick.net/gampad/clk?id=153845071&iu=/4140/ostg.clktrk _______________________________________________ myhdl-list mailing list myh...@li... https://lists.sourceforge.net/lists/listinfo/myhdl-list |