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

Subversion Repositories uart_block

[/] [uart_block/] [trunk/] [hdl/] [iseProject/] [serial_transmitter.vhd] - Blame information for rev 11

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

Line No. Rev Author Line
1 2 leonardoar
--! Data transmitter
2
--! http://www.fpga4fun.com/SerialInterface.html
3
library IEEE;
4
use IEEE.STD_LOGIC_1164.ALL;
5
 
6
--! Use CPU Definitions package
7
use work.pkgDefinitions.all;
8
 
9
entity serial_transmitter is
10
    Port ( rst : in  STD_LOGIC;
11
           baudClk : in  STD_LOGIC;
12
           data_byte : in  STD_LOGIC_VECTOR ((nBits-1) downto 0);
13
                          data_sent : out STD_LOGIC;
14
           serial_out : out  STD_LOGIC);
15
end serial_transmitter;
16
 
17
architecture Behavioral of serial_transmitter is
18
signal current_s,next_s: txStates;
19
begin
20
 
21
        -- Next state process
22
        process (rst, baudClk)
23
        begin
24
                if rst = '1' then
25
                        current_s <= tx_idle;
26
                elsif rising_edge(baudClk) then
27
                        current_s <= next_s;
28
                end if;
29
        end process;
30
 
31
        process (current_s, data_byte)
32
        begin
33
                case current_s is
34
                        when tx_idle =>
35
                                serial_out <= '1';
36
                                data_sent <= '0';
37
                                next_s <= tx_start;
38
 
39
                        -- Start bit
40
                        when tx_start =>
41
                                serial_out <= '0';
42
                                data_sent <= '0';
43
                                next_s <= bit0;
44
 
45
                        when bit0 =>    -- Send the least significat bit
46
                                serial_out <= data_byte(0);
47
                                data_sent <= '0';
48
                                next_s <= bit1;
49
 
50
                        when bit1 =>
51
                                serial_out <= data_byte(1);
52
                                data_sent <= '0';
53
                                next_s <= bit2;
54
 
55
                        when bit2 =>
56
                                serial_out <= data_byte(2);
57
                                data_sent <= '0';
58
                                next_s <= bit3;
59
 
60
                        when bit3 =>
61
                                serial_out <= data_byte(3);
62
                                data_sent <= '0';
63
                                next_s <= bit4;
64
 
65
                        when bit4 =>
66
                                serial_out <= data_byte(4);
67
                                data_sent <= '0';
68
                                next_s <= bit5;
69
 
70
                        when bit5 =>
71
                                serial_out <= data_byte(5);
72
                                data_sent <= '0';
73
                                next_s <= bit6;
74
 
75
                        when bit6 =>
76
                                serial_out <= data_byte(6);
77
                                data_sent <= '0';
78
                                next_s <= bit7;
79
 
80
                        when bit7 =>    -- Send the most significat bit
81
                                serial_out <= data_byte(7);
82
                                data_sent <= '0';
83
                                next_s <= tx_stop1;
84
 
85
 
86
                        when tx_stop1 =>
87
                                serial_out <= '1';
88
                                data_sent <= '1';
89
                                next_s <= tx_stop2;
90
 
91
                        when tx_stop2 =>        -- Stop here and wait for other reset
92
                                serial_out <= '1';
93
                                data_sent <= '1';
94
                                next_s <= tx_stop2;
95
 
96
                end case;
97
        end process;
98
 
99
end Behavioral;
100
 

powered by: WebSVN 2.1.0

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