zcy0517 发表于 2014-4-10 11:38:18

想请教一下边沿捕获的问题

下图是一张摄像头采集来的vsync和href的信号,信号正常。但是我用下面的程序来计算一帧图像(vsync)的href上升沿的个数,得到的值最大只有11个。这是怎么回事?
module count(vsync,href,cnt);
input href;
input vsync;
output cnt;
reg cnt;
always @(posedge href or posedge vsync)
if(vsync) cnt<=0;
else cnt<=cnt+1'b1;
endmodule

3DA502 发表于 2014-4-10 12:37:55

module count(vsync,href,cnt);

input href;
input vsync;
output cntout;

reg cnt;
regcntouttemp;

always @(posedge href )
cnt<=cnt+1'b1;
always @(posedge vsync)
cntouttemp <= cnt;
always @(negedge vsync)
cnt<=0;

assign cntout = cntouttemp ;

endmodule

Fourier00 发表于 2014-4-10 22:27:41

10 module posedge_detection (
11   inputclk,
12   inputrst_n,
13   inputi_data_in,
14   output o_rising_edge
15 );
16
17 reg r_data_in0;
18 reg r_data_in1;
19
20 assign o_rising_edge = ~r_data_in0 & r_data_in1;
21
22 always@(posedge clk, negedge rst_n) begin
23   if (!rst_n) begin
24   r_data_in0 <= 0;
25   r_data_in1 <= 0;
26   end
27   else begin
28   r_data_in0 <= r_data_in1;
29   r_data_in1 <= i_data_in;
30   end
31 end
32
33 endmodule

zcy0517 发表于 2014-4-11 10:11:14

Fourier00 发表于 2014-4-10 22:27
10 module posedge_detection (
11   inputclk,
12   inputrst_n,


谢了哈~~

zcy0517 发表于 2014-4-11 10:11:45

3DA502 发表于 2014-4-10 12:37
module count(vsync,href,cnt);

input href;


谢咯~{:biggrin:}

zcy0517 发表于 2014-4-11 16:34:31

3DA502 发表于 2014-4-10 12:37
module count(vsync,href,cnt);

input href;


cnt可以再两个always下赋值?

3DA502 发表于 2014-4-11 16:41:26

简单的说,场同步上升沿把计数器的值锁存到输出寄存器,下降沿把计数器清零,准备做下一场的行计数
页: [1]
查看完整版本: 想请教一下边沿捕获的问题