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

Subversion Repositories scarts

[/] [scarts/] [trunk/] [processor/] [VHDL/] [ext_modules/] [ext_miniUART/] [pkg_miniUART.vhd] - Blame information for rev 3

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 3 jlechner
-----------------------------------------------------------------------
2
-- This file is part of SCARTS.
3
-- 
4
-- SCARTS is free software: you can redistribute it and/or modify
5
-- it under the terms of the GNU General Public License as published by
6
-- the Free Software Foundation, either version 3 of the License, or
7
-- (at your option) any later version.
8
-- 
9
-- SCARTS is distributed in the hope that it will be useful,
10
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
11
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
-- GNU General Public License for more details.
13
-- 
14
-- You should have received a copy of the GNU General Public License
15
-- along with SCARTS.  If not, see <http://www.gnu.org/licenses/>.
16
-----------------------------------------------------------------------
17
 
18
 
19
-------------------------------------------------------------------------------
20
-- Title      : Extension Module: miniUART
21
-- Project    : HW/SW-Codesign
22
-------------------------------------------------------------------------------
23
-- File       : ext_miniUART.vhd
24
-- Author     : Roman Seiger
25
-- Company    : TU Wien - Institut für Technische Informatik
26
-- Created    : 2005-03-10
27
-- Last update: 2007-05-28
28
-------------------------------------------------------------------------------
29
 
30
----------------------------------------------------------------------------------
31
-- LIBRARY
32
----------------------------------------------------------------------------------
33
LIBRARY IEEE;
34
use IEEE.std_logic_1164.all;
35
use work.pkg_basic.all;
36
-- use work.io.all;
37
 
38
----------------------------------------------------------------------------------
39
-- PACKAGE
40
----------------------------------------------------------------------------------
41
package pkg_miniUART is
42
 
43
  constant DATA_W        : integer := 16;
44
  constant EXTREG_S      : integer := 8;
45
 
46
  constant EXT_ACT : std_logic := '1';
47
 
48
-------------------------------------------------------------------------------
49
-------------------------------------------------------------------------------
50
--                             KONSTANTEN
51
-------------------------------------------------------------------------------  
52
-------------------------------------------------------------------------------
53
 
54
  -- globale Konstanten TODO: nur für einzelne Tests!
55
--constant EXT_ACT         : std_logic := '1';
56
  constant OUTD_ACT : std_logic := '1';  -- Output Disable
57
  constant FAILSAFE : std_logic := '1';  -- Failsafestate
58
 
59
--  constant MINIUART_BASE : integer := 51;  --TODO: richtige BaseAddr herausfinden!!!
60
--  constant MINIUART_INTVEC : std_logic_vector(16-1 downto 0) := (others => '0');
61
 
62
  -- Register allgemein
63
--   constant DATA0        : integer := 2;
64
--   constant DATA1        : integer := 3;
65
--   constant DATA2        : integer := 4;
66
--   constant DATA3        : integer := 5;
67
--   constant DATA4        : integer := 6;
68
--   constant DATA5        : integer := 7;
69
  constant MSGREG_LOW   : integer := 6;--DATA2;   -- Message register
70
  constant MSGREG_HIGH  : integer := 7;--DATA2;   -- Message register
71
  constant UBRSREG_LOW  : integer := 4;--DATA5;  -- UART Baud Rate Selection Register
72
  constant UBRSREG_HIGH : integer := 5;--DATA5;  -- UART Baud Rate Selection Register
73
 
74
  constant STATUSREG_CUST      : integer := 1;
75
  constant CONFIGREG_CUST      : integer := 3;
76
  -- Statusregister
77
--constant EXTSTATUS    : integer := 0;
78
--  constant EXTSTATUS_CUST    : integer := 1;
79
  constant STA_TRANSERR  : integer := 6;--14;
80
  constant STA_PARERR    : integer := 5;--13;f
81
  constant STA_EVF       : integer := 4;--12;
82
  constant STA_OVF       : integer := 3;--11;
83
  constant STA_RBR       : integer := 2;--10;
84
  constant STA_TBR       : integer := 1;--9;     
85
--constant ST_LOOR      : integer := 7;
86
--constant ST_FSS       : integer := 4;
87
--constant ST_BUSY      : integer := 3;
88
--constant ST_ERR       : integer := 2;
89
--constant ST_RDY       : integer := 1;
90
--constant ST_INT       : integer := 0;
91
 
92
  -- Configregister
93
--constant EXTCONFIG      : integer := 1;
94
--constant EXTCONF_LOOW    : integer := 7;
95
--constant EXTCONF_EFSS    : integer := 4;
96
constant EXTCONF_OUTD    : integer := 3;
97
--constant EXTCONF_SRES    : integer := 2;
98
--constant EXTCONF_ID      : integer := 1;
99
--constant EXTCONF_INTA    : integer := 0;
100
 
