Re: [myhdl-list] difficulty using itertools with MyHDL
Brought to you by:
jandecaluwe
From: Jan D. <ja...@ja...> - 2006-10-20 14:16:01
|
George Pantazopoulos wrote: > Sorry for the confusion earlier. Does this help you understand what I > want to accomplish? This is already working for me, except that I have > to redefine izip() and ichain() myself. Perhaps you know of a better way > to do this? George: Yes, I understand now. I think this qualifies as Truly Advanced Usage :-) What happens is that you do want to use itertools to describe behavior, not structure, in MyHDL terminology. You use the fact that you can have a generator yield other generators, something which I originally included to support bus-functional procedures. With all this low-level RTL stuff that I'm doing these days, I had all but forgotten about it :-) I understand why you want to use itertools - not for performance, but as a clear and concise way to manipulate iterators. The missing part is how to make sure that the MyHDL simulator handles your final iterator properly. There are 2 options: either it should support that object directly, or it should be converted to a generator first. I have briefly looked at the first option - but this whole typing system related to iterators seems complex. It's not clear how to do it robustly. Moreover, it may not be wise: perhaps someday somebody would want to use a similar object for structure instead of behavior. So at this point I would look for a workaround and convert iterator objects to the "officially" supported types (for behavior or structure) as desired. The advantage is of course that no change to MyHDL would be required. A workaround for your case could be the following. Just use itertools to set up your iterator as desired. Then convert it to a generator using a one-liner generator expression, e.g.: ordered_tests = (t for t in chain(stage1, stage2, stopsim())) This should work for any iterator you can imagine. Regards, Jan -- Jan Decaluwe - Resources bvba - http://www.jandecaluwe.com Losbergenlaan 16, B-3010 Leuven, Belgium From Python to silicon: http://myhdl.jandecaluwe.com |