BinaryDecoder Model
A 3-to-8 decoder consists of
three inputs and eight outputs. Only one output is active at any
point of time, corresponding to the input value. Other outputs are
deactivated.
- Drag the Verilog_Cosim from Full Library > Hardware_Language > Verilog blocks to the editor space.
Figure 1. BinaryDecoder Model
- Right click on the actor and select Configure Arguments. Configure the parameter values as shown in the figure. The parameters are as follows:
- The Verilog_Module_Name is the model name in Verilog.
For example, ”BinaryDecoder”.
- The Verilog_Module_Path is the path to the Verilog source files (*.v).
Decoder.v file should be same as user Verilog Module name.
For example, “D:/VisualSim/VS/demo/interfacesVerilog/BinaryDecoder/Decoder.v”.
Figure 2. Configuring the Verilog_Cosim
- Configure the ports in the Verilog_Cosim Block:
- Select the context menu of the Verilog_Cosim and select Customize > Ports.
- Configure the input/output ports, type of the ports, and Verilog Data types in the Remote type Column.
Figure 3. Configure ports for Verilog_Cosim
- Now save the model before code generation.
- Click Interfaces > Generate Wrapper for code generation.
- Click Interfaces > Compiler Wrapper for code compilation of the source files.
Figure 4. Menu Bar View to Select Generator
- A new folder named
“BinaryDecoder” is automatically created under Verilog directory,
if it does not exist already. Otherwise, it overwrites the existing
generated files with the new files.
- Successful
compilation of the sources files creates a
Jni<Verilog_Module_Name> .dll/.so file under the blocks directory.
The file extension “. Dll or .so” indicates that the file is a link
library.
Note:
Open the “vsout.txt” file under the library Directory to verify the
errors that could have caused any unsuccessful compilation process.
These could help to correct any mistakes in the interface code.
- The blocks directory has been provided under Verilog directory to hold “. Dll” files, which will be in PATH.
- Drag the
Text_Display(Non-buffered) block from the Result > Text. Similarly,
the “Const” input block from the Full Library > Math
Operations > Math and Trig. Control-click to create the relations
from the toolbar.
- Connect all the blocks as shown in the Figure 5.
- Add a Digital simulator (located under ModelSetup). Double click and change the number of iterations from 0 to 1.
- To run
BinaryDecoder model, click the run button in the IDE or press Ctrl+R.
The expected result look similar to the one shown on the Figure as
below.
Figure 5. BinaryDecoder Model