Re: [myhdl-list] Re: inference problem?
Brought to you by:
jandecaluwe
From: Haitao Z. <ha...@gm...> - 2005-02-26 22:14:01
|
Jan, Thanks! You spotted the problem! > Yes, I infer that you didn't simulate this :-) Right I didn't on this one. I want to build a model of my project in myhdl and before doing it I wanted to be sure that it can be converted so I am experimenting a bit to see how things go. I did try some other sims just not thought of doing it here. As you can tell I am new to myhdl, and also pretty new to Python. Thanks for all the good advice. Haitao > > Here's the problem: your intention is that q1 is a Signal, but it isn't. > In fact, in MyHDL: > > q1 = Signal(intbv(0))[n:] > > is equivalent to: > > q1 = Signal(intbv(0)).val[n:] > > that is, you get a slice of the current underlying value, which is an > intbv and not a signal. > > What you want is: > > q1 = Signal(intbv(0)[n:]) > > In this case, you get a signal with an intbv (with a defined bit width) > as its underlying value. > > The reason why conversion currently behaves like it does has to do > with namespace lookups. Perhaps more could be done to detect flaws, > BUT in a Python context this is an upfront battle. You really should > use the run-time (= simulation) to detect errors. I have written > about this before: > > (from the manual, section 6.5.1) > """ > In the Python philosophy, the run-time rules. The Python compiler > doesn't attempt to detect a lot of errors beyond syntax errors, which > given Python's ultra-dynamic nature would be an almost impossible task > anyway. To verify a Python program, one should run it, preferably > using unit testing to verify each feature. > > The same philosophy should be used when converting a MyHDL description > to Verilog: make sure the simulation runs fine first. Although the > converter checks many things and attempts to issue clear error > messages, there is no guarantee that it does a meaningful job unless > the simulation runs fine. > """ > > In other words, if the simulation works fine, my goal is to guarantee > that the conversion (if it succeeds) is correct. Otherwise, all bets > are off (even if conversion succeeds). > > Note that in this case, a trivial test bench would detect the error, > as q1 in your code cannot have a next attribute. > > Miscellaneous remark: please don't use "private" attributes such as > _nrbits. An intbv supports the 'len' function (which returns 0 for > undefined bit widths.) > > Regards, Jan > > -- > Jan Decaluwe - Resources bvba - http://jandecaluwe.com > Losbergenlaan 16, B-3010 Leuven, Belgium > Using Python as a hardware description language: > http://jandecaluwe.com/Tools/MyHDL/Overview.html > > ------------------------------------------------------- > SF email is sponsored by - The IT Product Guide > Read honest & candid reviews on hundreds of IT Products from real users. > Discover which products truly live up to the hype. Start reading now. > http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click > _______________________________________________ > myhdl-list mailing list > myh...@li... > https://lists.sourceforge.net/lists/listinfo/myhdl-list > |