/* * DSI Core * Copyright (C) 2013 twl * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3.0 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library. */ `include "dsi_defs.vh" `timescale 1ns/1ps /* * dsi_core.v * * Top level of the core. Currently works on Spartan-6 FPGAs only. */ module dsi_core ( // system clock (= pixel clock for the moment) clk_sys_i, // PHY serdes clock (= 8x pixel clock) clk_phy_i, rst_n_i, pll_locked_i, frame_ready_o, // Pixel FIFO interface fifo_full_o, fifo_pixels_i, fifo_frame_i, fifo_wr_i, // DSI high speed output (OSERDES2) dsi_hs_p_o, dsi_hs_n_o, // DSI low power output dsi_lp_p_o, dsi_lp_n_o, // Lop power output enable dsi_lp_oe_o, // DSI clock lane output dsi_clk_p_o, dsi_clk_n_o, // DSI clock lane LP signals + output enable dsi_clk_lp_p_o, dsi_clk_lp_n_o, dsi_clk_lp_oe_o, // Displat reset pin dsi_reset_n_o, // Host control registers host_a_i, host_d_i, host_d_o, host_wr_i ); parameter g_pixels_per_clock = 1; parameter g_lanes = 3; parameter g_fifo_size = 1024; parameter g_invert_lanes = 0; parameter g_invert_clock = 0; localparam g_pixel_width = 24 * g_pixels_per_clock; input clk_sys_i, clk_phy_i, rst_n_i; input pll_locked_i; output frame_ready_o; output fifo_full_o; input [g_pixel_width - 1 : 0 ] fifo_pixels_i; input fifo_frame_i, fifo_wr_i; output dsi_clk_p_o, dsi_clk_n_o; output [g_lanes-1:0] dsi_hs_p_o, dsi_hs_n_o; output [g_lanes-1:0] dsi_lp_p_o, dsi_lp_n_o; output [g_lanes-1:0] dsi_lp_oe_o; output dsi_clk_lp_p_o, dsi_clk_lp_n_o; output dsi_clk_lp_oe_o; output reg dsi_reset_n_o; input [5:0] host_a_i; input [31:0] host_d_i; output [31:0] host_d_o; input host_wr_i; /////////////////// // PHY/Serdes layer /////////////////// reg tick = 0; wire [g_lanes-1:0] phy_hs_ready_lane, lp_ready_lane, lp_readback_lane; wire [g_lanes:0] serdes_oe_lane; wire [g_lanes-1:0] lp_txp, lp_txn, lp_oe; wire lp_ready; wire phy_hs_ready; assign lp_ready = lp_ready_lane[0]; assign phy_hs_ready = phy_hs_ready_lane[0]; wire phy_hs_request; wire [g_lanes * 8 -1 :0] phy_hs_data; wire [g_lanes-1:0] phy_hs_valid; wire [(g_lanes + 1) * 8 - 1: 0] serdes_data, serdes_data_interleaved; reg r_dsi_clk_en = 0; reg lp_request = 0; reg lp_valid = 0; reg [7:0] lp_data = 0; generate genvar i; for(i=0;i> ((g_lanes - 1 - i)*8)}), .hs_ready_o (phy_hs_ready_lane[i]), .hs_valid_i(phy_hs_valid[i]), .lp_request_i (lp_request), .lp_data_i (lp_data), .lp_valid_i (i ==0 ? lp_valid : 1'b0), .lp_ready_o (lp_ready_lane[i]), .serdes_data_o(serdes_data[i*8+:8]), .lp_txp_o(lp_txp[i]), .lp_txn_o(lp_txn[i]), .lp_oe_o(lp_oe[i]) ); assign dsi_lp_p_o[i] = lp_txp[i]; assign dsi_lp_n_o[i] = lp_txn[i]; assign dsi_lp_oe_o[i] = lp_oe[0]; assign serdes_oe_lane[i] = ~lp_oe[0]; end // for (i=0;i