Drawing schematic out of yosys using Latex with CircuitTikZ and convert it into a PDF? - yosys

Drawing circuit diagrams using logic gates symbols like a traditional logic gate-level netlist.
I saw the following:
Drawing circuit diagrams (with logic gates) in LaTeX
https://tex.stackexchange.com/questions/32839/drawing-circuit-diagrams-with-logic-gates-in-latex
and was wondering if there is a plan [or if this idea is possible or not] to create a schematic out of the Verilog output into a PDF file using LaTex and CircuitTikZ?
I am still reading up on it. Are there plans to have a schematic GUI viewer in the long term for yosys?
What would be the best way to get this at least looked at please?
A way to have a PDF view of logic gates symbols and D-type flip flops would really help.

Yosys has a schematic viewer via the "show" command. It doesn't handle complex designs very well, but it does allow you to "see" what's going on within a synthesized design.
To use it, read your design in and synthesize it. Then run the "show" command. Without an argument, it should show the whole design, although you can select just a portion of the design if you would like to show that.

Related

Automated Testing on graphic outputs

I wonder is there any tool or standard methods to automatically testing programs that produce graphic outputs.
For example, a simple painting application is built allowing users to draw circles and rectangles in specific locations. The tests probably need to check whether the shapes are located in the exact place as specified.
My problem is: is there a standard way to automate the test procedure instead of letting tester manually check the outputs again and again?
There are several approaches, but the most important is, that the GUI part comes last.
The GUI is only responsible (or should be) for visualizing data. This implies that you have some underlying models and functionality, which is told to create a circle or rectangle at a certain position. You would usually test this first in order to make sure, your functionality does the right things and the underlying data is correct. Functionality and models can be fully covered by regular API tests.
Your particular question is to check, whether the visualization part is correct. You have IMHO two options for automation:
Use screenshots and diff the drawing canvas between a static expectation screenshot and the actual test result
Use tracing: You would take a screenshot from the canvas area and convert it to some vector image that allows you to check certain vectors for being at the right place
In general, GUI specifics such as the right color, exact placing are still human tasks. You can only try testing as much as you can using API tests and reduce the human part to a minimum.

Does a language describe things beyond itself?

I now have sufficent exposure to the Objective-C that if i'm stuck with anything, I know how to think of the problem in terms of a likely tool I need and go look for it. Simple really. There's A Method For That. So nothings a real problem anymore.
Now I'm looking deeper at the language in broader terms. We write stuff. The compiler hews out all the code to execute it. From a simple flashlight app thats a if/then decision to turn on, to a highly complex accelerometer driven 3D shoot 'em up with blood 'n guts and body parts following all sorts of physics, the compiler prepares the code ready to be executed like a giant railway layout. No matter how random it appears on the screen, everything possible can be generically described and prepared for.
So here's the question:
Are there cases where something completely unexpected to the software designer can still be handled without an execution halt? Maybe I'd better re-frame the question a few different ways: Can a ( objective-C ) program meta-compile within itself in response to an unplanned-for user request? or to re-put my opening remark, are there tools or methods for unlikely descriptions of unlikely problems?
I think #kfb has the right comment about metaprogramming. Check out the Runtime docs in conjunction with metaprogramming tutorials.
Parts of your last question might be in the realm of this doc.
If your looking for ways to reduce the size of your code base for the lesser used features, one idea might be to make the features internet based (assuming connectivity is not a problem).

how to convert the control design from simulink to C