101
  -- UARTConfigregister
102
  constant EXTUARTCONF         : integer := CONFIGREG_CUST;--4; --DATA0;
103
  constant EXTCONF_PARENA      : integer := 7;--15;
104
  constant EXTCONF_PARODD      : integer := 6;--14;
105
  constant EXTCONF_STOP        : integer := 5;--13;
106
  constant EXTCONF_TRCTRL      : integer := 4;--12;
107
  constant EXTCONF_MSGL_H      : integer := 3;--11;
108
  constant EXTCONF_MSGL_L      : integer := 0;--8;
109
 
110
  -- Commandregister
111
  constant EXTCMD          : integer := 8;--DATA1;  
112
  constant EXTCMD_ERRI    : integer := 7;
113
  constant EXTCMD_EI      : integer := 6;
114
  constant EXTCMD_ASA_H   : integer := 5;
115
  constant EXTCMD_ASA_L   : integer := 3;
116
  constant EXTCMD_EVS_H   : integer := 2;
117
  constant EXTCMD_EVS_L   : integer := 1;
118
 
119
  -- Config & Statusbits
120
  constant PARITY_ENABLE : std_logic := '1';  -- Parity enabled
121
  constant SECOND_STOPBIT : std_logic := '1';  -- Zweites Stopbit enabled
122
  constant RB_READY : std_logic := '1';  -- Receive Buffer Ready
123
  constant TB_READY : std_logic := '1';  -- Transmit Buffer Ready
124
  constant FRAME_ERROR : std_logic := '1';  -- !!!ACHTUNG: FE ist immer 1!!!
125
  constant PARITY_ERROR : std_logic := '1';  -- Parity Error
126
  constant OVERFLOW : std_logic := '1';  -- Overflow occured
127
  constant TRCTRL_ENA : std_logic := '1';  -- Error Control enabled
128
 
129
 
130
  -- Transmitter
131
  constant TRANS_COMP : std_logic := '1';  -- Transmission Complete
132
 
133
  -- Receiver
134
  constant RECEIVER_ENABLED : std_logic := '1';  -- !!!ACHTUNG: muss 1 sein!!!
135
  constant REC_BUSY : std_logic := '1';  -- Receiving / Startbit detected
136
  constant REC_COMPLETE : std_logic := '1';  -- komplette Nachricht empfangen
137
 
138
  -- Busdriver
139
  constant BUSDRIVER_ON : std_logic := '1';  -- Einschaltsignal für Busdriver
140
 
141
  -- Baud Rate Generator
142
  constant BRG_ON : std_logic := '1';     -- Einschaltsignal für BRG
143
 
144
  -- Events
145
  constant EV_NONE  : std_logic_vector(1 downto 0) := "00";  -- no event
146
  constant EV_SBD   : std_logic_vector(1 downto 0) := "01";  -- Startbitdetection
147
  constant EV_RCOMP : std_logic_vector(1 downto 0) := "10";  -- Receive completion
148
  constant EV_TCOMP : std_logic_vector(1 downto 0) := "11";  -- Transmit completion
149
  constant EV_OCC : std_logic := '1';     -- Event occured (muß 1 sein!!!)
150
  constant EV_INT : std_logic := '1';   -- Event Interrupt enable
151
 
152
  -- Assigned Actions
153
  constant ASA_STRANS : std_logic_vector(2 downto 0) := "011";  -- start transmission
154
  constant ASA_EREC : std_logic_vector(2 downto 0) := "100";  -- enable receiver
155
  constant ASA_DREC : std_logic_vector(2 downto 0) := "101";  -- disable receiver
156
 
157
 
158
-------------------------------------------------------------------------------
159
-------------------------------------------------------------------------------
160
--                               TYPEN
161
-------------------------------------------------------------------------------  
162
-------------------------------------------------------------------------------
163
 
164
  -- Messagelength Signaltyp
165
  subtype MsgLength_type is std_logic_vector((EXTCONF_MSGL_H - EXTCONF_MSGL_L) downto 0);
166
 
167
  -- Nachricht
168
  subtype Data_type is std_logic_vector(15 downto 0);
169
 
170
-------------------------------------------------------------------------------
171
-------------------------------------------------------------------------------
172
--                             KOMPONENTEN
173
-------------------------------------------------------------------------------  
174
-------------------------------------------------------------------------------
175
 
176
  component ext_miniUART IS
177
  --      generic (
178
        --              GWORD_CFG : integer :=1);
179
  --        MINIUART_BASE : integer := 51;
180
  --        MINIUART_INT  : integer := 9);
