Difference between revisions of "Genesis2FAQ"

From Genesis2
Jump to: navigation, search
(Created page with "= Genesis2 Frequently Asked Questions... And Answers=")
 
Line 1: Line 1:
 
= Genesis2 Frequently Asked Questions... And Answers=
 
= Genesis2 Frequently Asked Questions... And Answers=
 +
 +
 +
= Unprocessed Questions =
 +
 +
== can genesis produce the GUI(Graphical User Interface) for me automatically? ==
 +
 +
    I am now starting to build more complicated generator. One more question is, can genesis produce the GUI(Graphical User Interface) for me automatically?  I hope that there will be a Graphical User Interface which could be provided to the students in my advisor's class.  So that they could make experiments on my design. Is it possible/easy to do that?
 +
 +
On Thu, Mar 17, 2011 at 8:50 PM, Ofer Shacham <shacham@stanford.edu> wrote:
 +
 +
 +
    Aha, excellent question. So remember, what we wanted to do was make it easier and standardize for people to make generators, right?
 +
 +
    So with this in mind, we created the XML as genesis’s interface to the world, with a simple and standard schema. Our gui, is completely independent of genesis---it reads in the xml out and draws that on the screen. It does not know (or care)if this is an xml for a Pentium or FFT. All it needs is to know where the source code (the .vp files) are. It then shows all the <Parameters> (hierarchically) and makes them available for users to tweak. It also shows the <ImmutableParameters> but does not let users to tweak them.
 +
 +
    You can see a couple of examples in http://www-vlsi.stanford.edu/ig/. For example:
 +
 +
    ·        click on “(Real-ish) CMP Generator”
 +
 +
    ·        Click on DUT
 +
 +
    ·        Look for processors – there is only one and it is called P0
 +
 +
    ·        Click “up” (don’t hit the back arrow)
 +
 +
    ·        change the number of processors to 3 and click on submit.
 +
 +
    ·        Click on DUT
 +
 +
    ·        Now there are P0, P1 and P2 (there are also a bunch of other modules like I- and D-caches etc).
 +
 +
    ·        Click on rf (stands for regfile). This is much the same regfile that I sent you in the example. You can now change its base address etc. Genesis will uniquify it and rename modules and files etc.
 +
 +
   
 +
 +
    We (ok, mostly Steve :) are working on getting the gui wrapped so that we can send it to you to install locally. Steve, you said you needed to know what kind of html installation they have, right? Can you elaborate for Jolin?
 +
 +
   
 +
 +
    Thanks,
 +
 +
    Ofer.
 +
 +
