Displaying verilog structures in gtkwave from FSDB - gtkwave

GTKwave 3.3 does not display Verilog structures dumped by VCS into FSDB.
I declare a typedef:
typedef struct packed {
logic [DATA_WIDTH-1:0] data;
logic valid;
logic fp;
} in_tdef;
And then use it as input:
input in_tdef isv_data_in;
but GTKwave does not display this port. I can see all other single bit vectors or busses but not the structure. I do not see any switches that I need to use to enable displaying structures.
Can gtkwave 3.3 display structures, or array of structures?

GTKwave presents structures at a “submodule” hierarchy. Elements of the structure are expanded in the hierarchy pane.

gtkwave 3.3 does pretty-print packed struct. But the result also depends on the the source of the dump. If the packed struct is dumped as a big wire and gtkwave can do nothing about that. For a VCD file, you can open it with a text editor to see whether the packed struct is dumped correctly.

Related

How do I include code snippets (not objects) in an Arduino program?

Problem Solved!!! See below for solution
I was about to post this question and decided to check the web one more time. This site https://www.freepascal.org/docs-html/prog/progsu40.html
has this statement: The {$I filename} or {$INCLUDE filename} directive tells the compiler to read further statements from the file filename. The statements read there will be inserted as if they occurred in the current file.
This is exactly what I want to do with Arduino. How do I do it?
My Skill Set:
Writing code since 1967. Yes, I survived Y2K, which was a real thing; so I'm not new to programming/debugging. Mainframes and PC's. Very solid COBOL and SAS skills. Good skills with Borland/Lazarus Object Pascal. Weak C/C++ skills.
Background:
I have two working Arduino programs that are used on a model railroad. Prog1 uses infrared sensors to light LEDs that indicate the position of a train in a tunnel. I built the IRSensor class to handle a single sensor. Prog2 uses push-buttons to set a route through several track switches. Each track switch is set via a servo. I extended the Servo class to TOServo, which encapsulate most of the commonality in each track switch.
Now I'm working on a different model railroad and need merge Prog1 and Prog2 into a single program. Building Prog3 via copy/paste from programs 1 & 2 has proved unwieldy.
Problem:
How do I tell the Arduino pre-processor/compiler to "insert filename here; do not compile, pre-compile, or otherwise process the filename unless it is wrapped around the file asking for the insertion"?
What I've tried:
I built Prog3 by separating the code for Prog2 into 3 sections -- Main program storage & code and 2 include statements (Storage definitions and executable code for TOServo). These include statements pull in code that define or access an array of TOServo. I've used several suffixes (.h/.ino and .h/.cpp and .c/.c), and they all generate 'not declared in this scope' errors.
Finally:
Thanks for your help.
SOLUTION
My .ino file had grown large & unwieldy. The 'solution' was to move a large segment of code and matching declarations to external .h/.cpp files, and to access those files via #include statements. The program would not compile (undefined variables); they were, in fact, defined but the compiler couldn't find them. After many attempts to fix or rearrange the code, finally two things dawned on me.
1)The Arduino pre-compiler changes (rearranges?) my code so that C++ and the Arduino CPU can work together. This means that the code I see is not always the code the compiler sees.
2)My .h/.cpp files define and manage an array of servo objects. I could convert those files into an object that I access from the main .ino file.
So I've solved my problem. Thanks to all those who have posted in many forums/sites, especially to Tarick Welling who stayed with me to the end.

cuda global pointer allocation in different source file

