VHDL coding tips and tricks: modelsim
Showing posts with label modelsim. Show all posts
Showing posts with label modelsim. Show all posts

Sunday, November 22, 2020

Simulating a VHDL/Verilog code using Modelsim SE

    This is a simple How-To video for ModelSim SE 10.4a version. If you are already familiar with this software tool then you may not need to watch this video.


In this video, I am trying to show you:
  1. How to create a new project in ModelSim SE.
  2. Add VHDL codes to this project.
  3. Compile and simulate the codes.
  4. Few tips on the simulation part of the tool.





Wednesday, October 18, 2017

How to use ieee_proposed libraries in Modelsim?

You might have come across the ieee_proposed fixed and floating point packages, if you were looking for ways to deal with fractional numbers in VHDL. These libraries are amazing. But they are not so widely supported by simulation and synthesis tools like other ieee libraries.

Many tools use their own version of these libraries.

Lets see what I meant. See the below code, using the floating point operations + and *.

LIBRARY ieee;
library ieee_proposed;
use ieee_proposed.float_pkg.all;
 
ENTITY temp IS
port( a,b : in float(3 downto -4);
    c,d : out float(3 downto -4)
    );  
END temp;
 
ARCHITECTURE behavior OF temp IS 
 
BEGIN

<= a+b;
<= a*b;

END;

Upon compilation in Modelsim 10.4a, we would get the following errors,

** Error: D:/MODELSIM/temp.vhd(2): Library ieee_proposed not found.
** Error: D:/MODELSIM/temp.vhd(3): (vcom-1136) Unknown identifier "ieee_proposed".
** Error: D:/MODELSIM/temp.vhd(5): VHDL Compiler exiting

This error can be easily removed by just changing the name of the library. As I said, some tools, use their own version of ieee_proposed. Modelsim names it floatfixlib.

See the new code, which compiles fine, without any errors.

LIBRARY ieee;
Library floatfixlib; 
use floatfixlib.float_pkg.all;
 
ENTITY temp IS
port( a,b : in float(3 downto -4);
    c,d : out float(3 downto -4)
    );  
END temp;
 
ARCHITECTURE behavior OF temp IS 
 
BEGIN

<= a+b;
<= a*b;

END;

The code simply adds and multiplies two floating point numbers. Without this package, somebody would have had to implement the whole floating point operation from scratch.

It goes without saying that for using fixed point library, I just have to include the following line in the code,

use floatfixlib.fixed_pkg.all;

I have used Modelsim version 10.4a for this particular post.