-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathCicInterface.vhd
76 lines (59 loc) · 1.78 KB
/
CicInterface.vhd
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
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.NUMERIC_STD.ALL;
entity CicInterface is
port (
CLK_I : in std_logic;
RST_I : in std_logic;
START_I : in std_logic;
DATA_I : in std_logic;
DATA_O : out std_logic;
BUSY_O : out std_logic;
CIC_DCLK_O : out std_logic;
CIC_DATA_I : in std_logic;
CIC_DATA_O : out std_logic
);
end entity CicInterface;
architecture Behavioral of CicInterface is
constant LOW_TIME : unsigned(11 downto 0) := to_unsigned(1064, 12);
constant HIGH_TIME : unsigned(11 downto 0) := to_unsigned(1330, 12);
signal bitTime : unsigned(11 downto 0);
signal ifState : std_logic;
signal data_in : std_logic;
signal cic_dclk : std_logic;
begin
DATA_O <= data_in;
CIC_DCLK_O <= cic_dclk;
BUSY_O <= '1' when (ifState = '1') or (START_I = '1') else '0';
process (CLK_I)
begin
if rising_edge(CLK_I) then
if RST_I = '1' then
ifState <= '0';
CIC_DATA_O <= '1';
cic_dclk <= '1';
else
if ifState = '0' then
CIC_DATA_O <= '1';
cic_dclk <= '1';
if START_I = '1' then
CIC_DATA_O <= DATA_I;
bitTime <= LOW_TIME + HIGH_TIME - 1;
ifState <= '1';
cic_dclk <= '0';
end if;
else
bitTime <= bitTime - 1;
if bitTime = HIGH_TIME then
cic_dclk <= '1';
CIC_DATA_O <= '1';
data_in <= CIC_DATA_I;
end if;
if bitTime = 0 then
ifState <= '0';
end if;
end if;
end if;
end if;
end process;
end Behavioral;