OpenCores
URL https://opencores.org/ocsvn/adat_optical_feed_forward_receiver/adat_optical_feed_forward_receiver/trunk

Subversion Repositories adat_optical_feed_forward_receiver

[/] [adat_optical_feed_forward_receiver/] [web_uploads/] [ADAT_receiver.vhd] - Blame information for rev 6

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 6 root
library ieee;
2
use ieee.std_logic_1164.all;
3
library lpm;
4
use lpm.all;
5
 
6
entity mult12x8 is
7
 port(
8
  dataa : in std_logic_vector(11 downto 0);
9
  datab : in std_logic_vector(7 downto 0);
10
  result : out std_logic_vector (11 downto 0)
11
 );
12
end mult12x8;
13
 
14
architecture syn of mult12x8 is
15
 signal sub_wire0 : std_logic_vector(11 downto 0);
16
 component lpm_mult
17
  generic(
18
   lpm_hint     : string;
19
   lpm_representation : string;
20
   lpm_type     : string;
21
   lpm_widtha : natural;
22
   lpm_widthb : natural;
23
   lpm_widthp : natural;
24
   lpm_widths : natural
25
  );
26
  port(
27
   dataa : in std_logic_vector (11 downto 0);
28
   datab : in std_logic_vector (7 downto 0);
29
   result : out std_logic_vector (11 downto 0)
30
  );
31
 end component;
32
begin
33
 result <= sub_wire0(11 downto 0);
34
 lpm_mult_component : lpm_mult
35
 generic map (
36
  lpm_hint => "MAXIMIZE_SPEED=5",
37
  lpm_representation => "UNSIGNED",
38
  lpm_type => "LPM_MULT",
39
  lpm_widtha => 12,
40
  lpm_widthb => 8,
41
  lpm_widthp => 12,
42
  lpm_widths => 1
43
 )
44
 port map (
45
  dataa => dataa,
46
  datab => datab,
47
  result => sub_wire0
48
 );
49
end syn;
50
 
51
library ieee;
52
use ieee.std_logic_1164.all;
53
use ieee.std_logic_unsigned.all;
54
 
55
entity ADAT_receiver is
56
 port(
57
  m_clk : in std_logic;
58
  adat_in : in std_logic;
59
  adat_user : out std_logic_vector(3 downto 0); -- adat user bits
60
  adat_wordclock : out std_logic; -- adat wordclock out (approx 50% symmetry)
61
 
62
  bus_enable: in std_logic;
63
  bus_address: in std_logic_vector(2 downto 0);
64
  bus_data : out std_logic_vector(23 downto 0)
65
 );
66
end ADAT_receiver;
67
 
68
architecture behavioral of ADAT_receiver is
69
 signal adat_input_shift : std_logic_vector(1 downto 0);
70
 
71
 signal adat_edge_detect : std_logic;
72
 signal adat_edge_shift : std_logic_vector(1 downto 0);
73
 signal adat_edge_cur_time : std_logic_vector(9 downto 0) := (others=>'0');
74
 signal adat_edge_max_time : std_logic_vector(9 downto 0) := (others=>'0');
75
 signal wait_increase : std_logic_vector(15 downto 0);
76
 
77
 signal adat_inc_word_time : std_logic_vector(11 downto 0) := (others=>'0');
78
 signal adat_cur_word_time : std_logic_vector(11 downto 0) := (others=>'0');
79
 signal adat_sync_mask_time : std_logic_vector(8 downto 0) := (others=>'0');
80
 signal adat_sync_mask : std_logic := '0';
81
 signal adat_sync_mask_shift : std_logic_vector(1 downto 0) := (others=>'0');
82
 signal adat_bit_counter : std_logic_vector(7 downto 0) := (others=>'0');
83
 signal adat_bit_sample : std_logic_vector(11 downto 0) := (others=>'0');
84
 signal adat_bit_clk : std_logic;
85
 signal adat_data : std_logic_vector(1 downto 0);
86
 
87
 signal adat_data_shift : std_logic_vector(255 downto 0) := (others=>'1');
88
 
89
 signal audio_buffer_0 : std_logic_vector(23 downto 0);
90
 signal audio_buffer_1 : std_logic_vector(23 downto 0);
91
 signal audio_buffer_2 : std_logic_vector(23 downto 0);
92
 signal audio_buffer_3 : std_logic_vector(23 downto 0);
93
 signal audio_buffer_4 : std_logic_vector(23 downto 0);
94
 signal audio_buffer_5 : std_logic_vector(23 downto 0);
95
 signal audio_buffer_6 : std_logic_vector(23 downto 0);
96
 signal audio_buffer_7 : std_logic_vector(23 downto 0);
97
 
98
 component mult12x8
99
  port(
100
   dataa:in std_logic_vector(11 downto 0);
101
   datab:in std_logic_vector(7 downto 0);
102
   result:out std_logic_vector(11 downto 0)
103
  );
104
 end component;
105
begin
106
 
107
 shift_adat_input : process (m_clk)
108
 begin
109
  if m_clk'event and m_clk='1' then
