- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello everyone,
Very often I have to observe the output of my filters on ModelSim and compare its performance with specifications like peak sidelobe levels, integrated sidelobe levels etc. It is rather easy to observe some of those specifications if the output is plotted on log scale (20log10 or 10log10 etc.). Is there an easy tweak to do so in ModelSim? I have seen over web that users have done this in ModelSim and their ModelSim log plots were exactly the same as one can see in softwares like MATLAB. Any help would be greatly appreciated. Thanks.Link Copied
3 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
i was going to suggest writing the output to a .txt and reading with MATLAB/Octave, sounds like that's not going to cut it.
in your test bench you could 20*log10() your output with the HDL's math functions and display the result. which language?- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello all,
After a little bit of digging, I could plot the signals on log scale in the wave window, thanks to some new HDL packages and libraries that come installed with the latest ModelSim versions. For the sake of benefit for other users, here is the code to get the values in log scale: (I have assumed that my signal is complex (= I+jQ = S) in a fixed point format s24:16)
-- Following packages required in addition to the existing ones
LIBRARY IEEE;
USE IEEE.MATH_REAL.ALL;
USE IEEE.MATH_COMPLEX.ALL;
LIBRARY FLOATFIXLIB;
USE FLOATFIXLIB.FIXED_PKG.ALL;
-- Entity declaration
...
-- Architecture definition
...
-- Component instantiations
...
-- Signal and attribute declarations
...
SIGNAL I_std, Q_std : std_logic_vector (23 downto 0);
SIGNAL I_real, Q_real : real;
SIGNAL S_cmplx : complex;
SIGNAL S_abs_real, S_log_real : real;
BEGIN
-- Rest of the code
I_real <= to_real(to_SFix(I_std, 24, 18));
Q_real <= to_real(to_SFix(Q_std, 24, 18));
S_cmplx <= CMPLX(I_real, Q_real);
S_abs_real <= ABS(S_cmplx);
S_log_real <= 10.0*(log10(S_abs_real)); -- Plot S_log_real in the wave window
-- End of architecture
You may also be required to check the overflow of real values depending on the signal range. Hope it helps.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
cool, i'll have to try that out
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page