2015-06-26 09:04:19 +00:00
|
|
|
// ***************************************************************************
|
|
|
|
// ***************************************************************************
|
2017-05-17 08:44:52 +00:00
|
|
|
// Copyright 2014 - 2017 (c) Analog Devices, Inc. All rights reserved.
|
|
|
|
//
|
2017-05-31 15:15:24 +00:00
|
|
|
// In this HDL repository, there are many different and unique modules, consisting
|
|
|
|
// of various HDL (Verilog or VHDL) components. The individual modules are
|
|
|
|
// developed independently, and may be accompanied by separate and unique license
|
|
|
|
// terms.
|
|
|
|
//
|
|
|
|
// The user should read each of these license terms, and understand the
|
2018-03-14 14:45:47 +00:00
|
|
|
// freedoms and responsibilities that he or she has by using this source/core.
|
2017-05-31 15:15:24 +00:00
|
|
|
//
|
|
|
|
// This core is distributed in the hope that it will be useful, but WITHOUT ANY
|
2017-05-29 06:55:41 +00:00
|
|
|
// WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
|
|
|
// A PARTICULAR PURPOSE.
|
2017-05-17 08:44:52 +00:00
|
|
|
//
|
2017-05-29 06:55:41 +00:00
|
|
|
// Redistribution and use of source or resulting binaries, with or without modification
|
|
|
|
// of this file, are permitted under one of the following two license terms:
|
2017-05-17 08:44:52 +00:00
|
|
|
//
|
|
|
|
// 1. The GNU General Public License version 2 as published by the
|
2017-05-31 15:15:24 +00:00
|
|
|
// Free Software Foundation, which can be found in the top level directory
|
|
|
|
// of this repository (LICENSE_GPL2), and also online at:
|
|
|
|
// <https://www.gnu.org/licenses/old-licenses/gpl-2.0.html>
|
2017-05-17 08:44:52 +00:00
|
|
|
//
|
|
|
|
// OR
|
|
|
|
//
|
2017-05-31 15:15:24 +00:00
|
|
|
// 2. An ADI specific BSD license, which can be found in the top level directory
|
|
|
|
// of this repository (LICENSE_ADIBSD), and also on-line at:
|
2017-05-29 06:55:41 +00:00
|
|
|
// https://github.com/analogdevicesinc/hdl/blob/master/LICENSE_ADIBSD
|
|
|
|
// This will allow to generate bit files and not release the source code,
|
|
|
|
// as long as it attaches to an ADI device.
|
2015-06-26 09:04:19 +00:00
|
|
|
//
|
|
|
|
// ***************************************************************************
|
|
|
|
// ***************************************************************************
|
|
|
|
// Transmit HDMI, RGB to CrYCb conversion
|
|
|
|
// The multiplication coefficients are in 1.4.12 format
|
|
|
|
// The addition coefficients are in 1.12.12 format
|
|
|
|
// Cr = (+112.439/256)*R + (-094.154/256)*G + (-018.285/256)*B + 128;
|
|
|
|
// Y = (+065.738/256)*R + (+129.057/256)*G + (+025.064/256)*B + 16;
|
|
|
|
// Cb = (-037.945/256)*R + (-074.494/256)*G + (+112.439/256)*B + 128;
|
|
|
|
|
2018-08-27 07:14:54 +00:00
|
|
|
`timescale 1ns/100ps
|
|
|
|
|
2017-04-13 08:45:54 +00:00
|
|
|
module ad_csc_RGB2CrYCb #(
|
|
|
|
|
2022-04-08 10:21:52 +00:00
|
|
|
parameter DELAY_DATA_WIDTH = 16
|
|
|
|
) (
|
2015-06-26 09:04:19 +00:00
|
|
|
|
|
|
|
// R-G-B inputs
|
|
|
|
|
2019-10-14 13:01:33 +00:00
|
|
|
input clk,
|
|
|
|
input [DELAY_DATA_WIDTH-1:0] RGB_sync,
|
|
|
|
input [23:0] RGB_data,
|
2015-06-26 09:04:19 +00:00
|
|
|
|
|
|
|
// Cr-Y-Cb outputs
|
|
|
|
|
2019-10-14 13:01:33 +00:00
|
|
|
output [DELAY_DATA_WIDTH-1:0] CrYCb_sync,
|
2022-04-08 10:21:52 +00:00
|
|
|
output [23:0] CrYCb_data
|
|
|
|
);
|
2015-06-26 09:04:19 +00:00
|
|
|
|
|
|
|
localparam DW = DELAY_DATA_WIDTH - 1;
|
|
|
|
|
|
|
|
// Cr (red-diff)
|
|
|
|
|
2018-09-13 13:26:51 +00:00
|
|
|
ad_csc #(
|
2022-04-08 10:21:52 +00:00
|
|
|
.DELAY_DW(DELAY_DATA_WIDTH)
|
|
|
|
) j_csc_1_Cr (
|
2015-06-26 09:04:19 +00:00
|
|
|
.clk (clk),
|
|
|
|
.sync (RGB_sync),
|
|
|
|
.data (RGB_data),
|
2018-09-18 13:24:58 +00:00
|
|
|
.C1 ( 17'd28784), // 112.439
|
|
|
|
.C2 (-17'd24103), // -94.154
|
|
|
|
.C3 (-17'd4681), // -18.285
|
|
|
|
.C4 ( 24'd8388608), // 128
|
2018-09-13 13:26:51 +00:00
|
|
|
.csc_sync (CrYCb_sync),
|
|
|
|
.csc_data (CrYCb_data[23:16]));
|
2015-06-26 09:04:19 +00:00
|
|
|
|
|
|
|
// Y (luma)
|
|
|
|
|
2018-09-13 13:26:51 +00:00
|
|
|
ad_csc #(
|
2022-04-08 10:21:52 +00:00
|
|
|
.DELAY_DW(0)
|
|
|
|
) j_csc_1_Y (
|
2015-06-26 09:04:19 +00:00
|
|
|
.clk (clk),
|
|
|
|
.sync (1'd0),
|
|
|
|
.data (RGB_data),
|
2018-09-18 13:24:58 +00:00
|
|
|
.C1 (17'd16829), // 65.739
|
|
|
|
.C2 (17'd33039), // 129.057
|
|
|
|
.C3 (17'd6416), // 25.064
|
|
|
|
.C4 (24'd1048576), // 16
|
2018-09-13 13:26:51 +00:00
|
|
|
.csc_sync (),
|
|
|
|
.csc_data (CrYCb_data[15:8]));
|
2015-06-26 09:04:19 +00:00
|
|
|
|
|
|
|
// Cb (blue-diff)
|
|
|
|
|
2018-09-13 13:26:51 +00:00
|
|
|
ad_csc #(
|
2022-04-08 10:21:52 +00:00
|
|
|
.DELAY_DW(0)
|
|
|
|
) j_csc_1_Cb (
|
2015-06-26 09:04:19 +00:00
|
|
|
.clk (clk),
|
|
|
|
.sync (1'd0),
|
|
|
|
.data (RGB_data),
|
2018-09-18 13:24:58 +00:00
|
|
|
.C1 (-17'd9714), // -37.945
|
|
|
|
.C2 (-17'd19070), // -74.494
|
|
|
|
.C3 ( 17'd28784), // 112.439
|
|
|
|
.C4 (24'd8388608), // 128
|
2018-09-13 13:26:51 +00:00
|
|
|
.csc_sync (),
|
|
|
|
.csc_data (CrYCb_data[7:0]));
|
2015-06-26 09:04:19 +00:00
|
|
|
|
|
|
|
endmodule
|