Programmable Devices
CPLDs, FPGAs, SoC FPGAs, Configuration, and Transceivers
21600 Discussions

detect video Signal

Altera_Forum
Honored Contributor II
1,738 Views

hello, could someone explain me this following code? i have found it in a demo application but with no Comments. thank you 

 

module sigdetect( 

oTD_Stable, 

iTD_VS, 

iTD_HS, 

iRST_N ); 

 

input iTD_VS; 

input iTD_HS; 

input iRST_N; 

output oTD_Stable; 

 

reg TD_Stable; 

reg Pre_VS; 

reg [7:0] Stable_Cont; 

 

assign oTD_Stable = TD_Stable; 

 

always@(posedge iTD_HS or negedge iRST_N) 

begin 

if(!iRST_N) 

begin 

TD_Stable <= 1'b0; 

Stable_Cont <= 4'h0; 

Pre_VS <= 1'b0; 

end 

else 

begin 

Pre_VS <= iTD_VS; 

if(!iTD_VS) 

Stable_Cont <= Stable_Cont+1'b1; 

else 

Stable_Cont <= 0; 

 

if({Pre_VS,iTD_VS}==2'b01) 

begin 

if(Stable_Cont==9) 

TD_Stable <= 1'b1; 

else 

TD_Stable <= 1'b0; 

end 

end 

end
0 Kudos
6 Replies
Altera_Forum
Honored Contributor II
925 Views

 

--- Quote Start ---  

hello, could someone explain me this following code? i have found it in a demo application but with no Comments. thank you 

 

module sigdetect( 

oTD_Stable, 

iTD_VS, 

iTD_HS, 

iRST_N ); 

 

input iTD_VS; 

input iTD_HS; 

input iRST_N; 

output oTD_Stable; 

 

reg TD_Stable; 

reg Pre_VS; 

reg [7:0] Stable_Cont; 

 

assign oTD_Stable = TD_Stable; 

 

always@(posedge iTD_HS or negedge iRST_N) 

begin 

if(!iRST_N) 

begin 

TD_Stable <= 1'b0; 

Stable_Cont <= 4'h0; 

Pre_VS <= 1'b0; 

end 

else 

begin 

Pre_VS <= iTD_VS; 

if(!iTD_VS) 

Stable_Cont <= Stable_Cont+1'b1; 

else 

Stable_Cont <= 0; 

 

if({Pre_VS,iTD_VS}==2'b01) 

begin 

if(Stable_Cont==9) 

TD_Stable <= 1'b1; 

else 

TD_Stable <= 1'b0; 

end 

end 

end 

--- Quote End ---  

 

module sigdetect (oTD_Stable, iTD_VS, iTD_HS, iRST_N); input iTD_VS; input iTD_HS; input iRST_N; output oTD_Stable; reg TD_Stable; reg Pre_VS; reg Stable_Cont; assign oTD_Stable = TD_Stable; always @ (posedge iTD_HS or negedge iRST_N) begin if (!iRST_N) begin //all reset TD_Stable <= 1 'b0; Stable_Cont <= 4' h0; Pre_VS <= 1 'b0; end else begin //this is for each horisontal syno impulse Pre_VS <= iTD_VS; if(!iTD_VS)Stable_Cont <= Stable_Cont+1' b1; // blank time. Old frame is finish. But new frame is not begun. count HS singal pulses during blank time. else Stable_Cont <= 0;// draw frame. do nothing if ({Pre_VS, iTD_VS} == 2 'b01)// new frame is begin. begin if(Stable_Cont==9) TD_Stable <= 1' b1; // if during blank time been 9 pulses HS the signal is stable. else TD_Stable <= 1 'b0; // signal not stable. end end end  

 

blank time os "back moving beam". I don't know how to in english.
0 Kudos
Altera_Forum
Honored Contributor II
925 Views

blank time is http://en.wikipedia.org/wiki/vertical_blanking_interval 

 

Sorry for my English.
0 Kudos
Altera_Forum
Honored Contributor II
925 Views

 

--- Quote Start ---  

blank time is http://en.wikipedia.org/wiki/vertical_blanking_interval 

 

Sorry for my English. 

--- Quote End ---  

 

 

thank you for your Answer, aber i can't understand why 9 pulse is using
0 Kudos
Altera_Forum
Honored Contributor II
925 Views

 

--- Quote Start ---  

thank you for your Answer, aber i can't understand why 9 pulse is using 

--- Quote End ---  

 

It's you video signal parameter. You V-blank duration is 9 horizontal sync pulses.
0 Kudos
Altera_Forum
Honored Contributor II
925 Views

 

--- Quote Start ---  

It's you video signal parameter. You V-blank duration is 9 horizontal sync pulses. 

--- Quote End ---  

 

 

 

i cannot find this info that the V-blank is 9 horizontal sync pulses, can you give me more details...thanks
0 Kudos
Altera_Forum
Honored Contributor II
925 Views

 

--- Quote Start ---  

i cannot find this info that the V-blank is 9 horizontal sync pulses, can you give me more details...thanks 

--- Quote End ---  

 

It's depend on video signal. Different video signal have different parameter. The exactly 9 pulses looks very strange. Usually for video signal specified duration of V-blank, H-blank. And not exactly. You can find parameters for PAL or SECAM or VGA.
0 Kudos
Reply