181
        PORT(   ---------------------------------------------------------------
182
                -- Generic Ports
183
                ---------------------------------------------------------------
184
                clk           : IN  std_logic;
185
                                        extsel        : in  std_logic;
186
                Exti          : in module_in_type;
187
                Exto          : out module_out_type;
188
 
189
                ---------------------------------------------------------------
190
                -- Module Specific Ports
191
                ---------------------------------------------------------------
192
                RxD           : IN std_logic;  -- Empfangsleitung
193
                TxD           : OUT std_logic  --;  -- Sendeleitung
194
                );
195
  END component;
196
 
197
 
198
  component miniUART_control
199
    port (
200
      clk : in std_logic;
201
      reset : in std_logic;
202
--      MsgLength : in MsgLength_type;      
203
      ParEna : in std_logic;              -- Parity?
204
      Odd : in std_logic;                 -- Odd or Even Parity?
205
      AsA : in std_logic_vector(2 downto 0);  -- Assigned Action
206
      EvS : in std_logic_vector(1 downto 0);  -- Event Selector
207
      Data_r : in Data_type;              -- received Data
208
      ParBit_r : in std_logic;            -- empfangenes Paritybit
209
      FrameErr : in std_logic;
210
      RecComp : in std_logic;             -- Receive Complete
211
      RecBusy : in std_logic;             -- Reciever Busy (Startbit detected)        
212
      TransComp : in std_logic;           -- Transmission complete
213
      EnaRec : out std_logic;             -- Enable receiver
214
      Data_r_out : out Data_type;         -- empfangene Daten
215
      FrameErr_out : out std_logic;
216
      ParityErr : out std_logic;
217
      RBR : out std_logic;                -- Receive Buffer Ready (Rec Complete)
218
      StartTrans : out std_logic;         -- Start Transmitter (halten bis TrComp!)
219
      TBR : out std_logic;                -- Transmit Buffer Ready (MSGREG read,
220
                                          -- transmitter started)
221
      event : out std_logic               -- Selected Event occured!
222
      );
223
  end component;
224
 
225
 
226
  component miniUART_transmitter
227
    port (
228
      clk : in std_logic;
229
      reset : in std_logic;
230
      MsgLength : in MsgLength_type;
231
      Stop2 : in std_logic;               -- Zweites Stopbit?
232
      ParEna : in std_logic;              -- Parity?
233
      ParBit : in std_logic;              -- Vorberechnetes Paritybit
234
      Data : in Data_type;
235
      tp : in std_logic;                  -- Transmitpulse vom BRG
236
      TransEna : out std_logic;           -- Busdriver einschalten
237
      TrComp : out std_logic;              -- Transmission complete
238
      TxD : out std_logic                 -- Sendeausgang
239
      );
240
  end component;
241
 
242
 
243
  component miniUART_receiver
244
    port (
245
      clk : in std_logic;
246
      reset : in std_logic;
247
      enable : in std_logic;              -- Receiver eingeschaltet?
248
      MsgLength : in MsgLength_type;
249
      Stop2 : in std_logic;               -- Zweites Stopbit?
250
      ParEna : in std_logic;              -- Parity?
251
      rp : in std_logic;                  -- Receivepulse vom BRG
252
      RxD : in std_logic;                 -- Empfangseingang
253
      Data : out Data_type;
254
      ParBit : out std_logic;             -- Empfangenes Paritybit
255
      RecEna : out std_logic;             -- Busdriver einschalten
256
      StartRecPulse : out std_logic;      -- Receivepulse generieren
257
      busy : out std_logic;               -- Receiving / Startbit detected
258
      RecComplete : out std_logic;        -- komplettes Frame empfangen
259
      FrameErr : out std_logic
260
      );
261
  end component;
262
 
263
 
264
  component miniUART_BRG
265
    port (
266
      clk : in std_logic;
267
      reset : in std_logic;
268
      StartTrans : in std_logic;          -- Transmitterpulse eingeschaltet?
269
      StartRec : in std_logic;            -- Receiverpulse eingeschaltet?
270
      UBRS : in std_logic_vector(15 downto 0);  -- Baud Rate Selection Register 
271
                                                -- (12bit ganzzahlig, 4bit fraction)
272
      tp : out std_logic;                 -- Transmitterpulse
273
      rp : out std_logic                  -- Receiverpulse
274
      );
275
  end component;
276
 
277
 
278
  component miniUART_busdriver
279
    port (
280
      clk : in std_logic;
281
      reset : in std_logic;
282
      OutD : in std_logic;                -- Output disable
283
      TransEna : in std_logic;            -- Einschalten, von Transmitter
284
      RecEna : in std_logic;              -- Einschalten, von Receiver
285
      Data_t : in std_logic;              -- zu sendendes Bit
286
      Data_r : out std_logic;             -- empfangenes Bit
287
      TxD : out std_logic;                -- Sendeleitung
288
      RxD : in std_logic                  -- Empfangsleitung
289
      );
290
  end component;
291
 
292
end pkg_miniUART;

powered by: WebSVN 2.1.0

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