== more questions ==
 +
 +
    From: Qiuling Zhu [mailto:jolin.qiulingz@gmail.com]
 +
    Sent: Thursday, March 17, 2011 4:24 PM
 +
    To: Ofer Shacham
 +
 +
    Subject: Re: Genesis2 for CMU generators
 +
 +
   
 +
 +
    Hi Ofer,
 +
 +
    Thanks a lot for this detailed explanation. I think I have understood how it works and I am now able to control the parameters from the "config.xml" file. As you suggested, I just run the genesis once to get the hierarchy_out.xml and modify this output xml to create the input xml. It works well to me.
 +
 +
    Thanks,
 +
    Jolin
 +
 +
 +
    On Thu, Mar 17, 2011 at 3:15 PM, Ofer Shacham <shacham@stanford.edu> wrote:
 +
 +
    Hi Jolin,
 +
 +
   
 +
 +
    Genesis accepts (optional) an xml as input for elaboration of the code. In the makefile examples I sent you, it already does that. That’s the “-xml $(GENESIS_CFG_XML)” flag, and it reads the config.xml by default. You can change it by running “make clean run SIM_ENGINE=mentor GENESIS_CFG_XML=YourOwnFile”. Genesis knows how to parse the xml file and force the value of the parameters. However, note that the xml can only override a default value of a parameter. It cannot override a parameter that you already overwritten in the generate statement upon instantiation. The reason is that we assume that if you decided to override the value at instantiation, you probably knew what you were doing, and might also have other code that assumes that value. So in summary, the overriding priorities are:
 +
 +
    1.      $self->define_param(PrmName =>PrmValue)  --- Lowest priority
 +
 +
    2.      XML input --- Can override define_param
 +
 +
    3.      generate(‘flop’, ‘pipestage7’, PrmName =>NewPrmValue) --- Can override both define_param and xml
 +
 +
    4.      $self->force_param(PrmName =>PrmValue) --- mutually exclusive with all other, and cannot be overridden in anyway (Advanced users: useful for exporting information from one module to another: module A uses force_param to declare something. Module B uses $A->get_param to read that. )
 +
 +
   
 +
 +
    To make life easy and also to interact with the gui, genesis also dumps out (optional) a complete xml of the hierarchy. In the example makefiles I sent you these would be the “-hierarchy wallace.xml” for the wallace tree (I should probably fix that), and “-hierarchy $(GENESIS_HIERARCHY)” for the regfile. The output XML is a superset of the input xml because:
 +
 +
    ·        For the input xml, you only need to specify modules that you care about and parameters that you want to override. The output XML contains all the modules and all the parameters. Whether override-able or not.
 +
 +
    ·        The output XML contains a bunch of meta information regarding the source files, the source templates and the uniquified modules that were created. This info is not needed for the input xml.
 +
 +
    Therefore, in the examples I sent, the input xml is pretty much empty. For the wallce tree it only has “<top></top>”. For the regfile it has a little more info but still, all fields are empty.
 +
 +
   
 +
 +
    Important note: I typically run the genesis once to create the output xml so that I can use it as template to create my input xml. You can also read more about the schema for both xmls at: http://genesis2.stanford.edu/mediawiki/index.php/Genesis2#Program.xml_File and http://genesis2.stanford.edu/mediawiki/index.php/Genesis2#Hierarchy_Out
 +
 +
   
 +
 +
    Finally, to your question:
 +
 +
    In the Wallace tree, all parameters were bound at instantiation. In the regfile, I only bound the type of register but left the default value un-bound. As a result, when you run the elaboration, in the xml you will see (this is just a snippet of it of course) for register “DataIn_reg”, the following code:
 +
 +
            <DataIn_reg>
 +
 +
              <BaseModuleName>flop</BaseModuleName>
 +
 +
              <ImmutableParameters>
 +
 +
                <FLOP_TYPE>eflop</FLOP_TYPE>
 +
 +
                <FLOP_WIDTH>32</FLOP_WIDTH>
 +
 +
              </ImmutableParameters>
 +
 +
              <InstanceName>DataIn_reg</InstanceName>
 +
 +
              <Parameters>
 +
 +
                <FLOP_DEFAULT>0</FLOP_DEFAULT>
 +
 +
              </Parameters>
 +
 +
              <SubInstances></SubInstances>
 +
 +
              <UniqueModuleName>flop_unq4</UniqueModuleName>
 +
 +
            </DataIn_reg>
 +
 +
   
 +
 +
    Note that the ‘FLOP_DEFAULT’ param is the only one that is not bound so genesis identifies it and put it on the <Parameters> list. All other properties of the flop were bound at instantiation so those are on the <ImmutableParameters> list. This way I can (either manually or through the gui) tweak the value of each and every parameter individually. Makes sense?
 +
 +
   
 +
 +
    Having said all that, I could have created a default value parameter for each flop at the top level and then propagate it to the flops through the code. Then those default values would have been immutable in the flop, but then they would be override-able at the top level (i.e. they would show up in the <Parameters> list at the <top> item of the XML.
 +
 +
   
 +
 +
    I hope this long explanation made things clearer and not worse J,
 +
 +
    Ofer.
 +
 +
   
 +
 +
   
 +
 +
    From: Qiuling Zhu [mailto:jolin.qiulingz@gmail.com]
 +
    Sent: Thursday, March 17, 2011 9:09 AM
 +
 +
 +
    To: Ofer Shacham
 +
    Subject: Re: Genesis2 for CMU generators
 +
 +
   
 +
 +
    Hi Ofer,
 +
 +
    I see.. Actually that's what I plan to do next: specify the parameter values from outside by the XML configuration. Did you do this in the example designs of "reg file" and "wallace"?  Should I write a config.xml file ahead? I generally don't know how to do it.  When you run the code, it is able to read in the .xml files automatically and read in the parameters from .xml files?
 +
 +
    Thanks,
 +
    Jolin
 +
 +
 +
    On Thu, Mar 17, 2011 at 11:56 AM, Ofer Shacham <shacham@stanford.edu> wrote:
 +
 +
    Great!
 +
 +
    Small tip: in many cases, a parameter is local to a module and does not change its interface. In these cases, it sometimes makes sense to add the parameter but to NOT bind it at instantiation (i.e., in the ‘generate’ call). When you do that, this parameter can be controlled from the outside by the XML configuration (and eventually by the gui).
 +
 +
    (Of course, you can always just propagate the parameter to the top level and control it from there if if you find that more convenient.)
 +
 +
   
 +
 +
    Best,
 +
 +
    Ofer.
 +
 +
   
 +
 +
    From: Qiuling Zhu [mailto:jolin.qiulingz@gmail.com]
 +
    Sent: Thursday, March 17, 2011 8:49 AM
 +
 +
 +
    To: Ofer Shacham
 +
    Subject: Re: Genesis2 for CMU generators
 +
 +
   
 +
 +
    Hi Ofer,
 +
 +
    Thanks you very much for these detailed explanations.
 +
 +
    I have added more parameters to my design and I am even able to debug the code  based on the error message by checking the *.pm file. It works well so far.  Will let you know if I need more help.
 +
 +
    Thanks again.
 +
    Jolin
 +
 +
 +
 +
    On Wed, Mar 16, 2011 at 6:06 PM, Ofer Shacham <shacham@stanford.edu> wrote:
 +
 +
    Hi Jolin,
 +
 +
   
 +
 +
    I looked at your code. This was only a small issue of a couple of syntax errors in your Perl code. I do admit however that the error messages from genesis2 needs to be improved significantly!
 +
 +
   
 +
 +
    Here is how to fix your code:
 +
 +
    Line 24:
 +
 +
    Replace:
 +
 +
    //;              unless($flop_type = "BILINEAR" || $flop_type = "NEAR_NEIGHBOR")
 +
 +
    With:
 +
 +
    //;              unless($inter_order =~ m/^BILINEAR$/i || $inter_order =~ m/^NEAR_NEIGHBOR$/i);
 +
 +
    Explanation: in Perl you can compare strings using the ‘eq’ operator (e.g.:  if ($my_str eq “someString”)…, if ($my_str eq $your_str)…) . However, if you want to compare sub strings or regular expressions (e.g., in this case make it case insensitive) you typically use the ‘=~’ operator. So in the code above I made it compare to a regular expression: to return true, it must find a substring which starts with and end with ‘BILINEAR’ (this is what the ^ and $ sign doing-- ^ is line-start and $ is line-end). I also made it case insensitive using the ‘i’ like I showed in the previous email.
 +
 +
   
 +
 +
    Line 191:
 +
 +
    Replace:
 +
 +
    //; if ($inter_order =~  m/^bilinear$/i) 
 +
 +
    With:
 +
 +
    //; if ($inter_order =~  m/^bilinear$/i) {
 +
 +
    Explanation: in Perl, you always need to have the open curly braces ‘{‘ after the if condition.
 +
 +
   
 +
 +
    Line 280:
 +
 +
    Replace:
 +
 +
    //;# if ($inter_order =~  m/^bilinear$/i) 
 +
 +
    With:
 +
 +
    //; if ($inter_order =~  m/^bilinear$/i)  {
 +
 +
    Explanation: exactly the same as line 191.
 +
 +
   
 +
 +
    That’s it. It should work perfectly now. You may want to copy over the new makefile I sent you (and change the source file names).
 +
 +
   
 +
 +
    I’m here if you need any further help!
 +
 +
    Ofer.
 +
 +
   
 +
 +
    From: Ofer Shacham [mailto:shacham@stanford.edu]
 +
    Sent: Wednesday, March 16, 2011 2:13 PM
 +
 +
 +
    To: 'Qiuling Zhu'
 +
    Cc: 'Ofer Shacham'
 +
    Subject: RE: Genesis2 for CMU generators
 +
 +
   
 +
 +
    Hi Jolin,
 +
 +
    Attached please find new tars with the same design examples, but this time with a makefile that supports mentor tools. You will still need to do whatever you are used to doing to get your mentor tools sourced to the environment of course. (you can do ‘which vlog’ and ‘which vsim’ on your linux shell to make sure that both commands are in your path etc.)
 +
 +
   
 +
 +
    Since the makefile now supports both environment, you need to do: ‘make clean run SIM_ENGINE=mentor’ (i.e. add SIM_ENGINE=mentor to whatever make command you are using). Let me know if it works. I’ll look at your code next.
 +
 +
    Ofer.
 +
 +
   
 +
 +
   
 +
 +
    From: Ofer Shacham [mailto:shacham@stanford.edu]
 +
    Sent: Wednesday, March 16, 2011 10:57 AM
 +
    To: 'Qiuling Zhu'
 +
    Cc: 'Ofer Shacham'
 +
    Subject: RE: Genesis2 for CMU generators
 +
 +
   
 +
 +
    I’m happy that you started looking at the code and I’m happy to answer your questions: My answers below:
 +
 +
 +
    May I ask you some questions about the genesis2? YES!
 +
 +
    (1) I am now able to run your design example of 'flop' and 'wallace' by following your README file and it generates the verilog files to me successfully, but I have problems with the example of "register file": it shows error of "make: vcs: Command not found" when I type "make clean run" in that directory.
 +
 +
    Vcs is just the Sysnopsys simulator. I noticed that you used a Mentor flow where you compile using vlog and run using vsim. We are using Synopsys flow here where we compile with ‘vcs’ and run using ‘simv’. I’m working on a new makefile example that would support the Mentor flow. Will probably send it later today or tomorrow. Meanwhile, if you just want to look at the Verilog use “make gen” (or better yet”make clean gen”).
 +
 +
 +
 +
    (2) I built a small and simple example of my own design "rotation.vp", it has only one parameter of "INTER_ORDER", which could be "BILINEAR" or  "NEAR_NEIGHBOR". I wrote the source files(rotation.vp, top.vp and Makefile) by slightly modifying your "flop" design files. However, when I run it by typing "make clean run", it shows errors of "Genesis2::top: ERROR at (or right after) line 10 of file /*****/top.vp".  I attached my files to you and could you help me to look at what's wrong with my codes?  I wonder if there is anything else that I need to do besides preparing .vp files and Makefile?
 +
 +
    I’ll look at your code and send a separate email a little later.
 +
 +
 +
 +
    (3) About your design of "flop" (not "reg files"), can I ask you some simple questions ? (forgive me if these question are stupid since I am not that familiar with Perl)
 +
      1)  In "flop.vp", 
 +
 +
            //; if ($flop_type !~ m/constant/i) {........
 +
    -------------
 +
    what's the meaning of "~ m/constant/i" ?
 +
 +
    Perl is a scripting language that is all about regular expressions (i.e., string matching and manipulation).
 +
 +
    “if ($flop_type =~ m/constant/)” The “=~” means if the string $flop_type matches (matches=has a substring) the string “constant”
 +
 +
    “if ($flop_type =~ m/constant/i)” The “i” at the end makes it case insensitive (would match constant, consTANt,  CONSTANT, etc.)
 +
 +
    “if ($flop_type !~ m/constant/i)” The “!~” means the opposite of “=~”. That is, if the string $flop_type DOES NOT match the string “constant”
 +
 +
    A very concise and easily readable tutorial on perl regular expressions is here: http://www.troubleshooters.com/codecorn/littperl/perlreg.htm
 +
 +
 +
    -------------------------------------------------------------------------------------------
 +
      2)In "top_flop_only.vp"
 +
 +
      //; my $const_flop_obj = generate('flop', 'const_flop_eg', FLOP_TYPE=>'constant',
 +
      //;                              FLOP_DEFAULT => 0xFF, FLOP_WIDTH => 32);
 +
      `$const_flop_obj->instantiate()` (...);
 +
    -------------
 +
    what are "const_flop_obj ", "flop", "const_flop_eg" mapping to?  I thought "const_flop_eg" is the inst name, but when I look at the generated verilog file, the module name is "module flop_unq1". I wonder where you specify the name of "flop_unq1" or it must be in this format?
 +
    Every module that is generated is an object (in this case “$const_flop_obj”). This object is a sub-instance of the parent module. That is, in this case “$const_flop_obj” is a son/sub module of top. The base module name is ‘flop’, but you may end up generating many different flops, right? So we need to give each of the generated ‘flop’ modules a unique module name (similar to the work you had to do in your code manually. For example to create different “ftype"_twi_rom_"i”). Genesis2 does this for you. It checks if this is a new (and different) ‘flop’ and it names the module ‘flop_unq#N’. Does this makes sense? Of course, the flop object (in our case “$const_flop_obj”) knows what unique module it is and “$const_flop_obj->get_module_name” will return that value.
 +
 +
    The second argument is the name of the Verilog instance. The name of that instance (when Verilog is generated) is ‘const_flop_eg’. This means that we expect that when the Verilog for top.v be generated it would have a sub instance of type ‘flop’, but uniquified so let’s call it ‘flop_unq132’ and by the name ‘const_flop_eg’.
 +
 +
    The generated code should look something like this:
 +
 +
    module top();
 +
 +
    flop_unq132 const_flop_eg (…)
 +
 +
    endmodule
 +
 +
   
 +
 +
      Does this makes sense?
 +
 +
 +
      3) Actually I have more questions regarding to the "parametrization methods" and "module instantiation methods". But I can ask you later when I solve these simple problems.
 +
    Feel free, anytime!
 +
      Please see attached of my design files.
 +
    -------------------------------------------------------------------------------------------
 +
 +
    Thanks,
 +
    Jolin
 +
 +
   
 +
 +
 +
   
 +
 +
    From: Qiuling Zhu [mailto:jolin.qiulingz@gmail.com]
 +
    Sent: Sunday, March 13, 2011 9:16 AM
 +
    To: Ofer Shacham
 +
    Subject: Re: Genesis2 for CMU generators
 +
 +
    Sorry, I made a mistake in my last email since I thought the meeting time you suggested is next next Tuesday (May 22).  Thursday is good to me. But I am not sure if I can work out it by then. Let me look at it first and I will let you know when I am prepared for a meeting.
 +
 +
    Thanks,
 +
    Jolin
 +
 +
    On Sun, Mar 13, 2011 at 11:59 AM, Qiuling Zhu <jolin.qiulingz@gmail.com> wrote:
 +
 +
    Hi Ofer,
 +
 +
    Thanks a lot for all of these information/materials. I have downloaded all the stuff you attached and I am reading your thesis now. There is one more thing, can I have a user account for your wiki, since now I am not able to read the "Getting Started" part.
 +
 +
    Yes, a phone talk for us would be good. Tuesday is good for me. I have a meeting from 1-2pm EST, which is 10am-11am for your PST time. Any other time including night is OK to me.
 +
 +
    I will work on the generator this week and try to get back to you later this week or earlier next week. How about let's decide the exact meeting time by then?
 +
 +
    Thanks.
 +
    Jolin
 +
 +
 +
 +
 +
   
 +
 +
    On Sun, Mar 13, 2011 at 1:41 AM, Ofer Shacham <shacham@stanford.edu> wrote:
 +
 +
   
 +
 +
    Hi Jolin,
 +
 +
    I apologize for the delay in getting you the code for Genesis2, but here is everything now:
 +
 +
    ·        Attached please find the Perl libraries that you need to run Genesis2. All you need to do is to
 +
 +
    o  Copy to your favorite location (e.g., $USER/bin/) and then do “tar -xjf PerlLibs.tar.bz2 -C PerlLibs”
 +
 +
    o  Since this is source code, please don’t put those libraries in a publically accessible folder.
 +
 +
    ·        I created a publically accessible Wiki with the Genesis2 user guide: http://genesis2.stanford.edu/mediawiki/index.php/Main_Page. It also includes installation instructions.
 +
 +
    o  In addition, in this link you will find a draft of my thesis: http://stanford.edu/~shacham/thesis/tmp/. Chapter 3 is the high level description of the tool and why I created it. The appendix is written as a user manual. It contains installation instructions, all the commands etc. It also contain a couple of code examples (source is also attached here, with an example makefile).
 +
 +
    ·        I added two design examples with makefile etc. One is just the design example that is in my thesis appendix---a register file generator. The other is a variable bit wallace tree generator with a small testbench. Use “tar –xjf <FILENAME>.tar.bz2 –C <FILENAME>”  to unzip the files.
 +
 +
    o  I still plan to work out some small demo based on your code but that might take a little longer. (unless by the time I get to do that you already tell me that everything is working perfectly ;-))
 +
 +
    ·        You will notice that genesis2 interface the world through an XML config file. That’s the interface that our gui use. I’ll send the gui once we can package it nicely but we are still working out some bugs. Meanwhile, you will see that this XML is also easily changeable manually. (an XML parsing/dumping libraries exist in every language if you wanted to simply connect it to your existing gui)
 +
 +
    ·        If you have any problem, please feel absolutely free to email or call me (650-8626017). Any feedback would be greatly appreciated.
 +
 +
    Ofer.
 +
 +
   
 +
 +
    From: Qiuling Zhu [mailto:jolin.qiulingz@gmail.com]
 +
    Sent: Monday, February 28, 2011 12:20 PM
 +
    To: Ofer Shacham
 +
    Subject: Re: hello from Ofer
 +
 +
    I attached the a folder that contains all the source codes. There is a README file in it and you can follow that to compile and run the code. It is still an on-going work and it's a little bit messed at this stage, so I am not sure if it is readable for you.  Please let me know if you have any problems. Also you can try the corresponding web generator at this address: http://www.ece.cmu.edu/~pam/interp/index.html

