-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRXCntrl.vhd
74 lines (61 loc) · 1.84 KB
/
RXCntrl.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
library ieee;
use ieee.std_logic_1164.all;
use ieee.Numeric_std.all;
entity RXCNTRL is
port( clk : in std_logic;
rst :in std_logic;
SerialIn : in std_logic;
baud_enable : in std_logic;
DataOut : out std_logic_vector(7 downto 0) := "00000000"
);
end entity;
architecture behave of RXCNTRL is
TYPE state is( IDLE, RCVD_START_BIT, RCVD_DATA, RCVD_STOP_BIT);
signal RX_State : state;
signal s :std_logic_vector(7 downto 0) := "00000000";
signal countbits : integer range 0 to 15;
-- variable s : std_logic_vector(3 downto 0) := "0000" ;
begin
process(baud_enable)
begin
if (rising_edge (baud_enable)) then
if(rst = '1')then
RX_State <= IDLE;
s <= "00000000";
DataOut <= "00000000";
countbits <= 0;
else
baud_en: case(RX_State) is
when IDLE =>
if(SerialIn = '1')then
RX_State <= IDLE;
s <= (others => '0');
else
--countbits <= 0;
RX_State <= RCVD_DATA;
end if;
-- when RCVD_START_BIT => countbits <= 0;
--
-- RX_State <= RCVD_DATA;
when RCVD_DATA => if(countbits = 8)then
countbits <= 0;
RX_STATE <= RCVD_STOP_BIT;
else
countbits <= countbits +1;
s <= (SerialIn & s(7 downto 1));
end if;
when RCVD_STOP_BIT => DataOut <= s;
RX_State <= IDLE;
when others => RX_State <= IDLE;
end case;
end if ;
end if ;
end process;
end behave;
-- if (rst='1') then
-- s <= "00000000";
-- else
-- s <= (SerialIn & s(7 downto 1));
-- end if;
-- DataOut <= s;
-- end if;