0% found this document useful (0 votes)
15 views6 pages

ModCoupler User Guide for Co-Simulation

Uploaded by

maslahi1998
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views6 pages

ModCoupler User Guide for Co-Simulation

Uploaded by

maslahi1998
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

ModCoupler

User’s Guide

Powersim Inc.
ModCoupler User’s Guide
Version 1.0

Release 1.0

May 2011

Copyright © 2011 Carlos III University of Madrid, GSEP Power Electronics Systems Group, and
Microelectronic Design and Applications group, Spain.
All rights reserved. No part of this manual may be photocopied or reproduced in any form or by any
means without the written permission of Powersim and the Carlos III University of Madrid.

Disclaimer
Powersim Inc. (“Powersim”) and the Carlos III University of Madrid make no representation or warranty
with respect to the adequacy or accuracy of this documentation or the software which it describes. In no
event will Powersim and the Carlos III University of Madrid or its direct or indirect suppliers be liable for
any damages whatsoever including, but not limited to, direct, indirect, incidental, or consequential
damages of any character including, without limitation, loss of business profits, data, business
information, or any and all other commercial damages or losses, or for any damages in excess of the list
price for the license to the software and documentation.

Powersim Inc.
email: info@[Link]
[Link]
1 Introduction
ModCoupler is a communication link between the simulation software ModelSim® and
PSIM®. By means of ModCoupler, the co-simulation of the completed power electronics
equipment can be performed. The digital control algorithm, described in VHDL, will be
simulated in Modelsim and the power stage will be simulated in PSIM.
On PSIM® side, the user must include the ModCoupler block in his schematic. On ModelSim®
side there, no changes are needed. From PSIM´s schematic, the user will provide information to
ModCoupler module, time-step, VHDL clk signal frequency and input – output signals
information, required to configure the co-simulation. Fig. 1 shows the basic co-simulation
structure.

Mod
User’s power stage Communication link User’s digital control
(PSIM schematic) (PSIM module) circuit (VHDL)

Time step control


Sensors
Control
Clock generation
algorithms
Gate signals
Input/output management

Fig. 1: Co-simulation architecture.


At every simulation instant both simulators are stopped. The values of the input signals of the
ModCoupler module are forwarded to the digital circuit, which is in charge of the control
algorithms. Once the Modelsim´s calculations have finished, the value of the VHDL outputs are
sent back to close the loop. After that, each simulator runs a new simulation step and the cycle
is repeated. Note that one PSIM® simulation step correspond to several ModelSim® simulation
steps.
This guide describes how to build a co-simulation environment from scratch. It is assumed that
the user provides a PSIM® schematic for the analog simulation and a VHDL description for the
digital simulation.
2 ModCoupler block configuration
In your PSIM® schematic file (create a new one if it is needed) add a ModCoupler block
(placed on the Control submenu of the Elements menu) as show in Fig. 2.

Fig. 2: ModCoupler module menu.

In Fig. 3 the main dialogue window of the ModCoupler module is shown.

Fig. 3: ModCoupler module dialogue window.


The different parameters are explained below:
‐ VHDL file:The .vhd top entity file. After this file is selected, the IN/OUT nodes lists
will be created.
‐ Wave file: The file with the signals to to be diplayed in ModelSim® waveform window.
‐ ModelSim Time Step: The ModelSim® simulation time step. This value must be smaller
than the PSIM® time step of the Simulation Control
‐ Clk signal frequency: The frequency of the ModelSim® clk signal. Notice that the clk
signal is not processed as an input, since the period is usually smaller than the PSIM®
time step.
‐ ModelSim Run All (Yes/No): Allows starts the ModelSim® simulation without pressing
the “Run –All” button. It is recommended to set that parameter to “No” the first time
the simulation is run in order to select the signals to be displayed in ModelSim®
waveform window.
‐ Split input buses (Yes/No): Allows splitting an input std_logic_vector signal in its
different bits.
‐ Split output buses (Yes/No): Allows splitting an output std_logic_vector signal in its
different bits.

3 Compatible data types


ModCoupler handles the following type of signals:

3.1 Bit
When used as input signal, ModCoupler will set the corresponding ModelSim® signal to logic
‘0’ when reads a value of 0, otherwise the signal will be set to logic ‘1’.
When used as output signal, ModCoupler will set the corresponding PSIM® output node to 0
when reads a logic value of ‘0’, otherwise the node will be set to 1.

3.2 Std_logic
With the std_logic type only two states are taken into account, the logic ‘0’ and the logic ‘1’.
When used as input signal, ModCoupler will set the corresponding ModelSim® signal to logic
‘0’ when reads a value of 0, otherwise the signal will be set to logic ‘1’.
When used as output signal, ModCoupler will set the corresponding PSIM® output node to 0
when reads a logic value of ‘0’, otherwise the node will be set to 1.

3.3 Real
With this kind of signal, the PSIM® values are directly sent to ModelSim® and vice versa.

3.4 Integer
When used as input signal, ModCoupler will round the PSIM® input node value truncating the
decimal part and after that will set the corresponding ModelSim® signal to the rounded value.

3.5 Bit_vector and Std_logic_vector


In these both cases there are two different modes of operation:
When the Split input buses parameter is set to “No”, the bit vector will be treated in the PSIM®
side as an integer and ModCoupler will set the first element of the array as the least significant
bit (LSB) of the integer value, the second as the second LSB, etc.
When the Split input buses parameter is set to “Yes” an input node is created in PSIM® for each
of the signal bits.

4 Compilation of VHDL files