Revision as of 23:11, 20 March 2011

Genesis2 Frequently Asked Questions... And Answers

Unprocessed Questions

can genesis produce the GUI(Graphical User Interface) for me automatically?

   I am now starting to build more complicated generator. One more question is, can genesis produce the GUI(Graphical User Interface) for me automatically?  I hope that there will be a Graphical User Interface which could be provided to the students in my advisor's class.  So that they could make experiments on my design. Is it possible/easy to do that?

On Thu, Mar 17, 2011 at 8:50 PM, Ofer Shacham <shacham@stanford.edu> wrote:


   Aha, excellent question. So remember, what we wanted to do was make it easier and standardize for people to make generators, right?
   So with this in mind, we created the XML as genesis’s interface to the world, with a simple and standard schema. Our gui, is completely independent of genesis---it reads in the xml out and draws that on the screen. It does not know (or care)if this is an xml for a Pentium or FFT. All it needs is to know where the source code (the .vp files) are. It then shows all the <Parameters> (hierarchically) and makes them available for users to tweak. It also shows the <ImmutableParameters> but does not let users to tweak them.
   You can see a couple of examples in http://www-vlsi.stanford.edu/ig/. For example:
   ·         click on “(Real-ish) CMP Generator”
   ·         Click on DUT
   ·         Look for processors – there is only one and it is called P0
   ·         Click “up” (don’t hit the back arrow)
   ·         change the number of processors to 3 and click on submit.
   ·         Click on DUT
   ·         Now there are P0, P1 and P2 (there are also a bunch of other modules like I- and D-caches etc).
   ·         Click on rf (stands for regfile). This is much the same regfile that I sent you in the example. You can now change its base address etc. Genesis will uniquify it and rename modules and files etc.


   We (ok, mostly Steve :) are working on getting the gui wrapped so that we can send it to you to install locally. Steve, you said you needed to know what kind of html installation they have, right? Can you elaborate for Jolin?


   Thanks,
   Ofer.