110
   adat_input_shift <= adat_input_shift(0) & adat_in;
111
  end if;
112
 end process shift_adat_input;
113
 
114
 detect_adat_sync : process (m_clk)
115
 begin
116
  if m_clk'event and m_clk='1' then
117
   if (adat_input_shift="01") or (adat_input_shift="10") then
118
    adat_edge_detect <= '1';
119
    adat_edge_cur_time <= (others => '0');
120
   else
121
    adat_edge_cur_time <= adat_edge_cur_time + 1;
122
    adat_edge_detect <= '0';
123
    if adat_edge_cur_time > adat_edge_max_time then
124
     adat_edge_max_time <= adat_edge_cur_time;
125
     wait_increase <= (others => '0');
126
    else
127
     wait_increase <= wait_increase + 1;
128
     if wait_increase = 2**(wait_increase'length - 1) then
129
      adat_edge_max_time <= adat_edge_max_time - 1;
130
     end if;
131
    end if;
132
   end if;
133
  end if;
134
 end process detect_adat_sync;
135
 
136
 multiplier : mult12x8
137
 port map(
138
  dataa => adat_cur_word_time,
139
  datab => adat_bit_counter,
140
  result => adat_bit_sample
141
 );
142
 
143
 shift_adat_edge : process (m_clk)
144
 begin
145
  if m_clk'event and m_clk='1' then
146
   adat_edge_shift <= adat_edge_shift(0) & adat_edge_detect;
147
  end if;
148
 end process shift_adat_edge;
149
 
150
 mask_adat_edge : process (m_clk)
151
 begin
152
  if m_clk'event and m_clk='1' then
153
   adat_sync_mask_time <= adat_edge_max_time(adat_edge_max_time'left downto 1) + adat_edge_max_time(adat_edge_max_time'left downto 2);
154
   if adat_edge_cur_time <= adat_sync_mask_time then
155
    adat_sync_mask <= '1';
156
   else
157
    adat_sync_mask <= '0';
158
   end if;
159
  end if;
160
 end process mask_adat_edge;
161
 
162
  shift_adat_mask : process (m_clk)
163
 begin
164
  if m_clk'event and m_clk='1' then
165
   adat_sync_mask_shift <= adat_sync_mask_shift(0) & adat_sync_mask;
166
  end if;
167
 end process shift_adat_mask;
168
 
169
 detect_adat_bits : process (m_clk)
170
 begin
171
  if m_clk'event and m_clk='1' then
172
   adat_inc_word_time <= adat_inc_word_time + 1;
173
   if (adat_edge_detect='1') and (adat_sync_mask='0') then
174
    adat_cur_word_time <= adat_inc_word_time;
175
    adat_bit_counter <= (others=>'0'); -- set to bit 0 for first sample point
176
   end if;
177
   if adat_sync_mask_shift="01" then
178
    adat_inc_word_time <= (others => '0');
179
   end if;
180
   if adat_inc_word_time = adat_bit_sample then
181
    adat_bit_clk <= '1';
182
    adat_data <= adat_data(0) & adat_in;
183
    adat_bit_counter <= adat_bit_counter + 1;
184
   else
185
    adat_bit_clk <= '0';
186
   end if;
187
  end if;
188
 end process detect_adat_bits;
189
 
190
 shift_adat_data : process (adat_bit_clk)
191
 begin
192
  if adat_bit_clk'event and adat_bit_clk='1' then
193
   if (adat_data = "00") or (adat_data = "11") then
194
    adat_data_shift<=adat_data_shift(adat_data_shift'left-1 downto 0) & '0';
195
   else
196
    adat_data_shift<=adat_data_shift(adat_data_shift'left-1 downto 0) & '1';
197
   end if;
198
  end if;
199
 end process shift_adat_data;
200
 
201
 generate_wordclock : process (adat_bit_clk)
202
 begin
203
  if adat_bit_clk'event and adat_bit_clk='1' then
204
   if adat_bit_counter <= 127 then
205
    adat_wordclock <= '0';
206
   else
207
    adat_wordclock <= '1';
208
   end if;
209
  end if;
210
 end process generate_wordclock;
211
 
212
 align_adat_data : process (adat_bit_clk)
213
 begin
214
  if adat_bit_clk'event and adat_bit_clk='1' then
215
   if adat_data_shift(adat_data_shift'left downto adat_data_shift'left-9) = "0000000000" then
216
    adat_user<=adat_data_shift(adat_data_shift'left-11 downto adat_data_shift'left-14);
217
    audio_buffer_0<=adat_data_shift(adat_data_shift'left-16 downto adat_data_shift'left-19)&adat_data_shift(adat_data_shift'left-21 downto adat_data_shift'left-24)&adat_data_shift(adat_data_shift'left-26 downto adat_data_shift'left-29)&adat_data_shift(adat_data_shift'left-31 downto adat_data_shift'left-34)&adat_data_shift(adat_data_shift'left-36 downto adat_data_shift'left-39)&adat_data_shift(adat_data_shift'left-41 downto adat_data_shift'left-44);
218
    audio_buffer_1<=adat_data_shift(adat_data_shift'left-46 downto adat_data_shift'left-49)&adat_data_shift(adat_data_shift'left-51 downto adat_data_shift'left-54)&adat_data_shift(adat_data_shift'left-56 downto adat_data_shift'left-59)&adat_data_shift(adat_data_shift'left-61 downto adat_data_shift'left-64)&adat_data_shift(adat_data_shift'left-66 downto adat_data_shift'left-69)&adat_data_shift(adat_data_shift'left-71 downto adat_data_shift'left-74);
219
    audio_buffer_2<=adat_data_shift(adat_data_shift'left-76 downto adat_data_shift'left-79)&adat_data_shift(adat_data_shift'left-81 downto adat_data_shift'left-84)&adat_data_shift(adat_data_shift'left-86 downto adat_data_shift'left-89)&adat_data_shift(adat_data_shift'left-91 downto adat_data_shift'left-94)&adat_data_shift(adat_data_shift'left-96 downto adat_data_shift'left-99)&adat_data_shift(adat_data_shift'left-101 downto adat_data_shift'left-104);
220
    audio_buffer_3<=adat_data_shift(adat_data_shift'left-106 downto adat_data_shift'left-109)&adat_data_shift(adat_data_shift'left-111 downto adat_data_shift'left-114)&adat_data_shift(adat_data_shift'left-116 downto adat_data_shift'left-119)&adat_data_shift(adat_data_shift'left-121 downto adat_data_shift'left-124)&adat_data_shift(adat_data_shift'left-126 downto adat_data_shift'left-129)&adat_data_shift(adat_data_shift'left-131 downto adat_data_shift'left-134);
221
    audio_buffer_4<=adat_data_shift(adat_data_shift'left-136 downto adat_data_shift'left-139)&adat_data_shift(adat_data_shift'left-141 downto adat_data_shift'left-144)&adat_data_shift(adat_data_shift'left-146 downto adat_data_shift'left-149)&adat_data_shift(adat_data_shift'left-151 downto adat_data_shift'left-154)&adat_data_shift(adat_data_shift'left-156 downto adat_data_shift'left-159)&adat_data_shift(adat_data_shift'left-161 downto adat_data_shift'left-164);
222
    audio_buffer_5<=adat_data_shift(adat_data_shift'left-166 downto adat_data_shift'left-169)&adat_data_shift(adat_data_shift'left-171 downto adat_data_shift'left-174)&adat_data_shift(adat_data_shift'left-176 downto adat_data_shift'left-179)&adat_data_shift(adat_data_shift'left-181 downto adat_data_shift'left-184)&adat_data_shift(adat_data_shift'left-186 downto adat_data_shift'left-189)&adat_data_shift(adat_data_shift'left-191 downto adat_data_shift'left-194);
223
    audio_buffer_6<=adat_data_shift(adat_data_shift'left-196 downto adat_data_shift'left-199)&adat_data_shift(adat_data_shift'left-201 downto adat_data_shift'left-204)&adat_data_shift(adat_data_shift'left-206 downto adat_data_shift'left-209)&adat_data_shift(adat_data_shift'left-211 downto adat_data_shift'left-214)&adat_data_shift(adat_data_shift'left-216 downto adat_data_shift'left-219)&adat_data_shift(adat_data_shift'left-221 downto adat_data_shift'left-224);
224
    audio_buffer_7<=adat_data_shift(adat_data_shift'left-226 downto adat_data_shift'left-229)&adat_data_shift(adat_data_shift'left-231 downto adat_data_shift'left-234)&adat_data_shift(adat_data_shift'left-236 downto adat_data_shift'left-239)&adat_data_shift(adat_data_shift'left-241 downto adat_data_shift'left-244)&adat_data_shift(adat_data_shift'left-246 downto adat_data_shift'left-249)&adat_data_shift(adat_data_shift'left-251 downto adat_data_shift'left-254);
225
   end if;
226
  end if;
227
 end process align_adat_data;
228
 
229
 bus_controller : process (bus_enable)
230
 begin
231
  if bus_enable='0' then
232
   if bus_address="000" then
233
    bus_data<=audio_buffer_0;
234
   end if;
235
   if bus_address="001" then
236
    bus_data<=audio_buffer_1;
237
   end if;
238
   if bus_address="010" then
239
    bus_data<=audio_buffer_2;
240
   end if;
241
   if bus_address="011" then
242
    bus_data<=audio_buffer_3;
243
   end if;
244
   if bus_address="100" then
245
    bus_data<=audio_buffer_4;
246
   end if;
247
   if bus_address="101" then
248
    bus_data<=audio_buffer_5;
249
   end if;
250
   if bus_address="110" then
251
    bus_data<=audio_buffer_6;
252
   end if;
253
   if bus_address="111" then
254
    bus_data<=audio_buffer_7;
255
   end if;
256
  else
257
   bus_data<="ZZZZZZZZZZZZZZZZZZZZZZZZ";
258
  end if;
259
 end process bus_controller;
260
 
261
end behavioral;

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.