Multiplexer Model

Parent Previous Next

VisualSim                                                                                                                               

Multiplexer Model

The following section explains the creation of Multiplexer Verilog model in VisualSim. A Model is 2:1 Multiplexer to implement using Gate level. It is constructed using two And-gate, one Not-gate, and one Or-gate. The Output equation is Q=A.S'+B.S.

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

 

Multiplexer??model

Figure 1. Multiplexer 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:

Configuring for Andgate Block

For example,  ”AndGate”.

For example,  “D:/VisualSim/VS930/demo/interfaces/Verilog/AndGate/andgate.v”.

Here the “*.v” file name should be same as the Verilog module name in the user

Verilog code.

Parameter for AndGate

Figure 2. Configuring the parameters for Verilog_Cosim

Configuration for Orgate Block

For example, ”OrGate”.

For example, “D:/VisualSim/VS930/demo/Interfaces/Verilog/OrGate/orgate.v”.

Here the “*.v” file name should be same as the Verilog module name in the user Verilog code.

Configuring??ports for OrGate

Figure 3. Configure ports for OrGateWin

Configuration for Notgate Block

  1. The Verilog_Module_Name is the model name in Verilog.

For example,  ”NotGate”.

  1. The Verilog_Module_Path is the path to the Verilog source files (*.v).

For example, “D:/VisualSim/VS930/demo/Interfaces/Verilog/NotGate/notgate.v”.

Here the “*.v” file name should be same as the Verilog module name in the user Verilog code.

 

Parameters for??NotGateWin

Figure 4. Configuring the parameters for NotGateWin

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

 

Wrapper

Figure 5. Menu Bar View to Select Generator

  1. Configure the ports in the Verilog_Cosim Block:

Configure ports for the AndGate

Figure 6. Configure ports for the AndGate

Configure ports for the NotGate

Figure 7. Configure ports for the NotGate

  1. A new folder named “AndGate”, ”OrGate”, and “MuxGate” 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 source files creates Jni<Verilog_Module_Name> .dll file under the blocks directory. The file extension “. Dll” indicates that the file is a dynamic link library (dll).

Note: Open the “vsout.txt” file under the libraryDirectory 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 UserNativeC directory to hold “. Dll” files, which are in the PATH.
  2. Drag the Text_Display (Non-buffered) from the Result - Text. Similarly, the “Const” input block from the Math Operations > Math and Trig. Control-click to create the relations from the toolbar.
  3. Connect all the blocks as shown in the Figure 8.
  4. Add a Digital simulator (located under Model > Simulator). Double click and change the number of iterations from 0 to 1.
  5. To run multiplexer model, click the run button in the IDE or Press Ctrl+R.

 

Multiplexer_Model

Figure 8. Multiplexer Model