I faced a situation that I need some tables to be filled in one source file (for example fill.cu) and then be used in different kernels in different source files.
I tried declaring a pointer __device__ float *myTable; as 'extern' in fill.h header file and adding that to others.cpp and defining that pointer in fill.cu and allocate and fill it there.
This way, I got linker error indicating that myTable has been already defined in fill.cpp.
After many unsuccessful try, I decided to put all kernels that need this table in same source file, this way everything works fine until I added an cudaMalloc in main function before allocating my table in fill.cpp.
This way I noticed that table values and data allocated in main are overlapped and using cuda debugging tools of MS visual studio 2015, I found that 2 allocated pointer are same!!!
Please advice how to declare a global pointer in cuda without conflict.
The traditional CUDA linkage model requires that all device symbols, textures, functions, etc. are defined and used within the scope of the same translation unit. It sounds like your code structure is violating this requirement.
You have two choices:
Continue to the same code structure, but provide wrapper functions which your main can call to perform operations on statically declared device variables, rather than directly manipulating device symbols with the CUDA API from other code.
Use separate compilation. Here, you define the device symbol you want to access in exactly one file and declare the same symbol as externeverywhere else you need to use that symbol. You must explicitly use several nvcc options to compile your device code and use a separate device code linking stage.
Both approaches are well documented.

How to handle "bytes" in QML?

Considering :
http://doc.qt.io/qt-4.8/qdeclarativebasictypes.html
there is no strict equivalent of "byte" in QML.
Nonetheless, I have to manipulate some datas in a whole project, and QML file are an intermediate for communications. And some of these datas are some byte...
What can I do ?
(found some links about QVariant but I don't feel like I can use it in QML)
I've already seen your question in Qt forum, but left with the intention that someone with better knowledge can help you.
Could you please tell about your necessity to use a byte in QML. If it is going to be standalone application, you can handle (and only can - I think) it using a C++ datatype like char and display/present it from the QML side.
If it just going to be a QML file, then I think you have to create a byte like object with Qt C++ and use it to store the values.
I definitely don't think that QML can handle file operations, neither can it access any serial port services. So the C++ can handle these situations without any difficulties.
If you don't actually use those bits in QML you might be able to save in an integer and then get those back.

Qt - meta object code

What do we mean by the meta object code when relating to the Meta Object Compiler (moc) in Qt?
Thanks.
Meta objects enhance programming languages by creating new or manipulate existing objects. They provide functionalities a language does not actually have by itself. The Meta Objects are interpreted either by compile time or run time. In Qt and C++ it is done during compile time by the Meta Object Compiler (moc).
An example case is the usage of the signal/slot concept.
Since you specifically asked about Meta object and moc,
From docs,
...The moc tool reads a C++ header file. If it finds one or more class declarations that contain the Q_OBJECT macro, it produces a C++ source file containing the meta-object code for those classes. ...
HTH..
Meta object code is required for Signal Slot mechanism ,Run time type information and dynamic property system.
Qt system creates "meta object code" based on "annotations" in your c++ code (eg Q_PROPERTY, Q_SLOTS etc). Qt uses them to implement meta-calls and reflection style access to class properties.
Look at the ".moc" files that the compiler produces for your class and you'll understand.
But given the uncertainty around Qt's future, may I ask why you are choosing Qt? (unless its purely for the joy of hacking..)

Q_OBJECT macro and meta-object code

This link: http://doc.trolltech.com/4.5/moc.html#moc says
The moc tool reads a C++ header file.
If it finds one or more class
declarations that contain the Q_OBJECT
macro, it produces a C++ source file
containing the meta-object code for
those classes.
What is a meta object code?
EDIT 1
How to know in which classes I should write the Q_OBJECT? One example is the signals and slots, any other cases where that needs to be used?
You can read the article Qt internals and Reversing to get in depth knowledge about Qt and its moc compiler (meta objet compiler). In summary a meta object is created by Qt's moc compiler to add extra information to a class like signal/slot mechanism etc.
Meta objects enhance programming languages by creating new or manipulate existing objects. They provide functionalities a language does not actually have by itself. The Meta Objects are interpreted either by compile time or run time. In Qt and C++ it is done during compile time by the Meta Object Compiler (moc).
An example case is the usage of the signal/slot concept.
A meta object code in Qt environment is a C++ source file that is an expanded version of the C++ source file where you've put Q_OBJECT (and/or other related macros). The meta object code will have your implementation plus some other extra (meta) code so that signal and slots mechanism work.
A meta-object contains meta-information about an object like its name and a textual description of its signals and slots. This make it possible to call signal by "name". See the documentation about QMetaObject and this article.

Resources