blob: 93eff8daf470c045d35b1bf945fe6bf891a77371 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
|
library IEEE;
use IEEE.STD_LOGIC_1164.all;
use IEEE.std_logic_unsigned.all;
use IEEE.numeric_std.all;
-- clk wants to be so that the small feature is 3 ticks
entity bmc_decoder is
port
(
n_reset : in std_logic;
clk : in std_logic;
spdif : in std_logic;
ready : out std_logic;
e : out std_logic;
d : out std_logic;
l : out std_logic
);
end bmc_decoder;
architecture rtl of bmc_decoder is
signal last_spdif : std_logic;
signal edge : std_logic;
signal ticks : std_logic_vector(7 downto 0);
signal last_was_one : std_logic;
signal ready_buf : std_logic;
begin
edge <= last_spdif xor spdif;
process(n_reset, clk, spdif, edge, ticks)
begin
if n_reset = '0' then
ticks <= (others => '0');
last_was_one <= '0';
ready_buf <= '0';
elsif rising_edge(clk) then
last_spdif <= spdif;
if edge = '1' then
ticks <= (others => '0');
if ticks < 1 then
ready_buf <= '1';
e <= '1';
d <= '1';
l <= '0';
last_was_one <= '0';
elsif ticks < 4 then
if last_was_one = '0' then
last_was_one <= '1';
ready_buf <= '1';
e <= '0';
d <= '1';
l <= '0';
else
last_was_one <= '0';
end if;
elsif ticks < 7 then
last_was_one <= '0';
ready_buf <= '1';
e <= '0';
l <= '0';
d <= '0';
elsif ticks < 10 then
last_was_one <= '0';
ready_buf <= '1';
e <= '0';
d <= '0';
l <= '1';
else
ready_buf <= '1';
e <= '1';
d <= '0';
l <= '1';
last_was_one <= '0';
end if;
else
ticks <= ticks + 1;
ready_buf <= '0';
end if;
end if;
end process;
ready <= ready_buf;
end rtl;
|