Skip to content

Commit c461f18

Browse files
authored
Add files via upload
1 parent 45aed81 commit c461f18

File tree

100 files changed

+38436
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

100 files changed

+38436
-0
lines changed
Lines changed: 222 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,222 @@
1+
// ============================================================================
2+
// Copyright (c) 2012 by Terasic Technologies Inc.
3+
// ============================================================================
4+
//
5+
// Permission:
6+
//
7+
// Terasic grants permission to use and modify this code for use
8+
// in synthesis for all Terasic Development Boards and Altera Development
9+
// Kits made by Terasic. Other use of this code, including the selling
10+
// ,duplication, or modification of any portion is strictly prohibited.
11+
//
12+
// Disclaimer:
13+
//
14+
// This VHDL/Verilog or C/C++ source code is intended as a design reference
15+
// which illustrates how these types of functions can be implemented.
16+
// It is the user's responsibility to verify their design for
17+
// consistency and functionality through the use of formal
18+
// verification methods. Terasic provides no warranty regarding the use
19+
// or functionality of this code.
20+
//
21+
// ============================================================================
22+
//
23+
// Terasic Technologies Inc
24+
// 9F., No.176, Sec.2, Gongdao 5th Rd, East Dist, Hsinchu City, 30070. Taiwan
25+
//
26+
//
27+
//
28+
// web: http://www.terasic.com/
29+
// email: support@terasic.com
30+
//
31+
// ============================================================================
32+
33+
/*
34+
35+
Function:
36+
ADV7513 Video and Audio Control
37+
38+
I2C Configuration Requirements:
39+
Master Mode
40+
I2S, 16-bits
41+
42+
Clock:
43+
input Clock 1.536MHz (48K*Data_Width*Channel_Num)
44+
45+
Revision:
46+
1.0, 10/06/2014, Init by Nick
47+
48+
Compatibility:
49+
Quartus 14.0.2
50+
51+
*/
52+
53+
54+
55+
56+
module AUDIO_IF(
57+
//
58+
reset_n,
59+
sclk,
60+
lrclk,
61+
i2s,
62+
clk
63+
);
64+
65+
/*****************************************************************************
66+
* Constant Declarations *
67+
*****************************************************************************/
68+
69+
70+
/*****************************************************************************
71+
* Port Declarations *
72+
*****************************************************************************/
73+
74+
//
75+
output sclk;
76+
output lrclk;
77+
input reset_n;
78+
output [3:0] i2s;
79+
input clk;
80+
81+
parameter DATA_WIDTH = 16;
82+
parameter SIN_SAMPLE_DATA = 48;
83+
/*****************************************************************************
84+
* Internal wires and registers Declarations *
85+
*****************************************************************************/
86+
87+
reg lrclk;
88+
reg [5:0] sclk_Count;
89+
reg [5:0] Simple_count;
90+
reg [15:0] Data_Bit;
91+
reg [6:0] Data_Count;
92+
reg [5:0] SIN_Cont;
93+
reg [3:0] i2s;
94+
/*****************************************************************************
95+
* Sequential logic *
96+
*****************************************************************************/
97+
assign sclk = clk;
98+
99+
always@(negedge sclk or negedge reset_n)
100+
begin
101+
if(!reset_n)
102+
begin
103+
lrclk<=0;
104+
sclk_Count<=0;
105+
end
106+
107+
else if(sclk_Count>=DATA_WIDTH-1)
108+
begin
109+
sclk_Count <= 0;
110+
lrclk <= ~lrclk;
111+
end
112+
else
113+
sclk_Count <= sclk_Count + 1;
114+
end
115+
116+
always@(negedge sclk or negedge reset_n)
117+
begin
118+
if(!reset_n)
119+
begin
120+
Data_Count <= 0;
121+
end
122+
else
123+
begin
124+
if(Data_Count >= DATA_WIDTH-1)
125+
begin
126+
Data_Count <= 0;
127+
end
128+
else
129+
Data_Count <= Data_Count +1;
130+
end
131+
end
132+
133+
always@(negedge sclk or negedge reset_n)
134+
begin
135+
if(!reset_n)
136+
begin
137+
i2s <= 0;
138+
end
139+
else
140+
begin
141+
i2s[0] <= Data_Bit[~Data_Count];
142+
i2s[1] <= Data_Bit[~Data_Count];
143+
i2s[2] <= Data_Bit[~Data_Count];
144+
i2s[3] <= Data_Bit[~Data_Count];
145+
end
146+
end
147+
148+
always@(negedge lrclk or negedge reset_n)
149+
begin
150+
if(!reset_n)
151+
SIN_Cont <= 0;
152+
else
153+
begin
154+
if(SIN_Cont < SIN_SAMPLE_DATA-1 )
155+
SIN_Cont <= SIN_Cont+1;
156+
else
157+
SIN_Cont <= 0;
158+
end
159+
end
160+
161+
/*****************************************************************************
162+
* Combinational logic *
163+
*****************************************************************************/
164+
always@(SIN_Cont)
165+
begin
166+
case(SIN_Cont)
167+
0 : Data_Bit <= 0 ;
168+
1 : Data_Bit <= 4276 ;
169+
2 : Data_Bit <= 8480 ;
170+
3 : Data_Bit <= 12539 ;
171+
4 : Data_Bit <= 16383 ;
172+
5 : Data_Bit <= 19947 ;
173+
6 : Data_Bit <= 23169 ;
174+
7 : Data_Bit <= 25995 ;
175+
8 : Data_Bit <= 28377 ;
176+
9 : Data_Bit <= 30272 ;
177+
10 : Data_Bit <= 31650 ;
178+
11 : Data_Bit <= 32486 ;
179+
12 : Data_Bit <= 32767 ;
180+
13 : Data_Bit <= 32486 ;
181+
14 : Data_Bit <= 31650 ;
182+
15 : Data_Bit <= 30272 ;
183+
16 : Data_Bit <= 28377 ;
184+
17 : Data_Bit <= 25995 ;
185+
18 : Data_Bit <= 23169 ;
186+
19 : Data_Bit <= 19947 ;
187+
20 : Data_Bit <= 16383 ;
188+
21 : Data_Bit <= 12539 ;
189+
22 : Data_Bit <= 8480 ;
190+
23 : Data_Bit <= 4276 ;
191+
24 : Data_Bit <= 0 ;
192+
25 : Data_Bit <= 61259 ;
193+
26 : Data_Bit <= 57056 ;
194+
27 : Data_Bit <= 52997 ;
195+
28 : Data_Bit <= 49153 ;
196+
29 : Data_Bit <= 45589 ;
197+
30 : Data_Bit <= 42366 ;
198+
31 : Data_Bit <= 39540 ;
199+
32 : Data_Bit <= 37159 ;
200+
33 : Data_Bit <= 35263 ;
201+
34 : Data_Bit <= 33885 ;
202+
35 : Data_Bit <= 33049 ;
203+
36 : Data_Bit <= 32768 ;
204+
37 : Data_Bit <= 33049 ;
205+
38 : Data_Bit <= 33885 ;
206+
39 : Data_Bit <= 35263 ;
207+
40 : Data_Bit <= 37159 ;
208+
41 : Data_Bit <= 39540 ;
209+
42 : Data_Bit <= 42366 ;
210+
43 : Data_Bit <= 45589 ;
211+
44 : Data_Bit <= 49152 ;
212+
45 : Data_Bit <= 52997 ;
213+
46 : Data_Bit <= 57056 ;
214+
47 : Data_Bit <= 61259 ;
215+
default :
216+
Data_Bit <= 0 ;
217+
endcase
218+
219+
end
220+
endmodule
221+
222+
Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
#**************************************************************
2+
# Create Clock
3+
#**************************************************************
4+
create_clock -period "50.0 MHz" [get_ports CLK_IN_50]
5+
create_clock -period "50.0 MHz" [get_ports CLK_IN_50_vid]
6+
7+
create_clock -period "1.0 MHz" [get_nets {I2C_HDMI_Config:u_I2C_HDMI_Config|mI2C_CTRL_CLK}]
8+
9+
10+
#**************************************************************
11+
# Create Generated Clock
12+
#**************************************************************
13+
derive_pll_clocks
14+
15+
16+
#**************************************************************
17+
# Set Clock Latency
18+
#**************************************************************
19+
20+
21+
22+
#**************************************************************
23+
# Set Clock Uncertainty
24+
#**************************************************************
25+
derive_clock_uncertainty
26+
27+
#Specify the required tSU
28+
set tSU 0.500
29+
#Specify the required tH
30+
set tH 2.000
31+
32+
#Specify the required tCO 9 96 = 7.5
33+
#Use -7.5 for -6 Altera FPGA
34+
#Use -8.0 for -7 Altera FPGA
35+
#Use -8.5 for -8 Altera FPGA
36+
set tCO -7.500
37+
38+
#Specify the required tCOm
39+
set tCOm -3.800
40+
41+
42+
##**************************************************************
43+
## Set Input Delay
44+
##**************************************************************
45+
46+
set_input_delay -clock [get_clocks {*DDR3_PLL5*counter[2]*}] -max -add_delay $tSU [get_ports {DDR3_DQ*[*]}]
47+
set_input_delay -clock [get_clocks {*DDR3_PLL5*counter[2]*}] -min -add_delay $tH [get_ports {DDR3_DQ*[*]}]
48+
set_input_delay -clock [get_clocks {*DDR3_PLL5*counter[2]*}] -clock_fall -max -add_delay $tSU [get_ports {DDR3_DQ*[*]}]
49+
set_input_delay -clock [get_clocks {*DDR3_PLL5*counter[2]*}] -clock_fall -min -add_delay $tH [get_ports {DDR3_DQ*[*]}]
50+
51+
set_input_delay -clock [get_clocks {*DDR3_PLL5*counter[4]*}] -max $tSU [get_ports {GPIO0_D[*]}]
52+
set_input_delay -clock [get_clocks {*DDR3_PLL5*counter[4]*}] -min $tH [get_ports {GPIO0_D[*]}]
53+
set_input_delay -clock [get_clocks {*DDR3_PLL5*counter[4]*}] -max $tSU [get_ports {KEY[*]}]
54+
set_input_delay -clock [get_clocks {*DDR3_PLL5*counter[4]*}] -min $tH [get_ports {KEY[*]}]
55+
set_input_delay -clock [get_clocks {*DDR3_PLL5*counter[4]*}] -max $tSU [get_ports {SW[*]}]
56+
set_input_delay -clock [get_clocks {*DDR3_PLL5*counter[4]*}] -min $tH [get_ports {SW[*]}]
57+
set_input_delay -clock [get_clocks {*DDR3_PLL5*counter[4]*}] -max $tSU [get_ports {HDMI_I2C_SDA}]
58+
set_input_delay -clock [get_clocks {*DDR3_PLL5*counter[4]*}] -min $tH [get_ports {HDMI_I2C_SDA}]
59+
set_input_delay -clock [get_clocks {*DDR3_PLL5*counter[4]*}] -max $tSU [get_ports {HDMI_TX_INT}]
60+
set_input_delay -clock [get_clocks {*DDR3_PLL5*counter[4]*}] -min $tH [get_ports {HDMI_TX_INT}]
61+
62+
63+
##**************************************************************
64+
## Set Output Delay
65+
##**************************************************************
66+
67+
set_output_delay -clock [get_clocks {*DDR3_PLL5*counter[0]*}] -max $tCO [get_ports {DDR3*}] -add_delay
68+
set_output_delay -clock [get_clocks {*DDR3_PLL5*counter[0]*}] -max $tCO -clock_fall [get_ports {DDR3*}] -add_delay
69+
set_output_delay -clock [get_clocks {*DDR3_PLL5*counter[0]*}] -min $tCOm [get_ports {DDR3*}] -add_delay
70+
set_output_delay -clock [get_clocks {*DDR3_PLL5*counter[0]*}] -min $tCOm -clock_fall [get_ports {DDR3*}] -add_delay
71+
72+
set_output_delay -clock [get_clocks {*DDR3_PLL5*counter[4]*}] -max $tCO [get_ports {GPIO0_D[*]}]
73+
set_output_delay -clock [get_clocks {*DDR3_PLL5*counter[4]*}] -min $tCOm [get_ports {GPIO0_D[*]}]
74+
set_output_delay -clock [get_clocks {*DDR3_PLL5*counter[4]*}] -max $tCO [get_ports {LED[*]}]
75+
set_output_delay -clock [get_clocks {*DDR3_PLL5*counter[4]*}] -min $tCOm [get_ports {LED[*]}]
76+
77+
set_output_delay -clock CLK_IN_50_vid -max $tCO [get_ports {HDMI*}]
78+
set_output_delay -clock CLK_IN_50_vid -min $tCOm [get_ports {HDMI*}]
79+
80+
81+
#**************************************************************
82+
# Set Clock Groups
83+
#**************************************************************
84+
85+
86+
87+
#**************************************************************
88+
# Set False Path
89+
#**************************************************************
90+
91+
# Separate VGA output video pixel clock from the main system clock and CLK_In 50Mhz clock.
92+
set_false_path -from [get_clocks {u_vpg|u_pll|altera_pll_i|general[0].gpll~PLL_OUTPUT_COUNTER|divclk}] -to [get_clocks {CLK_IN_50_vid}]
93+
set_false_path -from [get_clocks {u_vpg|u_pll|altera_pll_i|general[0].gpll~PLL_OUTPUT_COUNTER|divclk}] -to [get_clocks {*DDR3_PLL5*counter[4]*}]
94+
set_false_path -from [get_clocks {u_vpg|u_pll|altera_pll_i|general[0].gpll~PLL_OUTPUT_COUNTER|divclk}] -to [get_clocks {*DDR3_PLL5*counter[3]*}]
95+
set_false_path -from [get_clocks {*DDR3_PLL5*counter[4]*}] -to [get_clocks {u_vpg|u_pll|altera_pll_i|general[0].gpll~PLL_OUTPUT_COUNTER|divclk}]
96+
set_false_path -from [get_clocks {*DDR3_PLL5*counter[3]*}] -to [get_clocks {u_vpg|u_pll|altera_pll_i|general[0].gpll~PLL_OUTPUT_COUNTER|divclk}]
97+
98+
# Separate the fake generated I2C clock output from the CLK_IN 50 MHz source.
99+
set_false_path -from [get_clocks {CLK_IN_50}] -to [get_clocks {u_I2C_HDMI_Config|mI2C_CTRL_CLK|q}]
100+
set_false_path -from [get_clocks {*DDR3_PLL5*counter[4]*}] -to [get_clocks {u_I2C_HDMI_Config|mI2C_CTRL_CLK|q}]
101+
102+
# Optional: Separate the reset and low frequency inputs on the CLK_IN 50Mhz from the core.
103+
set_false_path -from [get_clocks {*DDR3_PLL5*counter[4]*}] -to [get_clocks {CLK_IN_50}]
104+
set_false_path -from [get_clocks {CLK_IN_50}] -to [get_clocks {*DDR3_PLL5*counter[4]*}]
105+
106+
#**************************************************************
107+
# Set Multicycle Path
108+
#**************************************************************
109+
110+
111+
112+
#**************************************************************
113+
# Set Maximum Delay
114+
#**************************************************************
115+
116+
117+
118+
#**************************************************************
119+
# Set Minimum Delay
120+
#**************************************************************
121+
122+
123+
124+
#**************************************************************
125+
# Set Input Transition
126+
#**************************************************************
127+
128+
129+
130+
#**************************************************************
131+
# Set Load
132+
#**************************************************************
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# -------------------------------------------------------------------------- #
2+
#
3+
# Copyright (C) 2020 Intel Corporation. All rights reserved.
4+
# Your use of Intel Corporation's design tools, logic functions
5+
# and other software and tools, and any partner logic
6+
# functions, and any output files from any of the foregoing
7+
# (including device programming or simulation files), and any
8+
# associated documentation or information are expressly subject
9+
# to the terms and conditions of the Intel Program License
10+
# Subscription Agreement, the Intel Quartus Prime License Agreement,
11+
# the Intel FPGA IP License Agreement, or other applicable license
12+
# agreement, including, without limitation, that your use is for
13+
# the sole purpose of programming logic devices manufactured by
14+
# Intel and sold by Intel or its authorized distributors. Please
15+
# refer to the applicable agreement for further details, at
16+
# https://fpgasoftware.intel.com/eula.
17+
#
18+
# -------------------------------------------------------------------------- #
19+
#
20+
# Quartus Prime
21+
# Version 20.1.1 Build 720 11/11/2020 SJ Lite Edition
22+
# Date created = 22:09:02 March 10, 2021
23+
#
24+
# -------------------------------------------------------------------------- #
25+
26+
QUARTUS_VERSION = "20.1"
27+
DATE = "22:09:02 March 10, 2021"
28+
29+
# Revisions
30+
31+
PROJECT_REVISION = "BrianHG_DDR3_CV_top"

0 commit comments

Comments
 (0)