Re: [myhdl-list] [myhdl_hg] toVerilog unittest errors with Icarus Verilog
Brought to you by:
jandecaluwe
|
From: Jan D. <ja...@ja...> - 2008-08-02 12:36:23
|
Günter Dannoritzer wrote:
> Hi,
>
> I ran the unittest test_all.py in the hg repository's
> conversion/toVerilog folder and got a bunch of errors (took out the
> traceback):
>
> Comparing that to the latest development snapshot 0.6dev8, there are
> only three of these errors. All the indexing errors are new with the
> latest revision in the repository.
>
> Is that expected or has it to do that I am using Icarus Verilog the
> latest development snapshot for the cosimulation? In the test cver was
> used by default.
Ok, a couple of points.
I have found Icarus to be less reliable than cver. I am currently happy when
the tests run without errors with cver. (Perhaps I should define a project
to debug Icarus using the MyHDL tests; having cver I'm not very motivated
to do that myself.)
With cver, I indeed found 2 errors that shouldn't be there. It shows that
we should run all tests for any changes (although that may not be
practical for those who haven't cosimulation installed.)
I used 'hg bisect' to track down the cause. (A nice mercurial feature BTW
for this kind of thing. The culprit is this changeset:
-----------------------------------------------------
changeset: 931:3bcbf3cd752c
user: cfelton@localhost
date: Wed Jul 23 21:00:15 2008 -0500
files: myhdl/_extractHierarchy.py
description:
Change to the conditional check. The conditional check would error out when numpy arrays were used.
Numpy arrays would not resolve to a boolean value when tested.
diff -r 1870cf0064df -r 3bcbf3cd752c myhdl/_extractHierarchy.py
--- a/myhdl/_extractHierarchy.py Tue Jul 22 14:22:49 2008 +0200
+++ b/myhdl/_extractHierarchy.py Wed Jul 23 21:00:15 2008 -0500
@@ -126,7 +126,7 @@
def _isListOfSigs(obj):
- if obj and isinstance(obj, list):
+ if obj != None and isinstance(obj, list):
for e in obj:
if not isinstance(e, Signal):
return False
--------------------------------------------------------------------
The _isListOfSigs function is broken. The intention of the function is to
only return True on a *non-empty* list of signals, but as you can see
this is not what currently happens - empty lists are not equal to None.
The original test had a problem with numpy arrays (you can't really test
these for thruth value - rather strange).
Assuming that numpy arrays are not subtypes of list, the following
should work
if isinstance(obj, list) and obj:
but I think I'm going to make the intention clearer as follows:
if isinstance(obj, list) and len(obj) > 0:
Unless someone objects, I'll test this and push the change.
Jan
--
Jan Decaluwe - Resources bvba - http://www.jandecaluwe.com
Kaboutermansstraat 97, B-3000 Leuven, Belgium
From Python to silicon:
http://myhdl.jandecaluwe.com
|