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

Subversion Repositories System68

[/] [System68/] [tags/] [arelease/] [vhdl/] [rxunit.vhd] - Blame information for rev 8

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 4 dilbert57
--===========================================================================--
2
--
3
--  S Y N T H E Z I A B L E    miniUART   C O R E
4
--
5
--  www.OpenCores.Org - January 2000
6
--  This core adheres to the GNU public license  
7
--
8
-- Design units   : miniUART core for the OCRP-1
9
--
10
-- File name      : RxUnit.vhd
11
--
12
-- Purpose        : Implements an miniUART device for communication purposes 
13
--                  between the OR1K processor and the Host computer through
14
--                  an RS-232 communication protocol.
15
--                  
16
-- Library        : uart_lib.vhd
17
--
18
-- Dependencies   : IEEE.Std_Logic_1164
19
--
20
--===========================================================================--
21
-------------------------------------------------------------------------------
22
-- Revision list
23
-- Version   Author                 Date                        Changes
24
--
25
-- 0.1      Ovidiu Lupas     15 January 2000                   New model
26
-- 2.0      Ovidiu Lupas     17 April   2000  samples counter cleared for bit 0
27
--        olupas@opencores.org
28
-------------------------------------------------------------------------------
29
-- Description    : Implements the receive unit of the miniUART core. Samples
30
--                  16 times the RxD line and retain the value in the middle of
31
--                  the time interval. 
32
-------------------------------------------------------------------------------
33
-- Entity for Receive Unit - 9600 baudrate                                  --
34
-------------------------------------------------------------------------------
35
library ieee;
36
   use ieee.std_logic_1164.all;
37
   use ieee.numeric_std.all;
38
 
39
-------------------------------------------------------------------------------
40
-- Receive unit
41
-------------------------------------------------------------------------------
42
entity RxUnit is
43
  port (
44
     Clk    : in  Std_Logic;  -- system clock signal
45
     Reset  : in  Std_Logic;  -- Reset input
46
     Enable : in  Std_Logic;  -- Enable input
47
     RxD    : in  Std_Logic;  -- RS-232 data input
48
     ReadD  : in  Std_Logic;  -- Read data signal
49
     FRErr  : out Std_Logic;  -- Status signal
50
     ORErr  : out Std_Logic;  -- Status signal
51
     DARdy  : out Std_Logic;  -- Status signal
52
     DataI  : out Std_Logic_Vector(7 downto 0));
53
end entity; --================== End of entity ==============================--
54
-------------------------------------------------------------------------------
55
-- Architecture for receive Unit
56
-------------------------------------------------------------------------------
57
architecture Behaviour of RxUnit is
58
  -----------------------------------------------------------------------------
59
  -- Signals
60
  -----------------------------------------------------------------------------
61
  signal Start     : Std_Logic;             -- Syncro signal
62
  signal tmpRxD    : Std_Logic;             -- RxD buffer
63
  signal tmpDRdy   : Std_Logic;             -- Data ready buffer
64
  signal outErr    : Std_Logic;             -- 
65
  signal frameErr  : Std_Logic;             -- 
66
  signal BitCnt    : Unsigned(3 downto 0);  -- 
67
  signal SampleCnt : Unsigned(3 downto 0);  -- samples on one bit counter
68
  signal ShtReg    : Std_Logic_Vector(7 downto 0);  --
69
  signal DOut      : Std_Logic_Vector(7 downto 0);  --
70
 
71
begin
72
  ---------------------------------------------------------------------
73
  -- Receiver process
74
  ---------------------------------------------------------------------
75
  RcvProc : process(Clk,Reset,Enable,RxD)
76
      constant CntOne : Unsigned(3 downto 0):="0001";
77
  begin
78
     if Clk'event and Clk='1' then
79
        if Reset = '1' then
80
           BitCnt <= "0000";
81
           SampleCnt <= "0000";
82
           Start <= '0';
83
           tmpDRdy <= '0';
84
           frameErr <= '0';
85
           outErr <= '0';
86
 
87
           ShtReg <= "00000000";  --
88
           DOut   <= "00000000";  --
89
        else
90
           if ReadD = '1' then
91
              tmpDRdy <= '0';      -- Data was read
92
           end if;
93
 
94
           if Enable = '1' then
95
              if Start = '0' then
96
                 if RxD = '0' then -- Start bit, 
97
                    SampleCnt <= SampleCnt + CntOne;
98
                    Start <= '1';
99
                 end if;
100
              else
101
                 if SampleCnt = "1000" then  -- reads the RxD line
102
                    tmpRxD <= RxD;
103
                    SampleCnt <= SampleCnt + CntOne;
104
                 elsif SampleCnt = "1111" then
105
                    case BitCnt is
106
                         when "0000" =>
107
                                if tmpRxD = '1' then -- Start Bit
108
                                   Start <= '0';
109
                                else
110
                                   BitCnt <= BitCnt + CntOne;
111
                                end if;
112
                                SampleCnt <= SampleCnt + CntOne;
113
                         when "1001" =>
114
                                if tmpRxD = '0' then  -- stop bit expected
115
                                   frameErr <= '1';
116
                                else
117
                                   frameErr <= '0';
118
                                end if;
119
 
120
                                if tmpDRdy = '1' then -- 
121
                                   outErr <= '1';
122
                                else
123
                                   outErr <= '0';
124
                                end if;
125
 
126
                                tmpDRdy <= '1';
127
                                DOut <= ShtReg;
128
                                BitCnt <= "0000";
129
                                Start <= '0';
130
                         when others =>
131
                                BitCnt <= BitCnt + CntOne;
132
                                SampleCnt <= SampleCnt + CntOne;
133
                                ShtReg <= tmpRxD & ShtReg(7 downto 1);
134
                    end case;
135
                 else
136
                    SampleCnt <= SampleCnt + CntOne;
137
                 end if;
138
              end if;
139
           end if;
140
        end if;
141
     end if;
142
  end process;
143
 
144
  DARdy <= tmpDRdy;
145
  DataI <= DOut;
146
  FRErr <= frameErr;
147
  ORErr <= outErr;
148
 
149
end Behaviour; --==================== End of architecture ====================--

powered by: WebSVN 2.1.0

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