element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
FPGA
  • Technologies
  • More
FPGA
Forum How to solve red lines in modelsim when timing simulation with VHDL?
  • Blog
  • Forum
  • Documents
  • Quiz
  • Events
  • Polls
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join FPGA to participate - click to join for free!
Actions
  • Share
  • More
  • Cancel
Forum Thread Details
  • State Suggested Answer
  • Replies 10 replies
  • Answers 2 answers
  • Subscribers 535 subscribers
  • Views 9619 views
  • Users 0 members are here
  • timing simulation
  • testbench
  • vhdl
  • modelsim
  • combination circuits
Related

How to solve red lines in modelsim when timing simulation with VHDL?

blueapple
blueapple over 5 years ago

Hello,

I am learning VHDL now and meet a problem.When I use modelsim to do timing simulation,it always gives out red lines(X,mean unknow status)  and when I add internal signals that will be observed to wave windows ,the output show uninitialized .Is anybody can help me solve this problem? HERE are my some extral questions:

 

1.How to initialize the signals or ports in the testbench?

2.As for the red lins,what occurs that expect from uninitialization?

3.Does it necessary to set clock signals and reset signals in the testbench in combination circuit design?

 

Thank you!

  • Sign in to reply
  • Cancel

Top Replies

  • michaelkellett
    michaelkellett over 5 years ago in reply to blueapple +3 suggested
    First point - you are using use ieee.std_logic_arith.all; use ieee.std_logic_unsigned.all; Don't !!! Use IEEE.NUMERIC_STD.all; Look it up on the web to find out why. Because you are using a generally deprecated…
  • shabaz
    shabaz over 5 years ago +1 suggested
    Hi Albert, It's been 10 years since I've used it, so I'm only going off memory. You need to initialize all input signals - I cannot recall if that's only from a file, or if you can optionally also do it…
  • shabaz
    0 shabaz over 5 years ago

    Hi Albert,

     

    It's been 10 years since I've used it, so I'm only going off memory.

    You need to initialize all input signals - I cannot recall if that's only from a file, or if you can optionally also do it from the graphical interface. If you do not have clock or reset signals then you cannot set them of course. However, regardless of design (combinational or clocked) you need to have some starting value for the inputs. If you're still stuck, you might want to consult the documentation. If that doesn't help, consult old Xilinx ISE documentation, because I think they used a cut-down version of Modelsim.

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • Verify Answer
    • Reject Answer
    • Cancel
  • blueapple
    0 blueapple over 5 years ago in reply to shabaz

    Thaks for your answer,I think I have already initialize all input signlas when defining input/output signals.But it gives out 'U',and red lines in the middle of timing simulation,actually,the delay seems abnormal(about more than 10ns),as shown in the figure blow:

    image

     

    AND is it convenient for you to help me check the files attached at your spare time,or anybody else?

    Anyway,thanks you very much!

     

    --Here is the design block:8-bit phase multiplier
    library ieee;
    use ieee.std_logic_1164.all;
    use ieee.std_logic_arith.all;
    use ieee.std_logic_unsigned.all;
    
    entity mult_nbits is
          generic(n:integer:=8);
          port(multiplicand,multiplier:in std_logic_vector(n downto 1);
                multiplication:out std_logic_vector(2*n downto 1));
    end mult_nbits;
    
    architecture  behave of mult_nbits is
    signal sig:std_logic_vector(2*n downto 1);
    begin
         sig<=conv_std_logic_vector(0,n) & multiplicand;
          process(sig,multiplier)
          variable var:std_logic_vector(2*n downto 1);
          begin
                var := (others => '0');
                for i in 1 to n loop
                     if (multiplier(i) = '1') then
                          var:=var+to_stdlogicvector(to_bitvector(sig) sll (i-1));
                     end if;
                end loop;
                multiplication<=var;
          end process;
    end behave;

     

    Then it's testbench(maybe the cause of red lines problems)

     

    LIBRARY ieee;                                               
    USE ieee.std_logic_1164.all;
                                    
    ENTITY mult_nbits_vhd_tst IS
    END mult_nbits_vhd_tst;
    
    ARCHITECTURE mult_nbits_arch OF mult_nbits_vhd_tst IS 
    SIGNAL multiplicand : STD_LOGIC_VECTOR(8 DOWNTO 1):=x"00";
    SIGNAL multiplication : STD_LOGIC_VECTOR(16 DOWNTO 1):=x"0000";
    SIGNAL multiplier : STD_LOGIC_VECTOR(8 DOWNTO 1):=x"00";
    COMPONENT mult_nbits
          PORT (
                multiplicand : IN STD_LOGIC_VECTOR(8 DOWNTO 1);
                multiplication : BUFFER STD_LOGIC_VECTOR(16 DOWNTO 1);
                multiplier : IN STD_LOGIC_VECTOR(8 DOWNTO 1)
                );
    END COMPONENT;
    
    BEGIN
          i1 : mult_nbits
          PORT MAP (
                     multiplicand => multiplicand,     
                     multiplication => multiplication,     
                     multiplier => multiplier     
                     );
         
    init : PROCESS                                                                                 
    BEGIN
          wait for 50 ns;
    
          multiplier<="00001111";
          multiplicand<="00001111";
          assert(multiplication/="0000000011100000")
          report "error"
          severity error;
          wait for 50 ns;
    
          multiplier<="11111111";
          multiplicand<="11111111";
          assert(multiplication/="1111111000000001")
          report "error"
          severity error;
          wait for 50 ns;
    
          multiplier<="10101010";
          multiplicand<="01010101";  
          assert(multiplication/="0011100001110010")
          report "error"
          severity error;
                                                          
    WAIT;                                                       
    END PROCESS;
    END mult_nbits_arch;

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • michaelkellett
    0 michaelkellett over 5 years ago in reply to blueapple

    First point - you are using

    1. use ieee.std_logic_arith.all; 
    2. use ieee.std_logic_unsigned.all; 

     

    Don't !!!

    Use IEEE.NUMERIC_STD.all;

     

    Look it up on the web to find out why.

     

    Because you are using a generally deprecated non standard library it's even harder for me to understand you code than otherwise.

     

    The simulator looks as if its going through your process many times with an assumed 1ns delay and the first time something is unitialised- I don't think that's what you want. It may be a quirk of the simulator - for loops can make cascades of logic and the simulator will process them in order.

     

    Your code is very hard to read, like really really hard !

     

    Spaces are free: so put spaces between things write a <= b rather than a<=b

    Use indentation, it helps with understanding.

    And use comments !

    I have never (as far as I can remember) looked at code I wrote a few years ago and thought "Pity I wasted time on all these comments", but I have often thought some comments made at the time would have saved me hours later !

     

    Finally - I can't work out what the for loop is doing and I'm not sure that the simulator can: (some comments would help me, they won't bother the simulator).

     

    what is varvar (line 21) and why are some things red, some blue and some black ?

     

    Try showing some more data (like var) in the simulation plot.

     

    MK

    • Cancel
    • Vote Up +3 Vote Down
    • Sign in to reply
    • Verify Answer
    • Reject Answer
    • Cancel
  • blueapple
    0 blueapple over 5 years ago in reply to michaelkellett

    Thanks for your kindness ! It's very useful for me . I have learned a lot from your answer .

     

     

    As for the problems in the code :

     

    1 . It's an error in line 21 , the varvar should be var .

    2 .There maybe something wrong with the website , I can't re-edit the line 21 , "varvar" seems can't be corrected .

     

    Anyway , I would correct the style of coding , use indentation and comments .

     

     

    Rion

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • wolfgangfriedrich
    0 wolfgangfriedrich over 5 years ago in reply to blueapple

    God information, but you missed the most important point from Micheal's post.

    More data is required to get closer to a solution.

    Please re-run the simulation and show 'var' in the timing plot. Asll single bits of the signals would be helpful too, not just the 16-bit signal vector.

    Also, please zoom in, where 'multiplication' changes from green to red at ~4 ns.

     

    Thanks.

    - W.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • blueapple
    0 blueapple over 5 years ago in reply to wolfgangfriedrich

    imageimage

    To be honest , I have almost quit the design . It's really annoying . I can't find where to upload the files in this website(maybe it's more convenient) .

     

    Whether sloved or not , thank you very much !

     

    Rion

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • michaelkellett
    0 michaelkellett over 5 years ago in reply to blueapple

    I poked your code into my simulator (Aldec HDL) and once I'd fixed varvar it  compiled OK.

    Same basic results as Modelsim, but none of the funny business when the data changes.

     

    image

     

    My test bench is basically yours but with the Aldec generated wrapper:

     

    library ieee;
    use ieee.STD_LOGIC_UNSIGNED.all;
    use ieee.std_logic_1164.all;
    use ieee.std_logic_arith.all;
    
        -- Add your library and packages declaration here ...
    
    entity mult_nbits_tb is
        -- Generic declarations of the tested unit
            generic(
            n : INTEGER := 8 );
    end mult_nbits_tb;
    
    architecture TB_ARCHITECTURE of mult_nbits_tb is
        -- Component declaration of the tested unit
        component mult_nbits
            generic(
            n : INTEGER := 8 );
        port(
            multiplicand : in STD_LOGIC_VECTOR(n downto 1);
            multiplier : in STD_LOGIC_VECTOR(n downto 1);
            multiplication : out STD_LOGIC_VECTOR(2*n downto 1) );
        end component;
    
        -- Stimulus signals - signals mapped to the input and inout ports of tested entity
        signal multiplicand : STD_LOGIC_VECTOR(n downto 1);
        signal multiplier : STD_LOGIC_VECTOR(n downto 1);
        -- Observed signals - signals mapped to the output ports of tested entity
        signal multiplication : STD_LOGIC_VECTOR(2*n downto 1);
    
        -- Add your code here ...
    
    begin
    
        -- Unit Under Test port map
        UUT : mult_nbits
            generic map (
                n => n
            )
    
            port map (
                multiplicand => multiplicand,
                multiplier => multiplier,
                multiplication => multiplication
            );
    
        -- Add your stimulus here ...  
    init : PROCESS                                                                                   
    BEGIN  
    
    wait for 50 ns;  
    
    multiplier<="00001111";  
    multiplicand<="00001111";  
    assert(multiplication/="0000000011100000")  
    report "error"  
    severity error;  
    wait for 50 ns;  
    
    multiplier<="11111111";  
    multiplicand<="11111111";  
    assert(multiplication/="1111111000000001")  
    report "error"  
    severity error;  
    wait for 50 ns;  
    
    multiplier<="10101010";  
    multiplicand<="01010101";    
    assert(multiplication/="0011100001110010")  
    report "error"  
    severity error;  
                                                        
    WAIT;                                                         
    END PROCESS;  
    
    end TB_ARCHITECTURE;
    
    configuration TESTBENCH_FOR_mult_nbits of mult_nbits_tb is
        for TB_ARCHITECTURE
            for UUT : mult_nbits
                use entity work.mult_nbits(behave);
            end for;
        end for;
    end TESTBENCH_FOR_mult_nbits;

     

       library ieee;  
        use ieee.std_logic_1164.all;  
        use ieee.std_logic_arith.all;  
        use ieee.std_logic_unsigned.all;  
    
    
    entity mult_nbits is  
          generic(n:integer:=8);  
          port(multiplicand,multiplier:in std_logic_vector(n downto 1);  
                multiplication:out std_logic_vector(2*n downto 1));  
    end mult_nbits;  
    
    --}} End of automatically maintained section
    
    
          
          
    architecture  behave of mult_nbits is  
    signal sig:std_logic_vector(2*n downto 1);  
    begin  
         sig<=conv_std_logic_vector(0,n) & multiplicand;  
          process(sig,multiplier)  
          variable var:std_logic_vector(2*n downto 1);  
          begin  
                var := (others => '0');  
                for i in 1 to n loop  
                     if (multiplier(i) = '1') then  
                          var:=var+to_stdlogicvector(to_bitvector(sig) sll (i-1));  
                     end if;  
                end loop;  
                multiplication<=var;  
          end process;  
    end behave; 

     

    Not sure if this helps you much.

     

    MK

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • wolfgangfriedrich
    0 wolfgangfriedrich over 5 years ago in reply to blueapple

    Hello Rion,

    Don't give up and thanks for sending the detailed timings.

    It seems that the variables var and sig are missing the initial values and are undifined, which is represented by the red lines. They are only updated at the 1st wait statement.

    Try in the architecture for mult_nbits:

     

    signal sig:std_logic_vector(2*n downto 1) := (others => '0'); 

     

    variable var:std_logic_vector(2*n downto 1) := (others => '0'); 

     

    Micheal,

    your result looks quasi identical, the simulator behaviour seems to be different, processing all combinational logic statements are processed at once without a minimal time step.

     

    Good luck,

    - Wolfgang.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • michaelkellett
    0 michaelkellett over 5 years ago in reply to wolfgangfriedrich

    wolfgangfriedrich  wrote:

     

    your result looks quasi identical, the simulator behaviour seems to be different, processing all combinational logic statements are processed at once without a minimal time step.

     

    I've never used ModelSim much but I thought that the whole idea of a 'for' loop in VHDL is that the content within it was combinatorial and processed simultaneously - I'll have to check now if such behavior is optional or an Aldec interpretation.

     

    MK

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • wolfgangfriedrich
    0 wolfgangfriedrich over 5 years ago in reply to michaelkellett

    michaelkellett, yes the for loop generates multiple combinatorial statements in parallel. This must be behavioural differences in the simulator architecture. I would guess again that Modelsim might have a setting with a minimal time step even between instructions, exploding the simulation time when set to a very small value, from the plot is seems to be ~100psec.

    Reults are the same, so reality wins again.image

    - W. 

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube