Simulink how to reproduce code generation bugs - matlab

I am interested in reproducing a Simulink bug reported in their official site. The bug is marked as a code generation bug. From my limited understanding, Simulink generates code when run in accelerator or rapid accelerator modes. Alternatively, I can generated code using Code > C/C++ Code > Build Model menu option but I do not now how to "run" this code in my Desktop computer.
To reproduce this bug (and possibly all other bugs categorized as code generation bugs), will it be sufficient to run simulation in these modes (accelerator or rapid accelerator mode) where Simulink generates code? Once the code is generated (in a directory called "slprj"), will these code suffer from the bugs reported?
Or, should there be any other approaches for generating code to reproduce this bug? I have never used the code generation feature of Simulink and only know that I can generate code for a model using "Code" menu (Code > C/C++ Code > Build Model). For this particular bug, I was able to use the above menu options and generated code (not in "slprj" directory, in a different directory which has _ert_rtw prefix). Should I inspect code in this directory? Also, I would like to know how to run this code to reproduce the bug.
Thank you for any advices!

This bug seems to be a missing initialization in the generated code which you can verify by investigating the generated code. Try to reproduce in the model attached to this bug report. However, in order to check the correctness between the model simulation result and the generated code, I would recommend using SIL based testing which is described here:
https://in.mathworks.com/help/ecoder/examples/software-and-processor-in-the-loop-sil-and-pil-simulation.html

Related

stm32: How to configurate SWV on software part without autogenerated code, HAL or LL

I am currently working on a library that abstracts the use of a stm board (specifically the NUCLEO-H723ZG) and we are on the profiling phase. I did get to make the profiling with the SWV after a big headache with the SB26 bridge that comes with the aforementioned board, using the auto generated code from stm32cubeIDE.
Now i need to do the same but abstracting the auto generated code from the stm32cubeIDE into a method that does all the configuration for you, but i cannot pin point what is really missing. I already have copied the SystemClock config, the PeriphCommonClock config, both SCB_Enable Cache and the MPU_Config (and yes both are using the same copy of the ioc configuration). Any ideas of what i could be missing?
I tried to profile an autogenerated main.c and after some configuration it worked perfectly.
Then i tried to do the same with a main.cpp and copying the methods form the autogenerated main one by one (just to see whose were needed) and after copying them all it didn t work. The code executes and the live expressions work. The configurations are the same on the .ioc and the debugging.
I m now looking for the minimum necessary for an SWV configuration method, preferably non dependant from HAL.

Netlogo: Internal error with Time extention

