Thread: [myhdl-list] Bug in MyHDL compiler?
Brought to you by:
jandecaluwe
From: David G. <dsg...@gm...> - 2011-09-27 04:13:08
|
When I try to run the following code in a file, it terminates with an error. It appears to occur when a memory list is used in a function that doesn't return something directly executable, even though I am throwing away the other return value (but I'd like to be able to return a usable function that is synthesized into a verilog talk/function). What functions do I need to look at in the compiler to add this feature, or why is it impossible in the current system? Thanks, David from myhdl import * def test(a, o): mem = [Signal(intbv(i)[32:]) for i in range(32)] @always_comb def logic(): o.next = mem[a] def foo(): pass return logic, foo clk = Signal(bool(0)) @always(delay(10)) def clkgen(): clk.next = not clk def tb(clk): a = Signal(intbv(0)[32:]) o = Signal(intbv(0)[32:]) t_logic, foo = test(a,o) counter = Signal(intbv(0)[4:]) @always(clk.posedge) def logic(): counter.next = (counter + 1) % 16 if counter == 3: a.next = 0 else: a.next = 7 return t_logic, logic toVerilog(tb, clk) |
From: Jan D. <ja...@ja...> - 2011-09-27 07:46:52
|
On 09/27/2011 06:13 AM, David Greenberg wrote: > When I try to run the following code in a file, it terminates with an > error. It appears to occur when a memory list is used in a function > that doesn't return something directly executable, Hierarchy extraction (used for lower level tasks like conversion and waveform tracing) doesn't work for things that are not strictly instances according to MyHDL definition: http://www.myhdl.org/doc/current/manual/modeling.html#structural-modeling -- Jan Decaluwe - Resources bvba - http://www.jandecaluwe.com Python as a HDL: http://www.myhdl.org VHDL development, the modern way: http://www.sigasi.com World-class digital design: http://www.easics.com |
From: David G. <dsg...@gm...> - 2011-09-27 12:10:53
|
While considering other approaches for a register file, if I could return functions that would be synthesized into tasks, then I could have a very similar interface to the one I imagined. It seems that the hierarchy extractor could ignore these unknown objects as long as they're used only during the elaboration phase. Is there a technical reason this isn't done? I'd like to extend MyHDL to support this. If you could just give me a pointer or two to get started it'd make this easier for me (I have some experience in compiler implementation) 1) I think that if I modify the _ConvertVisitor to treat non-instance functions as either being ignored or the same as other functions, this would work, since MyHDL doesn't generate hierarchy, so the returned function would be accessible from the outer scope in the generated code. 2) Would it be more effective to make another subclass of ast.NodeVisitor and have all of the code generator/waveform viewer visitors inherit from the subclass of NodeVisitor instead of NodeVisitor itself? 3) Does the waveform analyzer require something different for this? Thanks, David On Tue, Sep 27, 2011 at 3:46 AM, Jan Decaluwe <ja...@ja...> wrote: > On 09/27/2011 06:13 AM, David Greenberg wrote: >> When I try to run the following code in a file, it terminates with an >> error. It appears to occur when a memory list is used in a function >> that doesn't return something directly executable, > > Hierarchy extraction (used for lower level tasks like conversion > and waveform tracing) doesn't work for things that are not strictly > instances according to MyHDL definition: > > http://www.myhdl.org/doc/current/manual/modeling.html#structural-modeling > > > > > -- > Jan Decaluwe - Resources bvba - http://www.jandecaluwe.com > Python as a HDL: http://www.myhdl.org > VHDL development, the modern way: http://www.sigasi.com > World-class digital design: http://www.easics.com > > > ------------------------------------------------------------------------------ > All the data continuously generated in your IT infrastructure contains a > definitive record of customers, application performance, security > threats, fraudulent activity and more. Splunk takes this data and makes > sense of it. Business sense. IT sense. Common sense. > http://p.sf.net/sfu/splunk-d2dcopy1 > _______________________________________________ > myhdl-list mailing list > myh...@li... > https://lists.sourceforge.net/lists/listinfo/myhdl-list > |
From: Jan D. <ja...@ja...> - 2011-09-27 14:59:38
|
On 09/27/2011 02:10 PM, David Greenberg wrote: > While considering other approaches for a register file, if I could > return functions that would be synthesized into tasks, then I could > have a very similar interface to the one I imagined. > > It seems that the hierarchy extractor could ignore these unknown > objects as long as they're used only during the elaboration phase. > Is there a technical reason this isn't done? I'm not very proud on the hierarchy extraction code, which I find tricky and confusing. I have tried to simplify it before, by imposing tougher restrictions on what it supports. The problem is that I use the general Python profiler. During profiling, all functions get traced. Currently, the only way I have to differentiate between general functions and those used to define MyHDL structure, is by looking at the return type. I assume that users will want this distinction, and therefore I consider anything that doesn't strictly comply with the definition of a MyHDL instance as something that doesn't participate in the structure. I don't understand exactly what you try to accomplish but there may be ways to do it today without changes. For example, you can play scoping games with top-level signals, and pass function as parameters etc. The convertor doesn't care, as long as it's in the elaboration phase. -- Jan Decaluwe - Resources bvba - http://www.jandecaluwe.com Python as a HDL: http://www.myhdl.org VHDL development, the modern way: http://www.sigasi.com World-class digital design: http://www.easics.com |
From: David G. <dsg...@gm...> - 2011-09-27 16:26:01
|
Hi Jan, I'm trying to make register file that returns a read and write function, the former which will be synthesized as a verilog function and the latter as a task. I don't want to have to explicitly pass around the register file's signals. Does that make sense? Sent from my iPhone On Sep 27, 2011, at 10:59 AM, Jan Decaluwe <ja...@ja...> wrote: > On 09/27/2011 02:10 PM, David Greenberg wrote: >> While considering other approaches for a register file, if I could >> return functions that would be synthesized into tasks, then I could >> have a very similar interface to the one I imagined. >> >> It seems that the hierarchy extractor could ignore these unknown >> objects as long as they're used only during the elaboration phase. >> Is there a technical reason this isn't done? > > I'm not very proud on the hierarchy extraction code, which I find > tricky and confusing. I have tried to simplify it before, by > imposing tougher restrictions on what it supports. > > The problem is that I use the general Python profiler. During > profiling, all functions get traced. Currently, the only way > I have to differentiate between general functions and those > used to define MyHDL structure, is by looking at the return > type. > > I assume that users will want this distinction, and therefore > I consider anything that doesn't strictly comply with the > definition of a MyHDL instance as something that doesn't > participate in the structure. > > I don't understand exactly what you try to accomplish but > there may be ways to do it today without changes. For > example, you can play scoping games with top-level signals, > and pass function as parameters etc. The convertor > doesn't care, as long as it's in the elaboration phase. > > -- > Jan Decaluwe - Resources bvba - http://www.jandecaluwe.com > Python as a HDL: http://www.myhdl.org > VHDL development, the modern way: http://www.sigasi.com > World-class digital design: http://www.easics.com > > > ------------------------------------------------------------------------------ > All the data continuously generated in your IT infrastructure contains a > definitive record of customers, application performance, security > threats, fraudulent activity and more. Splunk takes this data and makes > sense of it. Business sense. IT sense. Common sense. > http://p.sf.net/sfu/splunk-d2dcopy1 > _______________________________________________ > myhdl-list mailing list > myh...@li... > https://lists.sourceforge.net/lists/listinfo/myhdl-list |
From: Jan D. <ja...@ja...> - 2011-09-28 08:50:39
|
On 09/27/2011 06:25 PM, David Greenberg wrote: > Hi Jan, I'm trying to make register file that returns a read and > write function, the former which will be synthesized as a verilog > function and the latter as a task. I don't want to have to explicitly > pass around the register file's signals. Does that make sense? The proper way to implement such functionality would seem to be classes and methods, not passing functions around explicitly. (Supporting that in conversion is a different matter.) -- Jan Decaluwe - Resources bvba - http://www.jandecaluwe.com Python as a HDL: http://www.myhdl.org VHDL development, the modern way: http://www.sigasi.com World-class digital design: http://www.easics.com |