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

Subversion Repositories miniuart2

[/] [miniuart2/] [branches/] [avendor/] [rtl/] [vhdl/] [Txunit.vhd] - Blame information for rev 2

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 philippe
-------------------------------------------------------------------------------
2
-- Title      : UART
3
-- Project    : UART
4
-------------------------------------------------------------------------------
5
-- File        : Txunit.vhd
6
-- Author      : Philippe CARTON 
7
--               (pc@microsystemes.com / philippe.carton2@libertysurf.fr)
8
-- Organization: Microsystemes
9
-- Created     : 15/12/2001
10
-- Last update : 28/12/2001
11
-- Platform    : Foundation 3.1i
12
-- Simulators  : Foundation logic simulator
13
-- Synthesizers: Foundation Synopsys
14
-- Targets     : Xilinx Spartan
15
-- Dependency  : IEEE std_logic_1164
16
-------------------------------------------------------------------------------
17
-- Description: Txunit is a parallel to serial unit transmitter.
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
 
32
library ieee;
33
use ieee.std_logic_1164.all;
34
 
35
entity TxUnit is
36
  port (
37
     Clk    : in  Std_Logic;  -- Clock signal
38
     Reset  : in  Std_Logic;  -- Reset input
39
     Enable : in  Std_Logic;  -- Enable input
40
     LoadA  : in  Std_Logic;  -- Asynchronous Load
41
     TxD    : out Std_Logic;  -- RS-232 data output
42
     Busy   : out Std_Logic;  -- Tx Busy
43
     DataI  : in  Std_Logic_Vector(7 downto 0)); -- Byte to transmit
44
end entity;
45
 
46
architecture Behaviour of TxUnit is
47
  signal TBuff    : Std_Logic_Vector(7 downto 0); -- transmit buffer
48
  signal TReg     : Std_Logic_Vector(7 downto 0); -- transmit register
49
  signal TBufL    : Std_Logic;  -- Buffer loaded
50
  signal Load     : Std_Logic;  -- Load signal, Clk synchronised
51
  signal LoadAS   : Std_Logic;  -- Load signal Async started, Sync stopped
52
 
53
begin
54
  process(LoadA, Load)
55
  begin
56
     if load = '1' then
57
        loadAS <= '0';  -- Clear LoadAS
58
     elsif Rising_Edge(LoadA) then
59
        LoadAS <= '1';
60
     end if;
61
  end process;
62
  -- Synchronize Load on Clk
63
  SyncLoad : process(Clk, LoadAS)
64
  begin
65
     if Rising_Edge(Clk) then
66
        if LoadAS = '1' then
67
           Load <= '1';
68
        end if;
69
        if Load = '1' then
70
           Load <= '0';
71
        end if;
72
     end if;
73
  end process;
74
  Busy <= LoadAS or TBufL;
75
 
76
  -- Tx process
77
  TxProc : process(Clk, Reset, Enable, Load, DataI, TBuff, TReg, TBufL)
78
  variable BitPos : INTEGER range 0 to 10; -- Bit position in the frame
79
  begin
80
     if Reset = '1' then
81
        TBufL <= '0';
82
        BitPos := 0;
83
     elsif Rising_Edge(Clk) then
84
        if LoadAS = '1' then
85
           TBuff <= DataI;
86
           TBufL <= '1';
87
        end if;
88
        if Enable = '1' then
89
           case BitPos is
90
              when 0 => -- idle or stop bit
91
                 TxD <= '1';
92
                 if TBufL = '1' then -- start transmit. next is start bit
93
                    TReg <= TBuff;
94
                    TBufL <= '0';
95
                    BitPos := 1;
96
                 end if;
97
              when 1 => -- Start bit
98
                 TxD <= '0';
99
                 BitPos := 2;
100
              when others =>
101
                 TxD <= TReg(BitPos-2); -- Serialisation of TReg
102
                 BitPos := BitPos + 1;
103
           end case;
104
           if BitPos = 10 then -- bit8. next is stop bit
105
              BitPos := 0;
106
           end if;
107
        end if;
108
     end if;
109
  end process;
110
end Behaviour;

powered by: WebSVN 2.1.0

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