• AVR Freaks

Hot!SCL Procedure

Author
Chris White
New Member
  • Total Posts : 10
  • Reward points : 0
  • Joined: 2011/05/24 03:40:36
  • Location: Bristol, United Kingdom
  • Status: offline
2019/08/14 08:00:43 (permalink)
0

SCL Procedure

Am I correct in thinking these aren't actually supported in the simulator? I notice they're in the HTML documentation that gets installed with MPLAB-X, v5.05, but not in the online version.
 
I have tried putting them in my SCL. I don't get errors reported but as best I can tell the procedures simply get implemented immediately in sequence as if they were a part of the encapsulating process and not invoked on demand from the process body.

--
Chris White
#1

10 Replies Related Threads

    GeorgePauley
    Moderator
    • Total Posts : 1221
    • Reward points : 0
    • Joined: 2009/12/01 13:59:30
    • Location: Chandler AZ
    • Status: offline
    Re: SCL Procedure 2019/08/14 08:15:21 (permalink)
    0
    Procedures work.  They are pretty limited in functionality, but they work. 

    As far as executing "immediately" this sounds very much like typical SCL misunderstanding.  SCL is based on VHDL not on C.  VHDL, and SCL, can be tricky with respect to timing.  Can we see your (SCL) code?
    #2
    Chris White
    New Member
    • Total Posts : 10
    • Reward points : 0
    • Joined: 2011/05/24 03:40:36
    • Location: Bristol, United Kingdom
    • Status: offline
    Re: SCL Procedure 2019/08/15 05:01:48 (permalink)
    0
    configuration for "PIC18F2480" is
      shared label _CANInit;
      shared label slimset;
      shared label initevdata;
      shared label main0;
    end configuration;
    --
    testbench for "PIC18F2480" is
    begin
      test_timeout: process is
        begin
          wait for 2000 ms;
          report("setup_slim_ignore_unlearn_test: TIMEOUT");
          report(PC); -- Crashes simulator, MDB will report current source line
          PC <= 0;
          wait;
        end process test_timeout;
        --
      setup_slim_ignore_unlearn_test: process is
        type test_result is (pass, fail);
        variable test_state : test_result;
        procedure at_slimset() is
          begin
            report("setup_slim_ignore_unlearn_test: Reached slimset");
          end procedure at_slimset;
        begin
          report("setup_slim_ignore_unlearn_test: START");
          test_state := pass;
          --
          RB4 <= '0'; -- DOLEARN on
          RA5 <= '0'; -- UNLEARN on
          --
          wait until PC == _CANInit;
          report("setup_slim_ignore_unlearn_test: Reached _CANInit");
          --
          wait until PC == slimset;
          at_slimset();
          --
          loop
            wait for 1 ic;
            if PC == initevdata then
              report("setup_slim_ignore_unlearn_test: Unexpectedly reached initevdata");
              test_state := fail;
              wait for 1 ic;
            end if;
            exit when PC == main0;
          end loop;
          report("setup_slim_ignore_unlearn_test: Reached main0");
          --
          if RB6 == '1' then
            report("setup_slim_ignore_unlearn_test: Yellow LED (FLiM) on");
            test_state := fail;
          end if;
          if RB7 == '0' then
            report("setup_slim_ignore_unlearn_test: Green LED (SLiM) off");
            test_state := fail;
          end if;
          --
          if test_state == pass then
            report("setup_slim_ignore_unlearn_test: PASS");
          else
            report("setup_slim_ignore_unlearn_test: FAIL");
            report(PC); -- Crashes simulator, MDB will report current source line
          end if;          
          PC <= 0;
          wait;
        end process setup_slim_ignore_unlearn_test;
    end testbench;

     
    The output I'm seeing is,
    ...
    setup_slim_ignore_unlearn_test: Reached slimset
    setup_slim_ignore_unlearn_test: START
    setup_slim_ignore_unlearn_test: Reached _CANInit
    setup_slim_ignore_unlearn_test: Reached main0
    setup_slim_ignore_unlearn_test: PASS
    ...
    As you can see I'm getting "... Reached slimset" reported as if the Procedure is being invoked immediately rather than after the wait for PC to reach the label slimset, which is what I expected.

    --
    Chris White
    #3
    GeorgePauley
    Moderator
    • Total Posts : 1221
    • Reward points : 0
    • Joined: 2009/12/01 13:59:30
    • Location: Chandler AZ
    • Status: offline
    Re: SCL Procedure 2019/08/15 09:48:55 (permalink)
    0
    Well... fudge.  :(
     
    I can confirm that procedure's are executed whether or not they actually get called.  I will open a bug report against SCL.  But it might be awhile before it gets fixed.
     
    I can see 2 ways for you to proceed in the mean time.  First, just inline your procedure code wherever the procedure is called.  Second, abandon SCL in favor of Java plugin's to the simulator.  If option 2 sounds feasible to you, (most embedded developers run for the hills when they hear the word Java), you can learn more by downloading the MPLAB X SDK and reading the section on Simulator plugins.
     
    ----
     
    One thing I dislike about unit testing is the propensity of the tests to be conveniently written in ways to ensure they pass.  None of our tests are structured to test a procedure NOT being called.  We do have an independent test team to double check our efforts, but SCL has always been a bit out of reach for them.
    #4
    Chris White
    New Member
    • Total Posts : 10
    • Reward points : 0
    • Joined: 2011/05/24 03:40:36
    • Location: Bristol, United Kingdom
    • Status: offline
    Re: SCL Procedure 2019/08/15 11:35:07 (permalink)
    0
    Thanks George.
     
    I'd already dropped the use of procedures in my SCL. I had to revert one of my scripts to let you have the sample.
     
    As you mention unit tests that's what I'm trying to do, unit tests for some assembler code. I got excited when I cam across RPicSim but unfortunately that doesn't seem to work with the current version of MPLABX. I've started roughing some test out using a combination of MDB and SCL scripting. I'm thinking writing these is going to be hard and they're going to be fragile to code changes. It might be better to bite the bullet and download  RPicSim from GitHub then see if I can fix it, which will mean manning up to the SCL API and dissecting the MDB interface with something like NetBeans. It's a shame Microchip don't support it as I bet you guys would find it real easy and it would make a great add on to MPLABX wink: wink

    --
    Chris White
    #5
    GeorgePauley
    Moderator
    • Total Posts : 1221
    • Reward points : 0
    • Joined: 2009/12/01 13:59:30
    • Location: Chandler AZ
    • Status: offline
    Re: SCL Procedure 2019/08/16 10:57:30 (permalink)
    0
    I was afraid you might be using MDB.  (So many regression testing simulator user's do!)  MDB is fine, but that whole Java plug-in thing I talked about doesn't work in MDB.
     
    ---
     
    Using simulator (with SCL) to develop unit/regression tests via MDB is something that hundreds (thousands?) of simulator users have done for many years.  I have spoken with customers who have built so many tests over the years that it takes them a few DAYS to run their suites.  And these are usually serious customers, like automotive or medical, (with money on the line), that are using the simulator in this way.  So, I suspect your concerns about test fragility are perhaps a bit inflated?
     
    One of my long(er) term goals is to integrate simulator unit test capabilities into MPLAB X.  NetBeans, which MPLAB X is built on, has extensive unit test features built into it.  In fact the simulator team uses NetBeans and Junit extensively.  We want to get similar features into MPLAB X so that customers don't feel compelled to pop out to MDB.
    ---

    I've never heard of RPicSim, but...
     
    The MPLAB X SDK that I mentioned earlier was written with third party vendors in mind.  Big portions of the SDK are devoted specifically to helping third party tool developers (like RPicSim) integrate their tools into MPLAB X.  That said, Microchip's policy has been that it is that third party developer's responsibility to integrate into MPLAB X if that's what they want.  (It's not THAT hard! ;) )  So maybe you should contact the RPicSim folks and ask them to develop said plug-in?  The MPLAB X pool is warm, and we always welcome more swimmers!
    #6
    Chris White
    New Member
    • Total Posts : 10
    • Reward points : 0
    • Joined: 2011/05/24 03:40:36
    • Location: Bristol, United Kingdom
    • Status: offline
    Re: SCL Procedure 2019/08/19 12:26:30 (permalink)
    0
    Sorry George, I think I skimped a bit on my previous reply. The fragility I was thinking of is on the MDB side. Here to set breakpoints I either have to use source file:line number, or absolute address. Obviously these will shift around as and when the source code changes. On of my reasons for doing as much as I can in SCL is that it uses shared labels to compare against the PC, which is not fragile to such changes.
     
    Consequently so far, and I've just dipped my toes in on this one, I really just use MDB to load the program COF, the appropriate SCL script, setup some EEPROM data, and then launch the test. I do have a breakpoint at address 0 so I can use SCL to set the PC to this then wait, thus terminating the test.

    --
    Chris White
    #7
    GeorgePauley
    Moderator
    • Total Posts : 1221
    • Reward points : 0
    • Joined: 2009/12/01 13:59:30
    • Location: Chandler AZ
    • Status: offline
    Re: SCL Procedure 2020/03/25 14:03:35 (permalink)
    0
    After digging into this for awhile, I'm just about convinced that procedures have never worked, even back in MPLAB 8.
     
    The engineer who wrote SCL left the company about 18 years ago.  And the SCL code is... not easy to reverse engineer.  When we moved to MPLAB X I ported the code from C to Java.  I'm not too admit that there were numerous times where I wasn't completely sure what the code was doing.  But we tested, and tweeked, and then tested more until we were satisfied that all was working.

    I now understand the code better after several years of maintaining it.  And I don't see any errors per se, just no actual internal code to handle procedures correctly.  Not even in the original C code.

    Still there is one last test I would like to perform...  Anyone have a working copy of MPLAB 8 with a working project, compiler/assembler, etc. that would be willing to perform a quick little test for me?  :D
    #8
    ric
    Super Member
    • Total Posts : 26159
    • Reward points : 0
    • Joined: 2003/11/07 12:41:26
    • Location: Australia, Melbourne
    • Status: online
    Re: SCL Procedure 2020/03/25 14:57:19 (permalink)
    +1 (1)
    I still have several MPLAB8 projects, using XC8.
    (but I've never played with SCL...)
     

    I also post at: PicForum
    Links to useful PIC information: http://picforum.ric323.co...opic.php?f=59&t=15
    NEW USERS: Posting images, links and code - workaround for restrictions.
    To get a useful answer, always state which PIC you are using!
    #9
    GeorgePauley
    Moderator
    • Total Posts : 1221
    • Reward points : 0
    • Joined: 2009/12/01 13:59:30
    • Location: Chandler AZ
    • Status: offline
    Re: SCL Procedure 2020/03/26 09:26:40 (permalink)
    0
    I came pretty close to taking you up on the offer Ric.  mr green: mr green

    But I finally found the link to the MPLAB IDE 8.92 installer.  I was worried about compilers and the like but remembered that I could just stuff opcodes into program memory and run the simulator that way.  (Ah the good old days.)

    Anyway, I have verified that SCL procedures had the same problem in MPLAB 8 that they do in my ported version of SCL in MPLAB X.

    While I think it would be a fun challenge to go spend several weeks figuring out how to make procedures work, I have to weigh that against the features I wouldn't be working on while I did that.  Especially since it seems as though SCL procedures aren't as useful as one might think at first glance.  SCL allows as many processes as you want, and each process can be fine tuned to run at very specific times or conditions.  (In other words there's a fairly simple work around to not having procedures.)

    So for now, I think I will simply remove discussion of procedures from the SCL user's guide.  I'll leave the trouble report open, but move it down in priority on our infinitely long list of simulator issues.  (aka our backlog for you agile fans.)

    I would really love to throw out the current SCL and start over from scratch.  Anyone have an extra man-year they can lend me?  sad: sad
    #10
    GeorgePauley
    Moderator
    • Total Posts : 1221
    • Reward points : 0
    • Joined: 2009/12/01 13:59:30
    • Location: Chandler AZ
    • Status: offline
    Re: SCL Procedure 2020/03/26 10:21:02 (permalink)
    0
    I should READ my own darned documentation!  From the SCL User's Manual...

       Support for user defined procedures and functions is incomplete at this time.
    #11
    Jump to:
    © 2020 APG vNext Commercial Version 4.5