more questions

   From: Qiuling Zhu [1]
   Sent: Thursday, March 17, 2011 4:24 PM
   To: Ofer Shacham
   Subject: Re: Genesis2 for CMU generators


   Hi Ofer,
   Thanks a lot for this detailed explanation. I think I have understood how it works and I am now able to control the parameters from the "config.xml" file. As you suggested, I just run the genesis once to get the hierarchy_out.xml and modify this output xml to create the input xml. It works well to me.
   Thanks,
   Jolin


   On Thu, Mar 17, 2011 at 3:15 PM, Ofer Shacham <shacham@stanford.edu> wrote:
   Hi Jolin,


   Genesis accepts (optional) an xml as input for elaboration of the code. In the makefile examples I sent you, it already does that. That’s the “-xml $(GENESIS_CFG_XML)” flag, and it reads the config.xml by default. You can change it by running “make clean run SIM_ENGINE=mentor GENESIS_CFG_XML=YourOwnFile”. Genesis knows how to parse the xml file and force the value of the parameters. However, note that the xml can only override a default value of a parameter. It cannot override a parameter that you already overwritten in the generate statement upon instantiation. The reason is that we assume that if you decided to override the value at instantiation, you probably knew what you were doing, and might also have other code that assumes that value. So in summary, the overriding priorities are:
   1.       $self->define_param(PrmName =>PrmValue)  --- Lowest priority
   2.       XML input --- Can override define_param
   3.       generate(‘flop’, ‘pipestage7’, PrmName =>NewPrmValue) --- Can override both define_param and xml
   4.       $self->force_param(PrmName =>PrmValue) --- mutually exclusive with all other, and cannot be overridden in anyway (Advanced users: useful for exporting information from one module to another: module A uses force_param to declare something. Module B uses $A->get_param to read that. )


   To make life easy and also to interact with the gui, genesis also dumps out (optional) a complete xml of the hierarchy. In the example makefiles I sent you these would be the “-hierarchy wallace.xml” for the wallace tree (I should probably fix that), and “-hierarchy $(GENESIS_HIERARCHY)” for the regfile. The output XML is a superset of the input xml because:
   ·         For the input xml, you only need to specify modules that you care about and parameters that you want to override. The output XML contains all the modules and all the parameters. Whether override-able or not.
   ·         The output XML contains a bunch of meta information regarding the source files, the source templates and the uniquified modules that were created. This info is not needed for the input xml.
   Therefore, in the examples I sent, the input xml is pretty much empty. For the wallce tree it only has “<top></top>”. For the regfile it has a little more info but still, all fields are empty.


   Important note: I typically run the genesis once to create the output xml so that I can use it as template to create my input xml. You can also read more about the schema for both xmls at: http://genesis2.stanford.edu/mediawiki/index.php/Genesis2#Program.xml_File and http://genesis2.stanford.edu/mediawiki/index.php/Genesis2#Hierarchy_Out


   Finally, to your question:
   In the Wallace tree, all parameters were bound at instantiation. In the regfile, I only bound the type of register but left the default value un-bound. As a result, when you run the elaboration, in the xml you will see (this is just a snippet of it of course) for register “DataIn_reg”, the following code:
           <DataIn_reg>
             <BaseModuleName>flop</BaseModuleName>
             <ImmutableParameters>
               <FLOP_TYPE>eflop</FLOP_TYPE>
               <FLOP_WIDTH>32</FLOP_WIDTH>
             </ImmutableParameters>
             <InstanceName>DataIn_reg</InstanceName>
             <Parameters>
               <FLOP_DEFAULT>0</FLOP_DEFAULT>
             </Parameters>
             <SubInstances></SubInstances>
             <UniqueModuleName>flop_unq4</UniqueModuleName>
           </DataIn_reg>


   Note that the ‘FLOP_DEFAULT’ param is the only one that is not bound so genesis identifies it and put it on the <Parameters> list. All other properties of the flop were bound at instantiation so those are on the <ImmutableParameters> list. This way I can (either manually or through the gui) tweak the value of each and every parameter individually. Makes sense?


   Having said all that, I could have created a default value parameter for each flop at the top level and then propagate it to the flops through the code. Then those default values would have been immutable in the flop, but then they would be override-able at the top level (i.e. they would show up in the <Parameters> list at the <top> item of the XML.


   I hope this long explanation made things clearer and not worse J,
   Ofer.



   From: Qiuling Zhu [2]
   Sent: Thursday, March 17, 2011 9:09 AM


   To: Ofer Shacham
   Subject: Re: Genesis2 for CMU generators


   Hi Ofer,
   I see.. Actually that's what I plan to do next: specify the parameter values from outside by the XML configuration. Did you do this in the example designs of "reg file" and "wallace"?  Should I write a config.xml file ahead? I generally don't know how to do it.  When you run the code, it is able to read in the .xml files automatically and read in the parameters from .xml files?
   Thanks,
   Jolin


   On Thu, Mar 17, 2011 at 11:56 AM, Ofer Shacham <shacham@stanford.edu> wrote:
   Great!
   Small tip: in many cases, a parameter is local to a module and does not change its interface. In these cases, it sometimes makes sense to add the parameter but to NOT bind it at instantiation (i.e., in the ‘generate’ call). When you do that, this parameter can be controlled from the outside by the XML configuration (and eventually by the gui).
   (Of course, you can always just propagate the parameter to the top level and control it from there if if you find that more convenient.)


   Best,
   Ofer.


   From: Qiuling Zhu [3]
   Sent: Thursday, March 17, 2011 8:49 AM


   To: Ofer Shacham
   Subject: Re: Genesis2 for CMU generators


   Hi Ofer,
   Thanks you very much for these detailed explanations.
   I have added more parameters to my design and I am even able to debug the code  based on the error message by checking the *.pm file. It works well so far.  Will let you know if I need more help.
   Thanks again.
   Jolin


   On Wed, Mar 16, 2011 at 6:06 PM, Ofer Shacham <shacham@stanford.edu> wrote:
   Hi Jolin,


   I looked at your code. This was only a small issue of a couple of syntax errors in your Perl code. I do admit however that the error messages from genesis2 needs to be improved significantly!


   Here is how to fix your code:
   Line 24:
   Replace:
   //;              unless($flop_type = "BILINEAR" || $flop_type = "NEAR_NEIGHBOR")
   With:
   //;              unless($inter_order =~ m/^BILINEAR$/i || $inter_order =~ m/^NEAR_NEIGHBOR$/i);
   Explanation: in Perl you can compare strings using the ‘eq’ operator (e.g.:  if ($my_str eq “someString”)…, if ($my_str eq $your_str)…) . However, if you want to compare sub strings or regular expressions (e.g., in this case make it case insensitive) you typically use the ‘=~’ operator. So in the code above I made it compare to a regular expression: to return true, it must find a substring which starts with and end with ‘BILINEAR’ (this is what the ^ and $ sign doing-- ^ is line-start and $ is line-end). I also made it case insensitive using the ‘i’ like I showed in the previous email.


   Line 191:
   Replace:
   //; if ($inter_order =~  m/^bilinear$/i)  
   With:
   //; if ($inter_order =~  m/^bilinear$/i) {
   Explanation: in Perl, you always need to have the open curly braces ‘{‘ after the if condition.


   Line 280:
   Replace:
   //;# if ($inter_order =~  m/^bilinear$/i)  
   With:
   //; if ($inter_order =~  m/^bilinear$/i)  {
   Explanation: exactly the same as line 191.


   That’s it. It should work perfectly now. You may want to copy over the new makefile I sent you (and change the source file names).


   I’m here if you need any further help!
   Ofer.


   From: Ofer Shacham [4]
   Sent: Wednesday, March 16, 2011 2:13 PM


   To: 'Qiuling Zhu'
   Cc: 'Ofer Shacham'
   Subject: RE: Genesis2 for CMU generators


   Hi Jolin,
   Attached please find new tars with the same design examples, but this time with a makefile that supports mentor tools. You will still need to do whatever you are used to doing to get your mentor tools sourced to the environment of course. (you can do ‘which vlog’ and ‘which vsim’ on your linux shell to make sure that both commands are in your path etc.)


   Since the makefile now supports both environment, you need to do: ‘make clean run SIM_ENGINE=mentor’ (i.e. add SIM_ENGINE=mentor to whatever make command you are using). Let me know if it works. I’ll look at your code next.
   Ofer.



   From: Ofer Shacham [5]
   Sent: Wednesday, March 16, 2011 10:57 AM
   To: 'Qiuling Zhu'
   Cc: 'Ofer Shacham'
   Subject: RE: Genesis2 for CMU generators


   I’m happy that you started looking at the code and I’m happy to answer your questions: My answers below:


   May I ask you some questions about the genesis2? YES!
   (1) I am now able to run your design example of 'flop' and 'wallace' by following your README file and it generates the verilog files to me successfully, but I have problems with the example of "register file": it shows error of "make: vcs: Command not found" when I type "make clean run" in that directory.
   Vcs is just the Sysnopsys simulator. I noticed that you used a Mentor flow where you compile using vlog and run using vsim. We are using Synopsys flow here where we compile with ‘vcs’ and run using ‘simv’. I’m working on a new makefile example that would support the Mentor flow. Will probably send it later today or tomorrow. Meanwhile, if you just want to look at the Verilog use “make gen” (or better yet”make clean gen”).


   (2) I built a small and simple example of my own design "rotation.vp", it has only one parameter of "INTER_ORDER", which could be "BILINEAR" or  "NEAR_NEIGHBOR". I wrote the source files(rotation.vp, top.vp and Makefile) by slightly modifying your "flop" design files. However, when I run it by typing "make clean run", it shows errors of "Genesis2::top: ERROR at (or right after) line 10 of file /*****/top.vp".  I attached my files to you and could you help me to look at what's wrong with my codes?  I wonder if there is anything else that I need to do besides preparing .vp files and Makefile?
   I’ll look at your code and send a separate email a little later.


   (3) About your design of "flop" (not "reg files"), can I ask you some simple questions ? (forgive me if these question are stupid since I am not that familiar with Perl)
      1)  In "flop.vp",  
            //; if ($flop_type !~ m/constant/i) {........
   -------------
    what's the meaning of "~ m/constant/i" ? 
   Perl is a scripting language that is all about regular expressions (i.e., string matching and manipulation).
   “if ($flop_type =~ m/constant/)” The “=~” means if the string $flop_type matches (matches=has a substring) the string “constant”
   “if ($flop_type =~ m/constant/i)” The “i” at the end makes it case insensitive (would match constant, consTANt,  CONSTANT, etc.)
   “if ($flop_type !~ m/constant/i)” The “!~” means the opposite of “=~”. That is, if the string $flop_type DOES NOT match the string “constant”
   A very concise and easily readable tutorial on perl regular expressions is here: http://www.troubleshooters.com/codecorn/littperl/perlreg.htm


   -------------------------------------------------------------------------------------------
      2)In "top_flop_only.vp"
      //; my $const_flop_obj = generate('flop', 'const_flop_eg', FLOP_TYPE=>'constant',
      //;                               FLOP_DEFAULT => 0xFF, FLOP_WIDTH => 32);
      `$const_flop_obj->instantiate()` (...);
   -------------
   what are "const_flop_obj ", "flop", "const_flop_eg" mapping to?  I thought "const_flop_eg" is the inst name, but when I look at the generated verilog file, the module name is "module flop_unq1". I wonder where you specify the name of "flop_unq1" or it must be in this format?
   Every module that is generated is an object (in this case “$const_flop_obj”). This object is a sub-instance of the parent module. That is, in this case “$const_flop_obj” is a son/sub module of top. The base module name is ‘flop’, but you may end up generating many different flops, right? So we need to give each of the generated ‘flop’ modules a unique module name (similar to the work you had to do in your code manually. For example to create different “ftype"_twi_rom_"i”). Genesis2 does this for you. It checks if this is a new (and different) ‘flop’ and it names the module ‘flop_unq#N’. Does this makes sense? Of course, the flop object (in our case “$const_flop_obj”) knows what unique module it is and “$const_flop_obj->get_module_name” will return that value.
   The second argument is the name of the Verilog instance. The name of that instance (when Verilog is generated) is ‘const_flop_eg’. This means that we expect that when the Verilog for top.v be generated it would have a sub instance of type ‘flop’, but uniquified so let’s call it ‘flop_unq132’ and by the name ‘const_flop_eg’.
   The generated code should look something like this:
   module top();
   flop_unq132 const_flop_eg (…)
   endmodule


     Does this makes sense?


     3) Actually I have more questions regarding to the "parametrization methods" and "module instantiation methods". But I can ask you later when I solve these simple problems.
    Feel free, anytime!
      Please see attached of my design files.
   -------------------------------------------------------------------------------------------
   Thanks,
   Jolin




   From: Qiuling Zhu [6]
   Sent: Sunday, March 13, 2011 9:16 AM
   To: Ofer Shacham
   Subject: Re: Genesis2 for CMU generators
   Sorry, I made a mistake in my last email since I thought the meeting time you suggested is next next Tuesday (May 22).  Thursday is good to me. But I am not sure if I can work out it by then. Let me look at it first and I will let you know when I am prepared for a meeting.
   Thanks,
   Jolin
   On Sun, Mar 13, 2011 at 11:59 AM, Qiuling Zhu <jolin.qiulingz@gmail.com> wrote:
   Hi Ofer,
   Thanks a lot for all of these information/materials. I have downloaded all the stuff you attached and I am reading your thesis now. There is one more thing, can I have a user account for your wiki, since now I am not able to read the "Getting Started" part.
   Yes, a phone talk for us would be good. Tuesday is good for me. I have a meeting from 1-2pm EST, which is 10am-11am for your PST time. Any other time including night is OK to me.
   I will work on the generator this week and try to get back to you later this week or earlier next week. How about let's decide the exact meeting time by then?
   Thanks.
   Jolin




   On Sun, Mar 13, 2011 at 1:41 AM, Ofer Shacham <shacham@stanford.edu> wrote:


   Hi Jolin,
   I apologize for the delay in getting you the code for Genesis2, but here is everything now:
   ·         Attached please find the Perl libraries that you need to run Genesis2. All you need to do is to
   o   Copy to your favorite location (e.g., $USER/bin/) and then do “tar -xjf PerlLibs.tar.bz2 -C PerlLibs”
   o   Since this is source code, please don’t put those libraries in a publically accessible folder.
   ·         I created a publically accessible Wiki with the Genesis2 user guide: http://genesis2.stanford.edu/mediawiki/index.php/Main_Page. It also includes installation instructions.
   o   In addition, in this link you will find a draft of my thesis: http://stanford.edu/~shacham/thesis/tmp/. Chapter 3 is the high level description of the tool and why I created it. The appendix is written as a user manual. It contains installation instructions, all the commands etc. It also contain a couple of code examples (source is also attached here, with an example makefile).
   ·         I added two design examples with makefile etc. One is just the design example that is in my thesis appendix---a register file generator. The other is a variable bit wallace tree generator with a small testbench. Use “tar –xjf <FILENAME>.tar.bz2 –C <FILENAME>”  to unzip the files.
   o   I still plan to work out some small demo based on your code but that might take a little longer. (unless by the time I get to do that you already tell me that everything is working perfectly ;-))
   ·         You will notice that genesis2 interface the world through an XML config file. That’s the interface that our gui use. I’ll send the gui once we can package it nicely but we are still working out some bugs. Meanwhile, you will see that this XML is also easily changeable manually. (an XML parsing/dumping libraries exist in every language if you wanted to simply connect it to your existing gui)
   ·         If you have any problem, please feel absolutely free to email or call me (650-8626017). Any feedback would be greatly appreciated.
   Ofer.


   From: Qiuling Zhu [7]
   Sent: Monday, February 28, 2011 12:20 PM
   To: Ofer Shacham
   Subject: Re: hello from Ofer
   I attached the a folder that contains all the source codes. There is a README file in it and you can follow that to compile and run the code. It is still an on-going work and it's a little bit messed at this stage, so I am not sure if it is readable for you.  Please let me know if you have any problems. Also you can try the corresponding web generator at this address: http://www.ece.cmu.edu/~pam/interp/index.html