ModCoupler needs a compiled model of the VHDL design in order to operate. Also, the “work”
ModelSim® library must be located in the working directory (it can be done easily moving the
work folder to the directory that contains the schematic file).
The proposed compilation method uses a Windows® batch file, although this process should be
performed by the ModCoupler dialog. A batch file includes commands to be executed. Example
batch files ([Link]) can be found in the different examples directories. ModelSim®
applications vcom and vlib are used, so the path to both of them must be in the environment
variable PATH.
NOTE: If any change is made on any VHDL file, the model must be recompiled.

5 Simulation
The last step is running the simulation. Set the configuration ModelSim Run All parameter to
“No” the first time the simulation is run, so ModelSim® opens without actually running the
simulation. In this state, the user can select the appropriate signals to display and save them to
the wave file ([Link] by defect).
Start the simulation pressing the PSIM® “Run simulation engine” button. After a few seconds, a
ModelSim® window will appear. Once the user has selected the signals to view, the simulation
is started by pressing the “Run –All” button in ModelSim®.
In next simulations, the ModelSim Run All parameter can be set to “Yes” to start ModelSim®
and run the simulation automatically.
If a new simulation with the same VHDL model is needed (for example, after editing a VHDL
file and recompiling or after a schematic change), press the ModelSim® “Restart” button before
pressing the PSIM® “Run simulation engine” button again (closing ModelSim® window is not
required).

Common questions

Powered by AI

Setting the 'ModelSim Run All' parameter to 'No' during the initial setup prevents the automatic execution of the simulation in ModelSim. This allows users to open ModelSim, select the signals they wish to display in the waveform window, and save these choices before starting the simulation. This step is crucial for tailoring the simulation outputs and optimizing the process before automating it by setting the parameter to 'Yes' in subsequent runs .

Recompiling the VHDL model is essential whenever modifications are made to VHDL files to ensure that the simulation runs accurately with the updated digital model. It is achieved by placing the 'work' library in the working directory and using a Windows batch file to execute compilation commands utilizing ModelSim tools such as vcom and vlib. This ensures synchronization between the updated VHDL model and the rest of the simulation setup in ModCoupler .

ModCoupler can handle several data types: bit, std_logic, real, integer, bit_vector, and std_logic_vector. For bit and std_logic types, logic '0' and '1' states are used; values are mapped directly to ModelSim and PSIM nodes. Real type signals are sent directly between PSIM and ModelSim. For integers, decimal parts are truncated before communication. Bit_vector and std_logic_vector signals can either be treated as integers if the Split input buses parameter is 'No', or each bit can be mapped to a separate node in PSIM if the parameter is 'Yes' .

ModCoupler allows the splitting of input and output buses represented by std_logic_vector signals. When the 'Split input buses' or 'Split output buses' parameter is set to 'Yes', each bit of the std_logic_vector is mapped to a separate input or output node in PSIM. If set to 'No', the entire std_logic_vector is treated as an integer, with each bit in the vector corresponding to the respective bits of an integer where the first element represents the least significant bit .

ModCoupler acts as a communication link between ModelSim and PSIM, allowing the co-simulation of power electronics equipment by enabling the integration of a digital control algorithm simulated in ModelSim with a power stage simulated in PSIM. The ModCoupler block, added on the PSIM side, manages input-output signals, time-step control, and VHDL clock signal frequency, ensuring information is forwarded correctly to the digital circuit for calculations. Once ModelSim finishes its calculations, VHDL outputs are returned to close the loop for the next simulation step .

To start a new simulation with ModCoupler after modifying VHDL files or schematics, users must first recompile the updated VHDL model to reflect changes. Then, the 'ModelSim Run All' parameter should be set to 'No' to manually select and save the signals to display. The user should press the PSIM 'Run simulation engine' button to initialize the process, then configure the desired signals in ModelSim before commencing the simulation by pressing 'Run-All'. Before rerunning, ensure ModelSim's 'Restart' is executed rather than closing and reopening the entire software .

In setting up the ModCoupler environment, the PSIM schematic file serves as the foundation for the analog simulation. Users must add the ModCoupler block to their PSIM schematic to facilitate communication between ModelSim and PSIM, configure input-output management, time-step control, and VHDL clock generation. This schematic provides the necessary structural and signal information to ModCoupler to ensure effective co-simulation and synchronizes with digital signals simulated in ModelSim .

In ModCoupler co-simulation, the clock signal frequency impacts synchronization between the digital and analog sections, as it dictates the timing of VHDL simulations in ModelSim. The clk signal is not processed as an input because its period is typically smaller than the PSIM time step, meaning it governs the internal timing within ModelSim rather than dictating a communication signal. This setup minimizes the risk of misalignment between the simulations and optimizes time-step management .

Within a ModCoupler co-simulation environment, digital and analog components interact in a cycle where, at each simulation instant, both simulators are paused to allow for value exchange. Input signals are sent from the ModCoupler module to the digital circuit in ModelSim, where control algorithms are processed. Upon completing ModelSim calculations, resulting VHDL outputs return to the PSIM analog components, closing the loop. This cyclic interaction ensures that each simulation step corresponds correctly between the faster digital clock in ModelSim and the overall PSIM time step, maintaining alignment and coherence across both simulation domains .

The co-simulation architecture benefits from ModCoupler by facilitating precise and efficient signal management between analog simulations in PSIM and digital simulations in ModelSim. ModCoupler manages the synchronization of simulation time steps, enables effective transfer of input and output signals using compatible data types, and ensures that the digital control algorithms and analog components remain in sync throughout the simulation process. This integration enables users to simulate complex power electronics systems with a mixture of analogue and digital components accurately .

You might also like