Project

General

Profile

RE: uPP receiving problem » top.vhd

Silvano Bertoldo, 07/21/2014 11:34 AM

 
1
----------------------------------------------------------------------------------
2
-- Company:        Envisens Technologies
3
-- Engineer:       OR
4
-- 
5
-- Create Date:    11:55:51 03/31/2014 
6
-- Design Name:    FPGA to MityDSP interface
7
-- Module Name:    top - Behavioral 
8
-- Project Name:   FIFO2
9
-- Target Devices: Spartan6
10
-- Tool versions:  14.3
11
-- Description:    Debug code for MITY DEV board
12
--
13
-- Dependencies:   Cloccoman, FIFO8192depth_11wordsize,scaloclock
14
--
15
-- Revision: 
16
-- Revision 0.01 - File Created
17
-- Additional Comments: 
18
--
19
----------------------------------------------------------------------------------
20

    
21
-------------------------------------------------------------
22
--------------- Start of SYNTHESIS code ---------------------
23
-------------------------------------------------------------
24

    
25
library IEEE;
26
use IEEE.STD_LOGIC_1164.ALL;
27
use IEEE.STD_LOGIC_ARITH.ALL;
28
use IEEE.STD_LOGIC_UNSIGNED.ALL;
29

    
30
-- Uncomment the following library declaration if using
31
-- arithmetic functions with Signed or Unsigned values
32
use IEEE.NUMERIC_STD.ALL;
33

    
34
-- Uncomment the following library declaration if instantiating
35
-- any Xilinx primitives in this code.
36
library UNISIM;
37
use UNISIM.VComponents.all;
38
LIBRARY XilinxCoreLib;
39

    
40

    
41
entity top is
42
    Port ( --ADC_INPUT        : in  STD_LOGIC_VECTOR (11 downto 0);   	-- These are the input from ADC
43
           ADC_CLOCK        : in  STD_LOGIC;                        	-- Clock from AD9360 clock generator
44
			  --RAMP_END         : in  STD_LOGIC;                        	-- End of Chirp signal from ADF4158 PLL Chirp generator 
45
			  FPGA_to_uPP_DATA : out STD_LOGIC_VECTOR (11 downto 0); 	-- These are the output from FPGA to OMAPL138 (uPP bus)
46
			  FPGA_to_uPP_ENBL : out STD_LOGIC;									-- uPP Channel A Enable Signal
47
			  uPP_to_FPGA_WAIT : in  STD_LOGIC;								  	-- uPP Channel A Wait Signal	
48
			  FPGA_to_uPP_CLK  : out STD_LOGIC;                       	-- uPP Channel A Clock
49
			  FPGA_to_uPP_START: out STD_LOGIC;							  		-- uPP Channel A Start Signal
50
			  SINE_GEN_BIT_TEST: out STD_LOGIC;									-- a simple test on MSB of sine generator
51
			  FPGA_OUT_CLK     : out STD_LOGIC);							  		-- Debug signal (just the outputted clock)
52
			  --LED_Ports        : out std_logic_vector(3 downto 0):="0000");  	-- LED ports
53
end top; 			 
54

    
55
architecture Behavioral of top is
56

    
57
----- Components for ADC (ADS 9224) debug ---------
58
-- Integrated CONtroller
59
component icon
60
  PORT (
61
    CONTROL0 : INOUT STD_LOGIC_VECTOR(35 DOWNTO 0));
62

    
63
end component;
64

    
65
-- Integrated Logic Analyzer
66
component ILA
67
  PORT (
68
    CONTROL : INOUT STD_LOGIC_VECTOR(35 DOWNTO 0);
69
    CLK : IN STD_LOGIC;
70
    DATA : IN STD_LOGIC_VECTOR(11 DOWNTO 0);
71
    TRIG0 : IN STD_LOGIC_VECTOR(0 TO 0));
72

    
73
end component;
74
----------------------------------------------------
75

    
76
------ For uPP debugging purpose ------------------
77
-- Component Sine generator declaration
78
component Sine_generator
79
  PORT (
80
	    aclk : IN STD_LOGIC;
81
       aclken : IN STD_LOGIC;
82
       aresetn : IN STD_LOGIC;
83
       m_axis_data_tvalid : OUT STD_LOGIC;
84
       m_axis_data_tdata : OUT STD_LOGIC_VECTOR(15 DOWNTO 0)
85
		 );
86
end component;
87
----------------------------------------------------
88

    
89
-- Component Core declaration (DCM module)
90
component core
91
port
92
 (-- Clock in ports
93
  CLK_IN1           : in     std_logic;
94
  -- Clock out ports
95
  CLK_OUT1          : out    std_logic;
96
  CLK_OUT2          : out    std_logic;
97
  ADC_CLK_OUT	     : out    std_logic;
98
   -- Status and control signals
99
  RESET             : in     std_logic;
100
  INPUT_CLK_STOPPED : out    std_logic;
101
  LOCKED            : out    std_logic
102
  );
103
 end component;
104
 
105
-- Component Scale declaration (A simple clock divider) 
106
component scale_clock
107
 port 
108
 (
109
    clk_20Mhz : in  std_logic;
110
    rst       : in  std_logic;
111
	 clk_1Hz   : out std_logic;
112
	 clk_2Hz   : out std_logic
113
  );
114
end component;
115

    
116
---- Component FIFO declaration 
117
component fifo
118
  port (
119
    rst : IN STD_LOGIC;
120
    wr_clk : IN STD_LOGIC;
121
    rd_clk : IN STD_LOGIC;
122
    din : IN STD_LOGIC_VECTOR(11 DOWNTO 0);
123
    wr_en : IN STD_LOGIC;
124
    rd_en : IN STD_LOGIC;
125
    dout : OUT STD_LOGIC_VECTOR(11 DOWNTO 0);
126
    full : OUT STD_LOGIC;
127
    almost_full : OUT STD_LOGIC;
128
    wr_ack : OUT STD_LOGIC;
129
    overflow : OUT STD_LOGIC;
130
    empty : OUT STD_LOGIC;
131
    almost_empty : OUT STD_LOGIC;
132
    valid : OUT STD_LOGIC;
133
    underflow : OUT STD_LOGIC;
134
    rd_data_count : OUT STD_LOGIC_VECTOR(9 DOWNTO 0);
135
    wr_data_count : OUT STD_LOGIC_VECTOR(9 DOWNTO 0)
136
  );
137
end component;
138

    
139
-- Signals
140
-- DCM signals
141
signal INPUT_CLK					: std_logic;                 
142
signal clk_out1 						: std_logic;                 
143
signal DCM_LOCKED_STATUS 			: std_logic; 			-- Asserted when DCM is LOCKED					 		
144
signal DCM_INPUT_RESET				: std_logic :='1';	-- Reset input of DCM module
145
signal DCM_INPUT_CLK_STATUS 		: std_logic;			-- DCM CLOCK input status
146
signal FPGA_to_uPP_ENBL_sig		: std_logic;			-- FPGA send enable signal to uPP
147

    
148
-- Auziliary signals
149
signal my_clk_output_buffered_neg : std_logic;  					-- my_clock_output out of phase
150
signal my_clk_output_buffered_neg2 : std_logic;  					-- my_clock_output out of phase
151
signal my_ODDR_out				: std_logic;							-- my_clock_output outputted from ODDR2 component
152
signal my_ODDR_out2				: std_logic;							-- my_clock_output outputted from ODDR2 component
153
signal BUFFER_CLK					: std_logic;
154
signal DOUBLE_CLK					: std_logic;
155

    
156
-- Sine generator signals
157
signal m_axis_data_tvalid:    std_logic;
158
signal m_axis_data_tdata:		std_logic_vector(15 downto 0);
159
signal aclken:						std_logic:='1';
160
signal aresetn:					std_logic:='1';
161

    
162

    
163

    
164

    
165
begin
166

    
167

    
168
-------------------- Sine_generator port instantiation ---------------
169
-- A sine generator for uPP debug purposes
170
--Sine_gen : Sine_generator
171
--  PORT MAP (
172
--    aclk => FIFO_WR_CLK,
173
--    aclken => aclken,
174
--    aresetn => aresetn,
175
--    m_axis_data_tvalid => m_axis_data_tvalid,
176
--    m_axis_data_tdata => m_axis_data_tdata
177
--  );
178
  
179
  -- m_axis_data_tdata is a 15 bits, but only 11   bits are used.
180
  -- Prior to assign them to output bus, truncates it.
181
  FPGA_to_uPP_DATA <= m_axis_data_tdata(11 downto 0);
182
  m_axis_data_tdata(0)<='1';m_axis_data_tdata(1)<='1';m_axis_data_tdata(2)<='1';
183
  m_axis_data_tdata(3)<='1';m_axis_data_tdata(4)<='1';m_axis_data_tdata(5)<='1';
184
  m_axis_data_tdata(6)<='1';m_axis_data_tdata(7)<='1';m_axis_data_tdata(8)<='1';
185
  m_axis_data_tdata(9)<='1';m_axis_data_tdata(10)<='1';m_axis_data_tdata(11)<='1';
186
  SINE_GEN_BIT_TEST <=m_axis_data_tdata(0);
187
-----------------------------------------------------------------------
188

    
189
----------------------------------------------------------------------	 
190
-- Component "cloccloman" of type "core" instantiation and mapping
191
-- It is used for clock management
192
cloccoman : core
193
  port map
194
   (-- Clock in ports
195
    CLK_IN1 => ADC_CLOCK,
196
    -- Clock out ports
197
    CLK_OUT1 => DOUBLE_CLK,  -- This is FIFO Read Clock (ADC_INPUT x 2)
198
	 CLK_OUT2 => BUFFER_CLK,  -- This is FIFO Write Clock (ADC_INPUT x 1)
199
	 ADC_CLK_OUT => INPUT_CLK,   -- This is a reply of ADC_CLOCK
200
	 RESET 	 => DCM_INPUT_RESET,
201
	 INPUT_CLK_STOPPED => DCM_INPUT_CLK_STATUS,
202
    LOCKED 	 => DCM_LOCKED_STATUS
203
    );
204

    
205
DCM_reset_management: process(INPUT_CLK,DCM_INPUT_RESET,DCM_INPUT_CLK_STATUS)
206
variable counter : integer range 0 to 6600000:=0;
207
constant ONE_SEC_CLOCK_TICKS : integer := 6600000; 
208
begin 
209
 
210
 if DCM_INPUT_RESET = '0' then
211
         counter   :=  0;
212
 elsif rising_edge(INPUT_CLK) then               -- Hold Reset to 1 for 1 sec in order
213
		if counter = ONE_SEC_CLOCK_TICKS then      -- to reset DCM and acquire LOCK
214
			counter := 0;
215
			DCM_INPUT_RESET <= '0';
216
		else
217
			counter := counter + 1;   
218
		 end if;
219
   end if;
220
	if DCM_INPUT_CLK_STATUS ='1' then -- Input clock fail: Hold DCM in RESET
221
	DCM_INPUT_RESET <= '1';
222
	counter   :=  0;
223
 end if;
224
end process DCM_reset_management;
225

    
226

    
227
FPGA_to_uPP_START <= '1';
228
FPGA_to_uPP_ENBL_sig <= '1';
229
FPGA_to_uPP_ENBL <= FPGA_to_uPP_ENBL_sig;
230

    
231
-----------------------------------------------------------------------------------------
232
-- uPP clock output (From FIFO_RD_CLK)
233

    
234
-- This is the negated version of INPUT_CLK, serves as input of ODDR2 component
235
my_clk_output_buffered_neg<= not DOUBLE_CLK;
236
--
237
-- ODDR2 component: used in order to output a clock (just used for debug)
238
ODDR2_inst : ODDR2
239
generic map(
240
DDR_ALIGNMENT => "NONE", -- Sets output alignment to "NONE", "C0", "C1"
241
INIT => '0', -- Sets initial state of the Q output to '0' or '1'
242
SRTYPE => "SYNC") -- Specifies "SYNC" or "ASYNC" set/reset
243
port map (
244
Q => my_ODDR_out, -- 1-bit output data
245
C0 => DOUBLE_CLK, -- 1-bit clock input
246
C1 => my_clk_output_buffered_neg, -- 1-bit clock input
247
CE => '1', -- 1-bit clock enable input
248
D0 => '1', -- 1-bit data input (associated with C0)
249
D1 => '0', -- 1-bit data input (associated with C1)
250
R => '0', -- 1-bit reset input
251
S => '0' -- 1-bit set input
252
);
253

    
254
-- An output buffer to drive the clock out to the FPGA pin 
255
OBUF_inst : OBUF
256
generic map (
257
DRIVE => 12,
258
IOSTANDARD => "LVCMOS33",
259
SLEW => "SLOW")
260
port map (
261
O => FPGA_to_uPP_CLK, -- Buffer output (connect directly to top-level port)
262
I => my_ODDR_out -- Buffer input
263
);
264
-------------------------------------------------------------------------------------------
265

    
266
-- Test clock
267

    
268
---- This is the negated version of INPUT_CLK, serves as input of ODDR2 component
269
--my_clk_output_buffered_neg2<= not BUFFER_CLK;
270
----
271
---- ODDR2 component: used in order to output a clock (just used for debug)
272
--ODDR2_inst2 : ODDR2
273
--generic map(
274
--DDR_ALIGNMENT => "NONE", -- Sets output alignment to "NONE", "C0", "C1"
275
--INIT => '0', -- Sets initial state of the Q output to '0' or '1'
276
--SRTYPE => "SYNC") -- Specifies "SYNC" or "ASYNC" set/reset
277
--port map (
278
--Q => my_ODDR_out2, -- 1-bit output data
279
--C0 => BUFFER_CLK, -- 1-bit clock input
280
--C1 => my_clk_output_buffered_neg2, -- 1-bit clock input
281
--CE => '1', -- 1-bit clock enable input
282
--D0 => '1', -- 1-bit data input (associated with C0)
283
--D1 => '0', -- 1-bit data input (associated with C1)
284
--R => '0', -- 1-bit reset input
285
--S => '0' -- 1-bit set input
286
--);
287
--
288
---- An output buffer to drive the clock out to the FPGA pin 
289
--OBUF_inst2 : OBUF
290
--generic map (
291
--DRIVE => 12,
292
--IOSTANDARD => "LVCMOS33",
293
--SLEW => "SLOW")
294
--port map (
295
--O => SINE_GEN_BIT_TEST, -- Buffer output (connect directly to top-level port)
296
--I => my_ODDR_out2 -- Buffer input
297
--);
298

    
299

    
300
end Behavioral;
301
-------------------------------------------------------------
302
--------------- End of SYNTHESIS code -----------------------
303
-------------------------------------------------------------
304

    
305

    
(6-6/6) Go to top
Add picture from clipboard (Maximum size: 1 GB)