Binary Decoder Model

Parent Previous Next

VisualSim                                                                                                                               

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.

  1. Drag the Verilog_Cosim from Full Library > Hardware_Language > Verilog blocks to the editor space.

BinaryDecoder Model

Figure 1. BinaryDecoder Model

  1. Right click on the actor and select Configure Arguments. Configure the parameter values as shown in the figure. The parameters are as follows:

For example, ”BinaryDecoder”.


Decoder.v file should be same as user Verilog Module name.

For example, “D:/VisualSim/VS/demo/interfacesVerilog/BinaryDecoder/Decoder.v”.

 

Configuring the Verilog_Cosim

Figure 2. Configuring the Verilog_Cosim

  1. Configure the ports in the Verilog_Cosim Block:

Configure ports for Verilog_Cosim

Figure 3. Configure ports for Verilog_Cosim

  1. Now save the model before code generation.
  2. Click Interfaces > Generate Wrapper for code generation.
  3. Click Interfaces > Compiler Wrapper for code compilation of the source files.

Generate_Wrapper

Figure 4.  Menu Bar View to Select Generator

  1. 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.
  2. 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.

  1. The blocks directory has been provided under Verilog directory to hold “. Dll” files, which will be in PATH.
  2. 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.
  3. Connect all the blocks as shown in the Figure 5.
  4. Add a Digital simulator (located under ModelSetup). Double click and change the number of iterations from 0 to 1.
  5. 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.

 

BinaryDecoder Model

Figure 5. BinaryDecoder Model