📄 de2_tv1.v
字号:
// --------------------------------------------------------------------
// Copyright (c) 2005 by Terasic Technologies Inc.
// --------------------------------------------------------------------
//
// Permission:
//
// Terasic grants permission to use and modify this code for use
// in synthesis for all Terasic Development Boards and Altera Development
// Kits made by Terasic. Other use of this code, including the selling
// ,duplication, or modification of any portion is strictly prohibited.
//
// Disclaimer:
//
// This VHDL/Verilog or C/C++ source code is intended as a design reference
// which illustrates how these types of functions can be implemented.
// It is the user's responsibility to verify their design for
// consistency and functionality through the use of formal
// verification methods. Terasic provides no warranty regarding the use
// or functionality of this code.
//
// --------------------------------------------------------------------
//
// Terasic Technologies Inc
// 356 Fu-Shin E. Rd Sec. 1. JhuBei City,
// HsinChu County, Taiwan
// 302
//
// web: http://www.terasic.com/
// email: support@terasic.com
//
// --------------------------------------------------------------------
// Major Functions: DE2 TV Box
// --------------------------------------------------------------------
//
// Revision History :
// --------------------------------------------------------------------
// Ver :| Author :| Mod. Date :| Changes Made:
// V1.0 :| Joe Yang :| 05/07/05 :| Initial Revision
// V1.1 :| Johnny Chen :| 05/09/05 :| Changed YCbCr2RGB Block,
// RGB output 8 Bits => 10 Bits
// V1.2 :| Johnny Chen :| 05/10/05 :| H_SYNC & V_SYNC Timing fixed.
// V1.3 :| Johnny Chen :| 05/11/16 :| Added FLASH Address FL_ADDR[21:20]
// V1.4 :| Joe Yang :| 06/07/20 :| Modify Output Color
// V2.0 :| Johnny Chen :| 06/11/20 :| New Version for DE2 v1.X PCB.
// --------------------------------------------------------------------
module DE2_TV1
(
//////////////////// Clock Input ////////////////////
OSC_27, // 27 MHz
OSC_50, // 50 MHz
EXT_CLOCK, // External Clock
//////////////////// Push Button ////////////////////
KEY, // Button[3:0]
//////////////////// USB JTAG link ////////////////////
TDI, // CPLD -> FPGA (data in)
TCK, // CPLD -> FPGA (clk)
TCS, // CPLD -> FPGA (CS)
TDO, // FPGA -> CPLD (data out)
//////////////////// I2C ////////////////////////////
I2C_SDAT, // I2C Data
I2C_SCLK, // I2C Clock
//////////////// TV Decoder ////////////////////////
TD_DATA, // TV Decoder Data bus 8 bits
TD_HS, // TV Decoder H_SYNC
TD_VS, // TV Decoder V_SYNC
TD_RESET, // TV Decoder Reset
Red,
Green,
Blue,
/////////////////// control signal ///////////////////////
DVAL,
Field
);
//////////////////////// Clock Input ////////////////////////
input OSC_27; // 27 MHz
input OSC_50; // 50 MHz
input EXT_CLOCK; // External Clock
//////////////////////// Push Button ////////////////////////
input [3:0] KEY; // Button[3:0]
//////////////////////// I2C ////////////////////////////////
inout I2C_SDAT; // I2C Data
output I2C_SCLK; // I2C Clock
//////////////////// USB JTAG link ////////////////////////////
input TDI; // CPLD -> FPGA (data in)
input TCK; // CPLD -> FPGA (clk)
input TCS; // CPLD -> FPGA (CS)
output TDO; // FPGA -> CPLD (data out)
//////////////////// TV Devoder ////////////////////////////
input [7:0] TD_DATA; // TV Decoder Data bus 8 bits
input TD_HS; // TV Decoder H_SYNC
input TD_VS; // TV Decoder V_SYNC
output TD_RESET; // TV Decoder Reset
//////////////////////// RGB DATA ////////////////////////////////
output [9:0] Red;
output [9:0] Green;
output [9:0] Blue;
/////////////////////// control signal /////////////////////////
output DVAL;
output Field;
// Enable TV Decoder
assign TD_RESET = KEY[0];
// Audio CODEC and video decoder setting
I2C_AV_Config u1 ( // Host Side
.iCLK(OSC_50),
.iRST_N(KEY[0]),
// I2C Side
.I2C_SCLK(I2C_SCLK),
.I2C_SDAT(I2C_SDAT) );
// TV Decoder Stable Check
TD_Detect u2 ( .oTD_Stable(TD_Stable),
.iTD_VS(TD_VS),
.iTD_HS(TD_HS),
.iRST_N(KEY[0]) );
// Reset Delay Timer
Reset_Delay u3 ( .iCLK(OSC_50),
.iRST(TD_Stable),
.oRST_0(DLY0),
.oRST_1(DLY1),
.oRST_2(DLY2));
// ITU-R 656 to YUV 4:2:2
ITU_656_Decoder u4 ( // TV Decoder Input
.iTD_DATA(TD_DATA),
// Position Output
.oTV_X(TV_X),
// YUV 4:2:2 Output
.oYCbCr(YCbCr),
.oDVAL(TV_DVAL),
.oField(oField),
.iRST_N(DLY1),
.iCLK_27(OSC_27) );
// YUV 4:2:2 to YUV 4:4:4
YUV422_to_444 u5( // YUV 4:2:2 Input
.iYCbCr(YCbCr),
.iDval(TV_DVAL),
// YUV 4:4:4 Output
.oY(mY),
.oCb(mCb),
.oCr(mCr),
.oDval(mDVAL),
// Control Signals
.iX(VGA_X),
.iCLK(OSC_27),
.iRST_N(DLY0));
// YCbCr 8-bit to RGB-10 bit
YCbCr2RGB u6( // Output Side
.Red(oRed),
.Green(oGreen),
.Blue(oBlue),
.oDVAL(oDVAL),
// Input Side
.iY(mY),
.iCb(mCb),
.iCr(mCr),
.iDVAL(mDVAL),
// Control Signal
.iRESET(!DLY2),
.iCLK(OSC_27));
// For ITU-R 656 Decoder
wire [15:0] YCbCr;
wire [9:0] TV_X;
wire TV_DVAL;
// For YUV 4:2:2 to YUV 4:4:4
wire [7:0] mY;
wire [7:0] mCb;
wire [7:0] mCr;
// For Delay Timer
wire TD_Stable;
wire DLY0;
wire DLY1;
wire DLY2;
wire mDVAL;
wire oDVAL;
wire DVAL;
assign DVAL=oDVAL;
wire oField;
assign Field=oField;
wire [9:0] oRed;
wire [9:0] oGreen;
wire [9:0] oBlue;
assign Red=oRed;
assign Green=oGreen;
assign Blue=oBlue;
endmodule
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -