1
|
----------------------------------------------------------------------------------
|
2
|
-- Company: ASTM/OmegaTi
|
3
|
-- Engineer:Michele Canepa
|
4
|
-- Module Name:acq_eng_seq_top.vhd
|
5
|
-- Arch: Behavioral
|
6
|
|
7
|
-- Acquisition Engine, top module, suitable to interface PulSAR family ADC's from
|
8
|
-- Analog Devices. Includes a Block RAM to store the data coming from the ADC, the
|
9
|
-- ADC interface, and the Address Generator.
|
10
|
|
11
|
-- Done signal from ADC interface and write enable has a clock cycle latency, in order
|
12
|
-- to let the address increment after writing on the RAM.
|
13
|
----------------------------------------------------------------------------------
|
14
|
library IEEE;
|
15
|
use IEEE.STD_LOGIC_1164.ALL;
|
16
|
|
17
|
-- Uncomment the following library declaration if instantiating
|
18
|
-- any Xilinx primitives in this code.
|
19
|
library UNISIM;
|
20
|
use UNISIM.VComponents.all;
|
21
|
|
22
|
entity acq_eng_seq_top is
|
23
|
port(
|
24
|
-- SPI ADC Interface Signals
|
25
|
o_sclk: out std_logic;
|
26
|
i_miso: in std_logic;
|
27
|
i_busy: in std_logic;
|
28
|
-- Emif Clock
|
29
|
ema_clk: in std_logic;
|
30
|
-- To CPU Interrupt Lines: end of frame signals
|
31
|
o_eofa : out std_logic;
|
32
|
o_eofb : out std_logic;
|
33
|
--From Acq Controller
|
34
|
i_framedepth: in std_logic_vector(2 downto 0);
|
35
|
i_rst: in std_logic;
|
36
|
i_cs: in std_logic;
|
37
|
-- Memory Interface Signals
|
38
|
i_addrb : in std_logic_vector(9 downto 0);
|
39
|
i_conv: in std_logic;
|
40
|
o_datab : out std_logic_vector(15 downto 0);
|
41
|
done: out std_logic;
|
42
|
shift_en: out std_logic-- Debug signal
|
43
|
);
|
44
|
|
45
|
end acq_eng_seq_top;
|
46
|
|
47
|
architecture Behavioral of acq_eng_seq_top is
|
48
|
|
49
|
component spi_core_seq is
|
50
|
Port ( CLOCK : in STD_LOGIC;
|
51
|
RESET : in STD_LOGIC;
|
52
|
MISO : in STD_LOGIC;
|
53
|
SCLK : out STD_LOGIC;
|
54
|
PARALLEL_OUT : out STD_LOGIC_VECTOR(15 downto 0);
|
55
|
DONE: out std_logic;
|
56
|
SHIFT_EN: out std_logic;-- Debug signal
|
57
|
CONV_INPUT: in std_logic);
|
58
|
end component;
|
59
|
|
60
|
component spi_addrgen is
|
61
|
port ( clk: in std_logic;
|
62
|
done : in std_logic;
|
63
|
rst: in std_logic;
|
64
|
eofa : out std_logic;
|
65
|
eofb : out std_logic;
|
66
|
addr : out std_logic_vector (9 downto 0);
|
67
|
frame_depth: in std_logic_vector(2 downto 0)
|
68
|
);
|
69
|
end component;
|
70
|
|
71
|
component memory
|
72
|
port (
|
73
|
clka : in std_logic;
|
74
|
wea : in std_logic_vector(0 downto 0);
|
75
|
addra : in std_logic_vector(9 downto 0);
|
76
|
dina : in std_logic_vector(15 downto 0);
|
77
|
clkb : in std_logic;
|
78
|
addrb : in std_logic_vector(9 downto 0);
|
79
|
doutb : out std_logic_vector(15 downto 0)
|
80
|
);
|
81
|
end component;
|
82
|
|
83
|
signal t_done: std_logic_vector(0 downto 0):=(others=>'0');
|
84
|
signal t_wea: std_logic_vector(0 downto 0):=(others=>'0');
|
85
|
signal t_datarx:std_logic_vector(15 downto 0);
|
86
|
signal t_addra:std_logic_vector(9 downto 0);
|
87
|
signal t_dataout:std_logic_vector(15 downto 0);
|
88
|
signal eofa_r: std_logic:='0'; -- Per introdurre ritardo su end of frame
|
89
|
signal eofb_r: std_logic:='0';
|
90
|
|
91
|
begin
|
92
|
|
93
|
spi_core_inst: spi_core_seq port map(
|
94
|
CLOCK => ema_clk,
|
95
|
RESET=> i_rst,
|
96
|
MISO => i_miso,
|
97
|
SCLK => o_sclk,
|
98
|
PARALLEL_OUT=>t_datarx,
|
99
|
DONE=>t_done(0),
|
100
|
SHIFT_EN=>shift_en, -- Debug signal
|
101
|
CONV_INPUT=>i_conv
|
102
|
);
|
103
|
|
104
|
spi_addrgen_inst: spi_addrgen PORT MAP(
|
105
|
clk => ema_clk,
|
106
|
done => t_wea(0), -- One-cycle delayed after t_done.
|
107
|
rst => i_rst,
|
108
|
eofa => eofa_r,
|
109
|
eofb => eofb_r,
|
110
|
addr => t_addra,
|
111
|
frame_depth => i_framedepth
|
112
|
);
|
113
|
|
114
|
MEMORY_inst : MEMORY
|
115
|
PORT MAP (
|
116
|
clka => ema_clk,
|
117
|
wea => t_done,
|
118
|
addra => t_addra,
|
119
|
dina => t_datarx,
|
120
|
clkb => ema_clk,
|
121
|
addrb => i_addrb,
|
122
|
doutb => t_dataout
|
123
|
);
|
124
|
|
125
|
-- A flip-flop to delay t_wea signal in respect to t_done signal.
|
126
|
|
127
|
wea_dly: process(ema_clk,t_done)
|
128
|
begin
|
129
|
if rising_edge(ema_clk) then
|
130
|
t_wea<=t_done;
|
131
|
end if;
|
132
|
end process;
|
133
|
|
134
|
-- End of frame flip-flop to delay.
|
135
|
|
136
|
eof_dly: process(ema_clk, eofa_r, eofb_r)
|
137
|
begin
|
138
|
if rising_edge(ema_clk) then
|
139
|
o_eofa<=eofa_r;
|
140
|
o_eofb<=eofb_r;
|
141
|
end if;
|
142
|
end process;
|
143
|
|
144
|
-- This process synchronizes readings and implements chip select.
|
145
|
|
146
|
reg_read: process(ema_clk)
|
147
|
begin
|
148
|
if rising_edge(ema_clk) then
|
149
|
if i_cs = '1' then
|
150
|
o_datab <= t_dataout;
|
151
|
else
|
152
|
o_datab <= (others=>'0');
|
153
|
end if;
|
154
|
end if;
|
155
|
end process;
|
156
|
|
157
|
-- Done is a single signal, t_done is a vector(0 downto 0)
|
158
|
|
159
|
done<=t_done(0);
|
160
|
|
161
|
end Behavioral;
|
162
|
|