Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

VHDL simulation problem

Status
Not open for further replies.

shaiko

Advanced Member level 5
Joined
Aug 20, 2011
Messages
2,644
Helped
303
Reputation
608
Reaction score
297
Trophy points
1,363
Activity points
18,300
The following happens in ModelSim :

Code:
signal noise : std_logic := '0' ;
signal stable_one : std_logic ;
signal x : std_logic ;

stable_one <= '1' ;
noise <= not noise after 100 ns ;
[COLOR="#FF0000"]x[/COLOR] <= noise , stable_one after 10 ms ;

I expected that signal 'x' will stabilize to a stable logic '1' after 10 ms. However, the waveform shows otherwise!
signal x continues to be driven by signal "noise" indefinitely...

Why is that ???
How shall I rewrite my code so it'll do what I expect it to...?
 

mrflibble

Advanced Member level 5
Joined
Apr 19, 2010
Messages
2,724
Helped
679
Reputation
1,360
Reaction score
651
Trophy points
1,393
Activity points
19,551
Now what did your mother teach you about including full testbench code and a screenshot of your waveform?
 

shaiko

Advanced Member level 5
Joined
Aug 20, 2011
Messages
2,644
Helped
303
Reputation
608
Reaction score
297
Trophy points
1,363
Activity points
18,300
Code:
library ieee ;
	use ieee.std_logic_1164.all ;
	use ieee.numeric_std.all ;
	use ieee.math_real.all ;

library work ;
	use work.package_functions.all ;
	
	
	
	
	
entity tb_debouncer is
generic
( 
    G :   unsigned ( 31 downto 0 ) := to_unsigned ( 50000000 , 32 )								             
) ;											
end entity tb_debouncer ;





architecture simulation_tb_debouncer of tb_debouncer is





component debouncer is
generic
( 
    G : unsigned ( 31 downto 0 ) := to_unsigned ( 50000000 , 32 )								             
) ;												
port							
( 							   
	I_CLOCK :       	in 	std_logic ;                               				        			
	I_RESET_GLOBAL :	in 	std_logic ;                                  			  			
	I_RESET_LOCAL : 	in 	std_logic ;        		                   				
	I_TIME :		in	unsigned ( log_2_unsigned ( G ) downto 0 ) ;  
	I_BOUNCING : 	in 	std_logic ;                            			    
	O_DEBOUNCED :	buffer 	std_logic ;   
	O_RISE :		buffer 	std_logic ;   
	O_FALL :		buffer 	std_logic 
) ;       
end component debouncer ;





signal stimulus_i_clock :	std_logic := '0' ;  
signal stimulus_i_reset_global :	std_logic ; 
signal stimulus_i_reset_local :	std_logic ; 
signal stimulus_i_time :	unsigned ( log_2_unsigned ( G ) downto 0 ) ;
signal stimulus_noise :	std_logic := '0' ;
signal stimulus_i_bouncing :        std_logic ;





begin





	stimulus_noise <= not stimulus_noise after 500 ns ;
	stimulus_i_clock <= not stimulus_i_clock after 10 ns ;
	stimulus_i_reset_global <= '1' , '0' after 1 us ;
	stimulus_i_reset_local <= '1' , '0' after 2 us ;
	stimulus_i_time <= to_unsigned ( 900000000 , stimulus_i_time ' length ) ; 
	stimulus_i_bouncing <= stimulus_noise , '1' after 10 ms ;

	

	
	
	waveform : debouncer 
	generic map
	( 
		G => G							             
	) 									
	port map						
	( 							   
		I_CLOCK =>              stimulus_i_clock , 	       			
		I_RESET_GLOBAL =>	stimulus_i_reset_global ,			
		I_RESET_LOCAL => 	stimulus_i_reset_local ,
		I_TIME =>		stimulus_i_time ,
		I_BOUNCING => 	stimulus_i_bouncing ,
		O_DEBOUNCED =>	open ,
		O_RISE =>	open ,
		O_FALL =>                open 
	) ;       

end architecture simulation_tb_debouncer ;

- - - Updated - - -

untitled.JPG

10ms is where the cursor is...

- - - Updated - - -

the signal in question is the first one ( "stimulus_i_bouncing" )
 

TrickyDicky

Advanced Member level 5
Joined
Jun 7, 2010
Messages
7,091
Helped
2,078
Reputation
4,175
Reaction score
2,036
Trophy points
1,393
Activity points
39,386
not really noise if it toggles like that ;)

Anyway, I dont quite get it either, assuming that really is 10 ms (sure its not 10 us? ). Have you tried other versions of modelsim? have you raised a support request?
 
  • Like
Reactions: shaiko

    shaiko

    Points: 2
    Helpful Answer Positive Rating

shaiko

Advanced Member level 5
Joined
Aug 20, 2011
Messages
2,644
Helped
303
Reputation
608
Reaction score
297
Trophy points
1,363
Activity points
18,300
Thanks TrickyDicky,

10mS - no doubt about it. Tried it with different delays - same result.
I've tried it at on version 6.5
Will retry tomorrow on 10.1 - haven't contacted Mentor support yet.

I thought that there was something I was missing (VHDL wise) but I guess not...
Wouldn't be the first time ModelSim makes me regret using it.
 

shaiko

Advanced Member level 5
Joined
Aug 20, 2011
Messages
2,644
Helped
303
Reputation
608
Reaction score
297
Trophy points
1,363
Activity points
18,300
I resimulated the code with ModelSim 10.1
The problem persists!

Any suggestions ? ( a true solution/explanation for the problem - not a workaround solution )
 
Last edited:

alexan_e

Administrator
Joined
Mar 16, 2008
Messages
11,895
Helped
2,021
Reputation
4,158
Reaction score
2,032
Trophy points
1,393
Location
Greece
Activity points
64,375
Please forgive my ignorance but I've never seen that coding style before using the comma

Code:
stimulus_i_reset_global <= '1' , '0' after 1 us ;
	stimulus_i_reset_local <= '1' , '0' after 2 us ;
	stimulus_i_time <= to_unsigned ( 900000000 , stimulus_i_time ' length ) ; 
	stimulus_i_bouncing <= stimulus_noise , '1' after 10 ms ;

I assume that this is a valid way so my question is does this work correctly for stimulus_i_reset_global, stimulus_i_reset_local and only gives wrong result for stimulus_i_bouncing ?
 

std_match

Advanced Member level 4
Joined
Jul 9, 2010
Messages
1,215
Helped
451
Reputation
902
Reaction score
413
Trophy points
1,363
Location
Sweden
Activity points
9,420
You are switching from a waveform to a constant value, and I am not sure how this affects the event scheduling.
You can do it like this:

Code:
select_signal <= '0', '1' after 10 ms;
x <= stimulus_noise when select_signal = '0' else '1' ;
 
  • Like
Reactions: shaiko

    shaiko

    Points: 2
    Helpful Answer Positive Rating

shaiko

Advanced Member level 5
Joined
Aug 20, 2011
Messages
2,644
Helped
303
Reputation
608
Reaction score
297
Trophy points
1,363
Activity points
18,300
I assume that this is a valid way so my question is does this work correctly for stimulus_i_reset_global, stimulus_i_reset_local and only gives wrong result for stimulus_i_bouncing ?
Correct alexan_e

std_match,
As I noted there're many possible solutions for this problem...I found a workaround before posting.
It's not the issue here - I wanted to know if it was me doing something wrong or the engineers at Mentor Graphics...
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top