Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1093929
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T23:53:56+00:00 2026-05-16T23:53:56+00:00

Similar to this post http://feedproxy.google.com/~r/cadence/community/blogs/fv/~3/IvdCIla8_Es/extending-multiple-when-subtypes-simultaneously.aspx I want to make a macro that does loop

  • 0

Similar to this post
http://feedproxy.google.com/~r/cadence/community/blogs/fv/~3/IvdCIla8_Es/extending-multiple-when-subtypes-simultaneously.aspx

I want to make a macro that does loop unrolling to get around some of the when-subtyping and inheritance issues Specman has.

I’ve started with:

-- macros.e
<'
define <FOREACH_UNROLL'action> "FOREACH_UNROLL (<UNROLLEES>\[<unrollee'name>,...\]) (<STATEMENTS>{<statement>;...})" as computed {
   print <UNROLLEES>;
   print str_split(<UNROLLEES>,"/ *, */");
   for each in str_split(<UNROLLEES>,"/ *, */") {
      out(it.as_a(string));
      var statements := str_replace( <STATEMENTS>,"\"REPLACE_ME\"",it);
      result =appendf("%s %s;",result,statements);
   };
};
'>


-- main.e
<'
import macros.e
extend sys {
   run() is also {
      FOREACH_UNROLL [baz,foo,bar] {
         out("REPLACE_ME");
         out("part2","REPLACE_ME");
      };
   };
};
'>

When I run this, I get:

specman -c 'load $HOME/main; test'
Welcome to Specman Elite(64) (08.20.007-s)  -  Linked on Tue Dec 15 17:07:26
2009

Protected by U.S. Patents 6,141,630 ;6,182,258; 6,219,809; 6,347,388;
6,487,704; 6,499,132; 6,502,232; 6,519,727; 6,530,054; 6,675,138; 6,684,359;
6,687,662; 6,907,599; 6,918,076; 6,920,583; Other Patents Pending.

0 notifications were modified by command 'set notify -severity=WARNING
DEPR_START_TCM_ARG_BY_REF'
Checking license ... OK
Loading macros.e   (imported by main.e) ...
read...parse...update...patch...h code...code...clean...
Loading /nfs/pdx/home/rbroger1/main.e ...
read...parse...  <UNROLLEES> = "[35]"
  str_split(<UNROLLEES>,"/ *, */") =
0.      "[35]"
[35]
update...patch...h code...code...clean...
Doing setup ...
Generating the test using seed 1...

Starting the test ...
Running the test ...
REPLACE_ME
part2REPLACE_ME
No actual running requested.
Checking the test ...
Checking is complete - 0 DUT errors, 0 DUT warnings.

If you look at the printout of <UNROLLEES>:

<UNROLLEES> = "[35]"

Why does <UNROLLEES> give me [35] instead of the body inside the curly braces? 35 is the ascii value for #, so I’m at a loss why I would get a 35…

P.S. I realize macros are from the devil, but I think code copying is worse. I have to do this because Specman isn’t really polymorphic.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T23:53:57+00:00Added an answer on May 16, 2026 at 11:53 pm

    It turns out I needed to use the function str_expand_dots in my version of Specman (8.2).

    Here is the modified macros.e:

    define <FOREACH_UNROLL'action> "FOREACH_UNROLL (<UNROLLEES>\[<unrollee'name>,...\]) (<STATEMENTS>{<statement>;...})" as computed {
       -- print str_expand_dots(<UNROLLEES>);
       --print str_expand_dots(<STATEMENTS>);
       -- print str_split(str_expand_dots(<UNROLLEES>),"/ *, */");
       for each  in str_split(str_expand_dots(<UNROLLEES>),"/ *, */") {
          var unrollee := str_replace(it, "[","");
          unrollee = str_replace(unrollee, "]","");
          --out(unrollee);
          var statements := str_replace( str_expand_dots(<STATEMENTS>),"\"REPLACE_ME\"",unrollee);
          result =appendf("%s %s;",result,statements);
       };
    };
    

    Modified main.e:

    import macros;
    extend sys {
       run() is also {
          FOREACH_UNROLL ["baz","foo","bar"] {
             out("REPLACE_ME");
             out("part2","REPLACE_ME");
             if "REPLACE_ME" == "baz" {
                out("found baz");
             };
          };
       };
    };
    

    And the output:

    Welcome to Specman Elite(64) (08.20.007-s)  -  Linked on Tue Dec 15 17:07:26
    2009
    
    Protected by U.S. Patents 6,141,630 ;6,182,258; 6,219,809; 6,347,388;
    6,487,704; 6,499,132; 6,502,232; 6,519,727; 6,530,054; 6,675,138; 6,684,359;
    6,687,662; 6,907,599; 6,918,076; 6,920,583; Other Patents Pending.
    
    0 notifications were modified by command 'set notify -severity=WARNING
    DEPR_START_TCM_ARG_BY_REF'
    Checking license ... OK
    Loading /nfs/pdx/home/rbroger1/macros.e   (imported by main.e) ...
    read...parse...update...patch...h code...code...clean...
    Loading /nfs/pdx/home/rbroger1/main.e ...
    read...parse...update...patch...h code...code...clean...
    Doing setup ...
    Generating the test using seed 1...
    
    Starting the test ...
    Running the test ...
    baz
    part2baz
    found baz
    foo
    part2foo
    bar
    part2bar
    No actual running requested.
    Checking the test ...
    Checking is complete - 0 DUT errors, 0 DUT warnings.
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I was looking at this post: https://stackoverflow.com/a/2262200 and I have a very similar setup
I got the problem similar to this post here: https://rails.lighthouseapp.com/projects/8994/tickets/106-authenticity_token-appears-in-urls-after-ajax-get-request routes.rb map.namespace(:admin, :active_scaffold =>
I have seen this post here (http://stackoverflow.com/questions/151777/how-do-i-save-an-android-applications-state). I am having a similar problem I
I found this post http://www.netmagazine.com/tutorials/create-jquery-tab-system And modified this tabs to fit my current design.
I am doing a query that converts rows to columns similar to this post
This post is very similar to my previous one, but the data structures are
Currently I am using a post-build event command line similar to this one: xcopy
Django code samples involving post data often shows code similar to this: if request.method
I'm looking to do something similar to this post: How to hide controller name
I'm referring to a problem similar to the one in this post , because

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.