1 代码
`timescale 1ns / 1ps
module simulate_camera_out (
input clk,
input rest_n,
output camera_clk, //像素时钟
output [13:0] camera_data, //像素值数据
output [19:0] pixel_xy, //此时输出的像素值坐标
output reg frame_valid //帧有效信号,1代表帧有效0代表帧无效
);
localparam PIXEL_SIZE = 640 * 512; //输出像素数量
localparam PIXEL_VALUE = 16383; //14位1
localparam FRAME_DELAY = 100; //延迟100个时钟单位
reg [19:0] pixel_count;
reg [13:0] out_count;
reg [14:0] frame_delay_count;
assign camera_clk = clk;
assign camera_data = out_count;
assign pixel_xy = pixel_count;
//计算此时输出的像素坐标,0~640*512-1
always @(posedge clk or negedge rest_n) begin
if (!rest_n) begin
pixel_count <= 0;
end else begin
if (frame_valid == 0) begin
pixel_count <= 0;
end else if (pixel_count == PIXEL_SIZE - 1) begin
pixel_count <= 0;
end else begin