I have designed a control system in simulink for my project. Now I need to convert this design into C code. But presently no specific hardware processor has been decided on which the code will reside. So I need to run my code from within matlab. I am very new to the industry, so I am unaware of the steps that are followed to change the control design from simulink to embedded C.
Since I have no practical experience about the workflow that I am supposed to follow can I please get some guidance on what are the general norms that has to be done in order to achieve my requirement.
Workflow recommendation:
Make sure your design is tested enough with Simulation. You don't want to detect simple errors when you control real hardware.
Investigate/decide on target requirements. Do you have limited resources (memory/speed) and must customize the generated code to fit a target interface you should use embedded coder. Otherwise Simulink coder could be enough (If you have embedded coder use it anyway).
Make sure your model interfaces match what you expect on target considering datatypes, sizes, logged data and states. If you have special requirements for how to interface the code, you need to set storage classes on signals and other data. If you can live with the default code interface your life will be a lot easier.
Set the proper target in configuration parameters/Code generation/System target file. grt.tlc for rapid prototyping code and ert.tlc for embedded code. Then you can look through optimization and code generation properties and set as you would like. If your target has specific datatypes you should also change the embedded hardware implementation to match datatypes on your target.
Generate code (ctrl-b).
Integrate the code in your target project. Call _initialize once first then in a time based loop set inputs, call _step and read outputs.
It is also possible to make you own custom target to customize the code interface and provide desired output directly, including compiling and downloadingn to target. This is mainly for rapid prototyping and I recommend doing it manually first a few times and then decide if it is worth the effort to automate.
You might want to start looking at some of the examples or videos of Simulink Coder and Embedded Coder. Simulink Coder is for generating C/C++ code, but not necessarily optimised for running on embedded processors (it may be for Rapid Prototyping or Hardware-in-the-Loop purposes for example). Embedded Coder is an add-on to Simulink Coder for optimising the generated code to run on embedded hardware.
You might also want to register some some of their webinars on that topic or look at some recorded ones (there are plenty to choose from).

Using flow chart or diagram for routines across programs

