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

Subversion Repositories z80control

[/] [z80control/] [trunk/] [DE1/] [rtl/] [VHDL/] [TxUnit.vhd] - Blame information for rev 12

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 12 tylerapohl
--===========================================================================--
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      : TxUnit.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    unnecessary variable removed
27
--  olupas@opencores.org
28
-------------------------------------------------------------------------------
29
-- Description    : 
30
-------------------------------------------------------------------------------
31
-- Entity for the Tx Unit                                                    --
32
-------------------------------------------------------------------------------
33
library ieee;
34
use ieee.std_logic_1164.all;
35
use ieee.numeric_std.all;
36
library work;
37
use work.Uart_Def.all;
38
-------------------------------------------------------------------------------
39
-- Transmitter unit
40
-------------------------------------------------------------------------------
41
entity TxUnit is
42
  port (
43
     Clk    : in  Std_Logic;  -- Clock signal
44
     Reset  : in  Std_Logic;  -- Reset input
45
     Enable : in  Std_Logic;  -- Enable input
46
     Load   : in  Std_Logic;  -- Load transmit data
47
     TxD    : out Std_Logic;  -- RS-232 data output
48
     TRegE  : out Std_Logic;  -- Tx register empty
49
     TBufE  : out Std_Logic;  -- Tx buffer empty
50
     DataO  : in  Std_Logic_Vector(7 downto 0));
51
end entity; --================== End of entity ==============================--
52
-------------------------------------------------------------------------------
53
-- Architecture for TxUnit
54
-------------------------------------------------------------------------------
55
architecture Behaviour of TxUnit is
56
  -----------------------------------------------------------------------------
57
  -- Signals
58
  -----------------------------------------------------------------------------
59
  signal TBuff    : Std_Logic_Vector(7 downto 0); -- transmit buffer
60
  signal TReg     : Std_Logic_Vector(7 downto 0); -- transmit register
61
  signal BitCnt   : Unsigned(3 downto 0);         -- bit counter
62
  signal tmpTRegE : Std_Logic;                    -- 
63
  signal tmpTBufE : Std_Logic;                    --
64
begin
65
  -----------------------------------------------------------------------------
66
  -- Implements the Tx unit
67
  -----------------------------------------------------------------------------
68
  process(Clk,Reset,Enable,Load,DataO,TBuff,TReg,tmpTRegE,tmpTBufE)
69
      variable tmp_TRegE : Std_Logic;
70
      constant CntOne    : Unsigned(3 downto 0):="0001";
71
  begin
72
     if Rising_Edge(Clk) then
73
        if Reset = '0' then
74
           tmpTRegE <= '1';
75
           tmpTBufE <= '1';
76
           TxD <= '1';
77
           BitCnt <= "0000";
78
        elsif Load = '1' then
79
           TBuff <= DataO;
80
           tmpTBufE <= '0';
81
        elsif Enable = '1' then
82
           if ( tmpTBufE = '0') and (tmpTRegE = '1') then
83
              TReg <= TBuff;
84
              tmpTRegE <= '0';
85
--              tmp_TRegE := '0';
86
              tmpTBufE <= '1';
87
--           else
88
--              tmp_TRegE := tmpTRegE;
89
           end if;
90
 
91
           if tmpTRegE = '0' then
92
              case BitCnt is
93
                  when "0000" =>
94
                          TxD <= '0';
95
                          BitCnt <= BitCnt + CntOne;
96
                  when "0001" | "0010" | "0011" |
97
                       "0100" | "0101" | "0110" |
98
                       "0111" | "1000" =>
99
                          TxD <= TReg(0);
100
                          TReg <= '1' & TReg(7 downto 1);
101
                          BitCnt <= BitCnt + CntOne;
102
                  when "1001" =>
103
                          TxD <= '1';
104
                          TReg <= '1' & TReg(7 downto 1);
105
                          BitCnt <= "0000";
106
                          tmpTRegE <= '1';
107
                  when others => null;
108
              end case;
109
           end if;
110
        end if;
111
     end if;
112
  end process;
113
 
114
      TRegE <= tmpTRegE;
115
      TBufE <= tmpTBufE;
116
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.