| 1 |
`default_nettype none |
| 2 |
module top(input wire clk, |
| 3 |
input wire rst_i, |
| 4 |
input wire fclk_i, |
| 5 |
input wire tlvds_p, |
| 6 |
input wire tlvds_n, |
| 7 |
output wire pclk_o, |
| 8 |
output wire [7:0]mled); |
| 9 |
|
| 10 |
wire rst = rst_i ^ `INV_BTN; |
| 11 |
wire data_i; |
| 12 |
IVIDEO ides( |
| 13 |
.D(data_i), |
| 14 |
.FCLK(fclk_i), |
| 15 |
.PCLK(pclk_o), |
| 16 |
.CALIB(1'b0), |
| 17 |
.RESET(!rst), |
| 18 |
.Q0(mled[0]), |
| 19 |
.Q1(mled[1]), |
| 20 |
.Q2(mled[2]), |
| 21 |
.Q3(mled[3]), |
| 22 |
.Q4(mled[4]), |
| 23 |
.Q5(mled[5]), |
| 24 |
.Q6(mled[6]) |
| 25 |
); |
| 26 |
|
| 27 |
TLVDS_IBUF in( |
| 28 |
.I(tlvds_p), |
| 29 |
.IB(tlvds_n), |
| 30 |
.O(data_i) |
| 31 |
); |
| 32 |
|
| 33 |
// div by 3.5 |
| 34 |
reg [6:0]cnt_r; |
| 35 |
reg ps0_r; |
| 36 |
reg ps3_r; |
| 37 |
reg ps4_r; |
| 38 |
always @(posedge fclk_i) begin |
| 39 |
if (!rst) begin |
| 40 |
cnt_r[6:0] <= 7'b000_0001; |
| 41 |
end else begin |
| 42 |
cnt_r[6:0] <= {cnt_r[5:0], cnt_r[6]}; |
| 43 |
end |
| 44 |
end |
| 45 |
|
| 46 |
always @(negedge fclk_i) begin |
| 47 |
if (!rst) begin |
| 48 |
ps0_r <= 1'b0; |
| 49 |
ps3_r <= 1'b0; |
| 50 |
ps4_r <= 1'b0; |
| 51 |
end else begin |
| 52 |
ps0_r <= cnt_r[0]; |
| 53 |
ps3_r <= cnt_r[3]; |
| 54 |
ps4_r <= cnt_r[4]; |
| 55 |
end |
| 56 |
end |
| 57 |
assign pclk_o = (ps0_r | cnt_r[0] | cnt_r[1]) | (ps3_r | ps4_r | cnt_r[4]); |
| 58 |
endmodule |