I have a busy set of routines to validate or download the current client application. It starts with a Windows desktop shortcut that invokes a .WSF file. This calls on several .VBS files, an .INI for settings, and potentially a .BAT file. Some of these script documents have internal functions. The final phase opens a Microsoft Access database, which entails an AutoExec macro, which kicks off some VBA, including a form which has a load routine of its own in VBA.
None of this detail is specifically important (so please don't add a VBA tag, OR criticize my precious complexity). The point is I have a variety of tools and containers and they may be functionally nested.
I need better techniques for parsing that in a flow chart. Currently I rely on any or all of the following:
a distinct color
a big box that encloses a routine
the classic 'transfer of control' symbol
perhaps an explanatory call-out
Shouldn't I increase my flow charting vocabulary? Tutorials explain the square, the diamond, the circle, and just about nothing more. Surely FC can help me deal with these sorts of things:
The plethora of script types lets me answer different needs, and I want to indicate tool/language.
A sub-routine could result in an abort of the overall task, or an error, and I want to show the handling of that by (or consequences for) higher-level "enclosing" routines.
I want to distinguish "internal" sub-routines from ones in a different script file.
Concurrent script processing could become critical, so I want to note that.
The .INI file lets me provide all routines with persistent values. How is that charted?
A function may have an argument(s) and a return value/reference ... I don't know how to effectively cite even that.
Please provide guidance or point me to a extra-helpful resource. If you recommend an analysis tool set (like UML, which I haven't gotten the hang of yet), please also tell me where I can find a good introduction.
I am not interested in software. Please consider this a white board exercise.
Discussion of the question suggests flowcharts are not useful or accurate.
Accuracy depends on how the flow charts are constructed. If they are constructed manually, they are like any other manually built document and will be out of date almost instantly; that makes hand-constructed flowcharts really useless, which is why people tend to like looking at the code.
[The rest of this response violate's the OPs requirement of "not interested in software (to produce flowcharts)" because I think that's the only way to get them in some kind of useful form.]
If the flowcharts are derived from the code by an an appropriate language-accurate analysis tool, they will be accurate. See examples at http://www.semanticdesigns.com/Products/DMS/FlowAnalysis.html These examples are semantically precise although the pages there don't provide the exact semantics, but that's just a documetation detail.
It is hard to find such tools :-} especially if you want flowcharts that span multiple languages, and multiple "execution paradigms" (OP wants his INI files included; they are some kind of implied assignment statements, and I'm pretty sure he'd want to model SQL actions which don't flowchart usefully because they tend to be pure computation over tables).
It is also unclear that such flowcharts are useful. The examples at the page I provided should be semiconvincing; if you take into account all the microscopic details (e.g., the possiblity of an ABORT control flow arc emanating from every subroutine call [because each call may throw an exception]) these diagrams get horrendously big, fast. The fact that the diagrams are space-consuming (boxes, diamonds, lines, lots of whitespace) aggravates this pretty badly. Once they get big, you literally get lost in space following the arcs. Again, a good reason for people to avoid flowcharts for entire systems. (The other reason people like text languages is they can in fact be pretty dense; you can get a lot on a page with a succinct language, and wait'll you see APL :)
They might be of marginal help in individual functions, if the function has complex logic.
I think it unlikely that you are going to get language accurate analyzers that produce flowcharts for all the languages you want, that such anlayzers can compose their flowcharts nicely (you want JavaScript invoking C# running SQL ...?)
What you might hope for is a compromise solution: display the code with various hyper links to the other artifacts referenced. You still need the ability to produce such hyperlinked code (see http://www.semanticdesigns.com/Products/Formatters/JavaBrowser.html for one way this might work), but you also need hyperlinks across the language boundaries.
I know of no tools that presently do that. And I doubt you have the interest or willpower to build such tools on your own.

Converting Actionscript syntax to Objective C

I have a game I wrote in Actionscript 3 I'm looking to port to iOS. The game has about 9k LOC spread across 150 classes, most of the classes are for data models, state handling and level generation all of which should be easy to port.
However, the thought of rejiggering the syntax by hand across all these files is none too appealing. Are there tools that can help me speed up this process?
I'm not looking for a magical tool here, nor am I looking for a cross compiler, I just want some help converting my source files.
I don't know of a tool, but this is the way I'd try and attack your problem if there really is a lot of (simple) code to convert. I'm sure my suggestion is not that useful on parts of the code that are very flash-specific (all the DisplayObject stuff?) and also not that useful on lots of your logic. But it would be fun to build! :-)
Partial automatic conversion should be possible, especially if the objects are just 'data containers', watch out for bringing too much as3-idiom over to objective-c though, it might not always be a good fit.
Unless you want to create your own (semi) parser for as3 you'd need some sort of a parser, apparently FlexPMD has one (never used it), and there probably are others.
After getting your hands on a parser you have to find some way of suggesting to the system what parts could be converted automatically. You could try and add rules to the parser/generator script for the general case. For more specific cases I'd use custom metadata on the actual class/property/method, assuming a real as3 parser would correctly parse those.
Now part of your work will shift from hand-converting files to hand-annotating files, but that might be ok for you.
Have the parser parse your classes and define actions based on your metadata that will determine what kind of objective-c class to generate. If you get this working it could at least get you all your classes, their simple properties and method signatures (getting the body of the methods converted might be a bit too much to ask but you could include it as a comment so you'd have a nice reference while hand-translating).
PS: if you make this into a one way process be very sure you don't need to re-generate it later - it would be bad if you find out that you have been modifying the generated code and somehow need to re-generate all those classes -- that would mean you'll have to redo all your hard work!
I've started putting a tool together to take the edge off the menial aspects of this process.
I'm trying to figure out if there's enough interest to make it clean and stable enough to release for others to use. I may just do it anyway.
http://meanwhileatthelab.blogspot.com.au/2012/08/automating-process-of-converting-as3-to.html
It's so far saving me a lot of time while porting one of my fairly large games from AS3 to objc.
Check out the Sparrow Framework. It's purported to be designed with Actionscript developers in mind, recreating classes that sort of emulate display list and things like that. You'll have to dive into some "rejiggering" for sure no matter what you do if you don't want to use the CS5 packager.
http://www.sparrow-framework.org/
even if some solution exists, note that architectural logic is DIFFERENT, and many more other details.
Anyway even if posible, You will have a strange hybrid.
I am coming back from WWDC2012, and the message is (as always..) performance anf great user experience.
So You should rewrite using a different programming model.