Thread: [myhdl-list] python list of signals
Brought to you by:
jandecaluwe
From: Tom D. <td...@di...> - 2004-07-14 20:08:57
|
I was trying to make a variable pipeline module with the following code: def pipe(q, d, clk, stages=1): """ pipe block q -- output, delayed d by stages pipe delays d -- input clk -- clock input stages -- number of pipeline delays, 0 is no pipes """ qReg = [Signal(intbv(0,0,q.max)) for i in range(stages)] while 1: if stages == 0 : yield d q.next = d else : yield posedge(clk) if stages == 1 : q.next = d else : qReg[0].next = d q.next = qReg[stages-2] for i in range(stages-2) : qReg[i+1].next = qReg[i] It simulates fine but the list of signals (qReg[]) isn't liked by the Verilog converter. stages is meant to be a compile time parameter and I would like to make a variable number of signals based upon its value. Then easily use them else where in the module. If indeed this can't be converted, is there a simple way to accomplish this. Thanks, Tom Dillon |
From: Frank P. <pal...@co...> - 2004-07-15 19:35:23
|
>I was trying to make a variable pipeline module with the following code: > >def pipe(q, d, clk, stages=1): Does it work if you take stages out of the function signature? It may be that the Verilog generation assumes it is a Signal if it's in the signature..? Just a guess... -Frank |
From: Tom D. <td...@di...> - 2004-07-19 14:19:57
|
Frank, Tried that with the same results. I'm sure there is an easy way to do this... Tom Frank Palazzolo wrote: >>I was trying to make a variable pipeline module with the following code: >> >>def pipe(q, d, clk, stages=1): >> >> > >Does it work if you take stages out of the function signature? It may be >that the Verilog generation assumes it is a Signal if it's in the >signature..? > >Just a guess... >-Frank > > > > >------------------------------------------------------- >This SF.Net email is sponsored by BEA Weblogic Workshop >FREE Java Enterprise J2EE developer tools! >Get your free copy of BEA WebLogic Workshop 8.1 today. >http://ads.osdn.com/?ad_id=4721&alloc_id=10040&op=click >_______________________________________________ >myhdl-list mailing list >myh...@li... >https://lists.sourceforge.net/lists/listinfo/myhdl-list > > > |
From: Jan D. <ja...@ja...> - 2004-07-19 18:09:03
|
Tom Dillon wrote: > I was trying to make a variable pipeline module with the following code: > > def pipe(q, d, clk, stages=1): > """ pipe block > q -- output, delayed d by stages pipe delays > d -- input > clk -- clock input > stages -- number of pipeline delays, 0 is no pipes > """ > qReg = [Signal(intbv(0,0,q.max)) for i in range(stages)] > while 1: > if stages == 0 : > yield d > q.next = d > else : > yield posedge(clk) > if stages == 1 : > q.next = d > else : > qReg[0].next = d > q.next = qReg[stages-2] > for i in range(stages-2) : > qReg[i+1].next = qReg[i] > > It simulates fine but the list of signals (qReg[]) isn't liked by the > Verilog converter. > > stages is meant to be a compile time parameter and I would like to make > a variable number of signals based upon its value. Then easily use them > else where in the module. > > If indeed this can't be converted, is there a simple way to accomplish > this. At this moment, a list of signals itself is not mapped directly to Verilog. Whether this would be possible or meaningful, using a Verilog memory, I'm not sure. Verilog memories have certain strange restrictions, and they may not be supported by synthesis. This doesn't mean that you can't use lists of signals - the trick is to make sure to use them only during "elaboration". In other words, the restrictions to Verilog conversion only apply to the things at the lowest level - the generators. At the higher levels of the hierarchy, where you use plain functions, you have a lot of freedom, because the hierarchy is "elaborated" by the interpreter before conversion. BTW, the above explains also why I took this approach, as opposed to trying to map the inferred hierarchy to Verilog. The way it is now, you may be able to things that you couldn't do in Verilog (of course) but *still* be able to convert! Take a look at the test_RandomScrambler.py code in the myhdl/test/toVerilog directory for an example. [Sidenote: there is one disturbing issue that I still need to solve. If you use lists of instances, where the instance is the result of a direct generator call, conversion may not work. It has to do with the difference between a plain function and a generator as seen by the profiler. The workaround is to convert the generator into a plain function with a local generator. If this sounds confusing, again see test_RandomScrambler for an example (XorGate).] Hope this helps, Jan -- Jan Decaluwe - Resources bvba - http://jandecaluwe.com Losbergenlaan 16, B-3010 Leuven, Belgium Python is fun, and now you can design hardware with it: http://jandecaluwe.com/Tools/MyHDL/Overview.html |
From: Tom D. <td...@di...> - 2004-07-19 20:05:42
|
Jan, Thanks, that worked fine. Jan Decaluwe wrote: > > > This doesn't mean that you can't use lists of signals - the trick is to > make sure to use them only during "elaboration". In other words, the > restrictions to Verilog conversion only apply to the things at the > lowest level - the generators. At the higher levels of the hierarchy, > where you use plain functions, you have a lot of freedom, because > the hierarchy is "elaborated" by the interpreter before conversion. Thanks, that works fine. Tom |