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

Subversion Repositories uart_block

[/] [uart_block/] [trunk/] [hdl/] [iseProject/] [SERIALMASTER.vhd] - Blame information for rev 32

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

Line No. Rev Author Line
1 27 leonardoar
--! Top wishbone Master to test the uart_wishbone_slave
2
library ieee;
3
USE ieee.std_logic_1164.ALL;
4
use ieee.std_logic_unsigned.all;
5
use ieee.std_logic_arith.all;
6
 
7
--! Use CPU Definitions package
8
use work.pkgDefinitions.all;
9
 
10
entity SERIALMASTER is
11
        port(
12
            -- WISHBONE Signals
13
            ACK_I:  in  std_logic;
14
            ADR_O:  out std_logic_vector( 1 downto 0 );
15
            CLK_I:  in  std_logic;
16
            CYC_O:  out std_logic;
17
            DAT_I:  in  std_logic_vector( 31 downto 0 );
18
            DAT_O:  out std_logic_vector( 31 downto 0 );
19
            RST_I:  in  std_logic;
20
            SEL_O:  out std_logic;
21
            STB_O:  out std_logic;
22
            WE_O:   out std_logic;
23
 
24
                                -- NON-WISHBONE Signals
25
                                byte_rec : out std_logic_vector(7 downto 0)
26
         );
27
 
28
end SERIALMASTER;
29
 
30
architecture Behavioral of SERIALMASTER is
31
signal masterSerialStates : testMaster;
32
signal byteIncome : std_logic_vector(7 downto 0);
33
begin
34
 
35
        process (CLK_I)
36
        variable contWait : integer range 0 to 50000000;
37 28 leonardoar
        variable cycles2Wait : integer range 0 to 50000000;
38 27 leonardoar
        variable nextState: testMaster;
39
        begin
40
                if rising_edge(CLK_I) then
41
                        if RST_I = '1' then
42
                                masterSerialStates <= idle;
43
                                nextState := idle;
44
                                contWait := 0;
45 28 leonardoar
                                cycles2Wait := 25000000;
46
                                byteIncome <= conv_std_logic_vector(64, (nBitsLarge));  --Send the '@';
47 27 leonardoar
                        else
48
                                case masterSerialStates is
49
                                        when idle =>
50
                                                masterSerialStates <= config_clock;
51
                                                nextState := idle;
52
 
53
                                        when config_clock =>
54
                                                nextState := config_baud;
55
                                                ADR_O <= "00";
56
                                                WE_O <= '1';
57
                                                STB_O <= '1';
58
                                                DAT_O <= conv_std_logic_vector(50000000, (nBitsLarge));         -- 50Mhz
59
                                                if ACK_I = '1' then
60
                                                        -- Byte received wait some cycles to continue                                           
61
                                                        masterSerialStates <= wait_cycles;
62
                                                        byte_rec        <= "00000001";
63
                                                end if;
64
 
65
                                        when config_baud =>
66
                                                nextState := send_byte;
67
                                                ADR_O <= "01";
68
                                                WE_O <= '1';
69
                                                STB_O <= '1';
70
                                                DAT_O <= conv_std_logic_vector(115200, (nBitsLarge));   --115200 bps
71
                                                if ACK_I = '1' then
72
                                                        -- Byte received wait some cycles to continue
73
                                                        masterSerialStates <= wait_cycles;
74
                                                        byte_rec        <= "00000010";
75
                                                end if;
76
 
77
                                        when send_byte =>
78
                                                nextState := receive_byte;
79
                                                ADR_O <= "10";
80
                                                WE_O <= '1';
81
                                                STB_O <= '1';
82
                                                --DAT_O <= conv_std_logic_vector(64, (nBitsLarge));     --Send the '@'
83
                                                DAT_O <= conv_std_logic_vector(0, (nBitsLarge-8)) & byteIncome;  --Send the '@'
84
                                                if ACK_I = '1' then
85
                                                        -- Byte received wait some cycles to continue
86 28 leonardoar
                                                        masterSerialStates <= wait_cycles;
87
                                                        cycles2Wait     := 7000000;
88 27 leonardoar
                                                end if;
89
 
90
                                        when receive_byte =>
91
                                                nextState := send_byte;
92
                                                ADR_O <= "11";
93
                                                WE_O <= '0';
94
                                                STB_O <= '1';
95
                                                if ACK_I = '1' then
96
                                                        -- Byte received wait some cycles to continue
97
                                                        masterSerialStates <= wait_cycles;
98
                                                        byte_rec        <= DAT_I(7 downto 0);
99
                                                        byteIncome <= DAT_I(7 downto 0);
100 28 leonardoar
                                                        cycles2Wait     := 7000000;
101 27 leonardoar
                                                end if;
102
 
103
                                        when wait_cycles =>
104
                                                -- wait some cycles (90)
105 28 leonardoar
                                                if contWait < cycles2Wait then
106 27 leonardoar
                                                        contWait := contWait + 1;
107
                                                        STB_O <= '0';
108
                                                else
109
                                                        contWait := 0;
110
                                                        masterSerialStates <= nextState;
111
                                                end if;
112
                                end case;
113
                        end if;
114
                end if;
115
        end process;
116
 
117
 
118
end Behavioral;
119
 

powered by: WebSVN 2.1.0

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