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

Subversion Repositories miniuart2

[/] [miniuart2/] [trunk/] [rtl/] [vhdl/] [Rxunit.vhd] - Blame information for rev 26

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 philippe
-------------------------------------------------------------------------------
2
-- Title      : UART
3
-- Project    : UART
4
-------------------------------------------------------------------------------
5
-- File        : Rxunit.vhd
6
-- Author      : Philippe CARTON 
7 15 philippe
--               (philippe.carton2@libertysurf.fr)
8
-- Organization:
9 2 philippe
-- Created     : 15/12/2001
10 17 philippe
-- Last update : 8/1/2003
11 2 philippe
-- Platform    : Foundation 3.1i
12 17 philippe
-- Simulators  : ModelSim 5.5b
13
-- Synthesizers: Xilinx Synthesis
14 2 philippe
-- Targets     : Xilinx Spartan
15
-- Dependency  : IEEE std_logic_1164
16
-------------------------------------------------------------------------------
17
-- Description: RxUnit is a serial to parallel unit Receiver.
18
-------------------------------------------------------------------------------
19
-- Copyright (c) notice
20
--    This core adheres to the GNU public license 
21
--
22
-------------------------------------------------------------------------------
23
-- Revisions       :
24
-- Revision Number :
25
-- Version         :
26
-- Date    :
27
-- Modifier        : name <email>
28
-- Description     :
29
--
30
------------------------------------------------------------------------------
31
library ieee;
32
   use ieee.std_logic_1164.all;
33
 
34
entity RxUnit is
35
  port (
36 17 philippe
     Clk    : in  std_logic;  -- system clock signal
37
     Reset  : in  std_logic;  -- Reset input
38
     Enable : in  std_logic;  -- Enable input
39 2 philippe
     ReadA  : in  Std_logic;  -- Async Read Received Byte
40 17 philippe
     RxD    : in  std_logic;  -- RS-232 data input
41
     RxAv   : out std_logic;  -- Byte available
42
     DataO  : out std_logic_vector(7 downto 0)); -- Byte received
43
end RxUnit;
44 2 philippe
 
45
architecture Behaviour of RxUnit is
46 17 philippe
  signal RReg    : std_logic_vector(7 downto 0); -- receive register  
47
  signal RRegL   : std_logic;                    -- Byte received
48 2 philippe
begin
49
  -- RxAv process
50
  RxAvProc : process(RRegL,Reset,ReadA)
51
  begin
52
     if ReadA = '1' or Reset = '1' then
53
        RxAv <= '0';  -- Negate RxAv when RReg read     
54
     elsif Rising_Edge(RRegL) then
55
        RxAv <= '1';  -- Assert RxAv when RReg written
56
     end if;
57
  end process;
58
 
59
  -- Rx Process
60
  RxProc : process(Clk,Reset,Enable,RxD,RReg)
61
  variable BitPos : INTEGER range 0 to 10;   -- Position of the bit in the frame
62
  variable SampleCnt : INTEGER range 0 to 3; -- Count from 0 to 3 in each bit 
63
  begin
64
     if Reset = '1' then -- Reset
65
        RRegL <= '0';
66 17 philippe
        BitPos := 0;
67 2 philippe
     elsif Rising_Edge(Clk) then
68
        if Enable = '1' then
69
           case BitPos is
70
              when 0 => -- idle
71
                 RRegL <= '0';
72
                 if RxD = '0' then -- Start Bit
73
                    SampleCnt := 0;
74
                    BitPos := 1;
75
                 end if;
76
              when 10 => -- Stop Bit
77
                 BitPos := 0;    -- next is idle
78
                 RRegL <= '1';   -- Indicate byte received
79
                 DataO <= RReg;  -- Store received byte
80
              when others =>
81 17 philippe
                 if (SampleCnt = 1 and BitPos >= 2) then -- Sample RxD on 1
82 2 philippe
                    RReg(BitPos-2) <= RxD; -- Deserialisation
83
                 end if;
84
                 if SampleCnt = 3 then -- Increment BitPos on 3
85 10 philippe
                    BitPos := BitPos + 1;
86 2 philippe
                 end if;
87 10 philippe
           end case;
88 17 philippe
           if SampleCnt = 3 then
89 10 philippe
              SampleCnt := 0;
90 17 philippe
           else
91 10 philippe
              sampleCnt := SampleCnt + 1;
92
           end if;
93
 
94 2 philippe
        end if;
95
     end if;
96
  end process;
97
end Behaviour;

powered by: WebSVN 2.1.0

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