I have installed the time extension but my code will setup but not run. Same for the example models I've tried. The error message I receive is below. Thanks for your help!
P.S:I am running NetLogo version 6.0.4.
NetLogo is unable to supply you with more details about this error.
Please report the problem at https://github.com/NetLogo/NetLogo/issues,
or to bugs#ccl.northwestern.edu, and paste the
contents of this window into your report
java.lang.IllegalAccessError: tried to access field
org.nlogo.agent.World.tickCounter from class time.datatypes.LogoSchedule
at time.datatypes.LogoSchedule.getTickCounter(LogoSchedule.java:135)
at time.datatypes.LogoSchedule.performScheduledTasks(LogoSchedule.java:156)
at time.primitives.DiscreteEventSchedulerPrimitives$GoUntil.perform(DiscreteEventSchedulerPrimitives.java:95)
at org.nlogo.prim._extern.perform(_extern.java:36)
at org.nlogo.nvm.Context.stepConcurrent(Context.java:107)
at org.nlogo.nvm.ConcurrentJob.step(ConcurrentJob.scala:65)
at org.nlogo.job.JobThread.runPrimaryJobs(JobThread.scala:133)
at org.nlogo.job.JobThread.$anonfun$run$1(JobThread.scala:68)
at
scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:12)
at scala.util.control.Exception$Catch.apply(Exception.scala:224)
at org.nlogo.api.Exceptions$.handling(Exceptions.scala:41)
at org.nlogo.job.JobThread.run(JobThread.scala:66)
I'm not confident in my answer; however,
If you look at the code (updated Jan 14, 2017) (https://github.com/colinsheppard/time/blob/master/src/main/java/time/datatypes/LogoSchedule.java):
TickCounter getTickCounter(ExtensionContext context){
if(tickCounter==null){
tickCounter = context.workspace().world().tickCounter;
}
return tickCounter;
}
We see that the timer is getting the workspace's world's tickCounter.
If we look at the netlogo website for updates (https://ccl.northwestern.edu/netlogo/docs/transition.html), we see that:
One of our goals in NetLogo 6.0 has been to make it easier to develop
extensions and easy to develop more powerful extensions. To that end,
we’ve bumped the extension API from 5.0 to 6.0. Existing extensions
will need to recompile changing the “NetLogo-Extension-API-Version” in
their jar’s MANIFEST.MF from 5.0 to 6.0.
Some of the changes we’ve made to the extensions API include :
org.nlogo.api.Context now allows access to the current world and
workspace objects without requiring a cast to an
org.nlogo.nvm.ExtensionContext. org.nlogo.api.Workspace has been
introduced as a stable API for extensions to depend on. A NetLogo jar
is now available from BinTray. For a full list of changes between 5.0
and 6.0, please visit our Extension Transition Guide on GitHub.
That being said, I think the source code for the timer extension hasn't done the migration to conform to the new updates. You can see that it explicitly mentions the ExtensionContext.
Unfortunately, I believe the solution is to update the timer source code and commit.
I'm afraid I can't tell what the problem is from the error statement posted. The time extension is in flux right now because the NetLogo development team is updating it for inclusion in future releases of NetLogo. But they are not done and not all the bugs are out.
I am using Colin Sheppard's version at https://github.com/colinsheppard/time
It has been reliable except for the discrete event simulation primitives. The date/time utilities and the time series tool work, but we know that the discrete event scheduling does not work under NetLogo 6.x. If you want to use the discrete event scheduling, I'm afraid you'll need to be patient until the NetLogo project gets their version fully debugged.
I temporarily put a fairly comprehensive example code here:
http://langrailsback.com/file-transfers/
It includes Colin's version of the extension.

System Generator configuration for Xilinx Co Simulation

I'm working on a cosimulation in simulink using either 2012a or 2011b, and System Generator 13.1. When building the library block for the hardware to be loaded onto the zynq fpga, I configure the system generator to be a 'Hardware Co-Sim,' everything through this step works. However, in the simulink/pc end of the simulation, I haven't found any good resources for how to configure. Am I correct in assuming it also should be set as a hardware co-sim and not some other setup (HDL netlist) or anything like that?
Currently, the system seems to be loading the block just fine, but the jtag library is missing, not sure if this is a sysgen issue, or software versioning issue. My understanding is that sysgen is still in beta for 2012a.
Thanks in advance.
Yes, it should be set as a hardware co-simulation (Your board->connection type).
Configuring of board occurs when You start simulation. (Or You can program it manually using Impact and next check "skip configuration" in block properties).

Where can I find good open source code flow visualization software?

I am working on an academic research regarding some very long functions in the Linux kernel (link, link).
For that research, I would like to use some code flow visualization tool, that would be able to plot a graph in which each vertex is a decision point and each edge is a piece of code which runs in a consequent way.
Do you know of any good, open source project that can visualize C code?
Perhaps a tool like KCacheGrind would be of help. It generates call graphs based on actual calls and cannot pre-generate a call graph without actually running the program, which may not suit your needs, but then it again it may.
History flow's are very neat for changes/diff across multiple versions.
Codeplex has a project, Dependency Visualizer which does support C also.
Gprof2Dot can render oprofile, this would get you dynamic info also.
CodeViz also (static tool) would work.
If your using gcc, gcc-xml has an introspector plugin also todo this.
You appears to want to acquire a flowchart of C source code ("decisions", "code blocks").
Something like this C flowchart?
To do this correctly, esp. for Linux kernal code, I'd expect you to have to preprocess the code first to get rid of macros and conditionals. I would assume that GCC would construct such a graph internally and that you ought to be able to get your hands on that graph.
Doxygen does some amount of 'visualization',
but you need to work on the code a bit for it to be usable.
Another interesting thing to check would be lxr
Linux Cross Referencer is a software toolset for indexing and presenting source code repositories. LXR was initially targeted at the Linux source code, but has proved usable for a wide range of software projects. lxr.linux.no is currently running an experimental fork of the LXR software.
I can recommend Sourcetrail. Can work with a compile_commands.json. Not sure if it's still maintained, though. But it's foss and you can fork it!

Graphically laying out wx app

Being really new to wx, I'm wondering if there is an IDE (especially for Linux) which would help me lay out a frame or dialog or whatever just to help me see what I'm doing. That means also creating the code for those changes.
I remember way back when using resource compilers for OS/2 and Windows that produced binaries that would then create the window, and was hoping for something similar (though obviously not binary if wx doesn't support that).
I use wxFormBuilder. It is written in wxWidgets, so it works on Linux quite well. It can generate C++ code or XRC files. Make sure you understand its philosophy, and use it like this:
generate C++ code for the GUI
don't edit the code wxFormBuilder generated, but create new files
in new files, derive new classes from the classes it generated
implement event handlers in you own class (wxFB creates virtual function for each event handler you wish to use)
I usually name the wxFormBuilder generated classes/files like, for example, MainFrameGUI, and one with implementation (derived one in which I write all my code) would be just MainFrame. This enables you to change the visual layout and regenerate C++ files from wxFB at any time without overwriting your code.
DialogBlocks works quite well for me, although sometimes you need to edit the code to fix errors manually. It has a property editor that seems advanced enough.
Just another options is wxGlade. It does not have the that much features as the others mentioned seem to have, but it works just good enough for me to not daring to switch.
I use Code::Blocks IDE from http://www.codeblocks.org which has
- built-in GUI editor
- Cross compilable, so you can use it under Linux, OSX and Windows.
But I still use wxFormBuilder with it instead of built-in wxSmith editor. But they are compatible with internal wxSmith.
For windows you've got "wx-devcpp" which is Blodsheed Dev C++ with some addons providing what you looking for
Here is project page
http://wxdsgn.sourceforge.net/