Visualization of design-related features such as datapaths, control sequencing, input and output patterns, module and system performance indexes, etc. is a very effective way of communicating structural, sequential and algorithmic details, especially when it is part of an executable specification. Since the CvSDL simulator and models can be embedded into any C++ applications (subject to compilers supported), you can use any C++ GUI RAD tool to develop your own visualization packages.
You can also take advantage of our free resources to make the building of GUI-based C++/CvSDL applications a simple process. One such resource is a pre-built GUI-based DLL that lets you control the CvSDL simulator and display signal waveforms. Another is a static library that encapsulates multi-thread functionality and the interface that connects the DLL with the CvSDL simulator. The DLX RISC CPU demo, available from our download page, uses these resources. They are available for Borland C++Builder currently.
Download the following files if you have not done so:
cvsdl_gui.dll - a pre-built GUI similar to winvcd.exe. You can use this DLL to control the CvSDL simulator and display signal waveforms. All messages from the simulator are automatically displayed on the DLL console window. You do not need to do anything special in your Verilog code to display all signals including arrays on the DLL waveform window.
cv_types.h, cvsdl_bcb6.lib and cvsdl_bcb6.dll - cvsdl type header, and link and runtime libraries, respectively.
cvgui_bcb6.lib and cvgui_bcb6.h - a static library and its header. The header defines a struct TCvSdlThread that encapsulate multi-threading, callback synchronization and the binding of cvsdl_gui.dll with the CvSDL simulator. TCvSdlThread contains the pointer to the CvSDL simulator, TCvSdl* TCvSdlThread::sim that is used to set up simulator-related features.
You need to instantiate a CvSDL simulator at the start of your application and delete it at the end.
Call CreateGuiCvSim, declared in cvgui_bcb6.h, with the first parameter specifying the location of cvsdl_gui.dll. Leave the second parameter as is. This can be done for example in the constructor of the main form in your application.
TCvSdlThread*
cvsdl; // declare the pointer, e.g. in the main form
definition.
cvsdl =CreateGuiCvSim(“..\\..\\lib\\cvsdl_gui.dll”);
// e.g. in the main form constructor
If the DLL is not found, cvsdl will be 0 (null) and the application should terminate.
Before the application is normally exited, you need to call DeleteGuiCvSim(), declared in cvgui_bcb6.h, to delete the CvSDL simualtor. This can be done for example in the destructor of the main form.
DeleteGuiCvSim();
Once a TCvSdlThread object is created, use the simulator pointer, TCvSdlThread::sim, to set up, e.g. in the main form constructor, the timescale if different from the default (1s/1s), register top-level modules, specify the command-line argument (for Verilog), etc. If hdl2cvsdl has generated cv_defparams.cpp, you need to register it before registering any other top-level modules.
#include
“cv_defparams.h” // optional
#include “top.h”
...
cvsdl->sim->TimeScale(“ 1ns/
10ps”);
cvsdl->sim->CV_COMPONENT(cv_defparams(\"cv_defparams\"));
// optional
cvsdl->sim->CV_COMPONENT(cvm_top(“top”));
If you want to provide your custom visualization on your design and simulation results, you can use callbacks. Callbacks are functions that you provide, which the CvSDL simulator calls when certain events occur. Typically what you may do inside a callback, when it receives, for example, a simulator-halted state, is to update your GUI per the latest simulation result.
TCvSdlThread provides one callback mechanism that should be adequate for many applications. The callback-trigger events are the halting and starting of the CvSDL simulator with one of the states, CV_SIM_RESET, CV_SIM_RUNNING , CV_SIM_STOPPED, CV_SIM_FINISHED, CV_SIM_NODESIGN, and CV_SIM_ERROR, all defined in cv_types.h. TCvSdlThread provides a thread synchronization for these callbacks.
Before you register a callback you need to declare or define it. It is a global function and takes one unsigned int parameter, which the simulator uses to pass its state. For example,
void SdlSimStatus(unsigned n);
Then you need to call TCvSdlThread::RegisterStatus() to register the name of the callback function,
cvsdl->RegisterStatus(SdlSimStatus);
At the end, you need to call TCvSdlThread::Init() to initialize the GUI DLL in terms of the design registered,
cvsdl->Init();
Here are some excerpts from the DLX CPU demo source code.
|
TFormDLX.h |
|---|
#include "cvgui_bcb6.h"
class TFormDLX : public TForm
{
...
TCvSdlThread *cvsdl;
void SimStatus(unsigned);
...
};
extern PACKAGE TFormDLX *FormDLX;
|
|
TFormDLX.cpp |
|---|
__fastcall TFormDLX::TFormDLX(TComponent* Owner) : TForm(Owner)
{
try
{
if ((cvsdl=CreateGuiCvSim("..\\..\\lib\\cvsdl_gui.dll"))==0)
{
ShowMessage("failed to start CvSDL simulator");
Application->Terminate();
}
else
{
cvsdl->RegisterStatus(SdlSimStatus);
cvsdl->sim->CV_COMPONENT(cvm_test_dlx("test_bench"));
cvsdl->Init();
...
}
}
catch(...)
{
Application->Terminate();
}
...
}
__fastcall TFormDLX::~TFormDLX()
{
DeleteGuiCvSim();
...
}
void SdlSimStatus(unsigned n) {FormDLX->SimStatus(n);}
void TFormDLX::SimStatus(unsigned status)
{
if (status&(CV_SIM_NODESIGN|CV_SIM_RUNNING))
{
...
}
else
if (status&(CV_SIM_READY|CV_SIM_STOPPED|CV_SIM_RESET))
{
...
}
else
{
}
}
|
Trademarks
and registered trademarks are property of the respective
owners.
CvSDL is a trademark of Tenko Technologies Inc.
Copyright
© 2005 Tenko Technologies Inc. All rights reserved. Last
modified on