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

Subversion Repositories utosnet

[/] [utosnet/] [trunk/] [gateware/] [uTosNet_example/] [uTosNet_uart/] [top.vhd] - Blame information for rev 4

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 3 sonicwave
----------------------------------------------------------------------------------
2
-- Company:             University of Southern Denmark
3
-- Engineer:            Simon Falsig
4
-- 
5
-- Create Date:         19/03/2010 
6
-- Design Name:         uTosNet_uart Example
7
-- Module Name:         top - Behavioral 
8 4 sonicwave
-- File Name:           top.vhd
9 3 sonicwave
-- Project Name:        uTosNet
10
-- Target Devices:      SDU XC3S50AN Board
11
-- Tool versions:       Xilinx ISE 11.4
12
-- Description:         This is a simple example showing the use of the uTosNet_uart
13
--                                      module.
14
--
15
-- Revision: 
16
-- Revision 0.10 -      Initial release
17
--
18 4 sonicwave
-- Copyright 2010
19
--
20
-- This file is part of the uTosNet_spi Example
21
--
22
-- The uTosNet_uart Example is free software: you can redistribute it 
23
-- and/or modify it under the terms of the GNU Lesser General Public License as
24
-- published by the Free Software Foundation, either version 3 of the License,
25
-- or (at your option) any later version.
26
--
27
-- The uTosNet_uart Example is distributed in the hope that it will be
28
-- useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
29
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser
30
-- General Public License for more details.
31
--
32
-- You should have received a copy of the GNU Lesser General Public License
33
-- along with the uTosNet_uart Example. If not, see
34
-- <http://www.gnu.org/licenses/>.
35 3 sonicwave
----------------------------------------------------------------------------------
36 4 sonicwave
 
37 3 sonicwave
library IEEE;
38
use IEEE.STD_LOGIC_1164.ALL;
39
use IEEE.STD_LOGIC_ARITH.ALL;
40
use IEEE.STD_LOGIC_UNSIGNED.ALL;
41
 
42
---- Uncomment the following library declaration if instantiating
43
---- any Xilinx primitives in this code.
44
--library UNISIM;
45
--use UNISIM.VComponents.all;
46
 
47
entity top is
48
Port (  CLK_50M_I                       : in    STD_LOGIC;
49
                LEDS_O                          : out   STD_LOGIC_VECTOR(2 downto 0);
50
                SERIAL_O                        : out   STD_LOGIC;
51
                SERIAL_I                        : in    STD_LOGIC);
52
end top;
53
 
54
architecture Behavioral of top is
55
 
56
        component uTosNet_uart is
57
        Port (  clk_50M                                         : in    STD_LOGIC;
58
                        serial_out                                      : out   STD_LOGIC;
59
                        serial_in                                       : in    STD_LOGIC;
60
                        dataReg_addr                            : in    STD_LOGIC_VECTOR(5 downto 0);
61
                        dataReg_dataIn                          : in    STD_LOGIC_VECTOR(31 downto 0);
62
                        dataReg_dataOut                         : out   STD_LOGIC_VECTOR(31 downto 0);
63
                        dataReg_clk                                     : in    STD_LOGIC;
64
                        dataReg_writeEnable                     : in    STD_LOGIC);
65
        end component;
66
 
67
        type STATES is (IDLE, SETUP_1, CLK_1, DONE_1);
68
 
69
        signal state            : STATES := IDLE;
70
        signal nextState        : STATES := IDLE;
71
 
72
        signal dataReg_addr             : STD_LOGIC_VECTOR(5 downto 0);
73
        signal dataReg_dataIn   : STD_LOGIC_VECTOR(31 downto 0) := (others => '0');
74
        signal dataReg_dataOut  : STD_LOGIC_VECTOR(31 downto 0) := (others => '0');
75
        signal dataReg_clk              : STD_LOGIC;
76
        signal dataReg_we               : STD_LOGIC;
77
 
78
begin
79
 
80
        uTosNet_uartInst : uTosNet_uart
81
        Port map (      clk_50M => CLK_50M_I,
82
                                serial_out => SERIAL_O,
83
                                serial_in => SERIAL_I,
84
                                dataReg_addr => dataReg_addr,
85
                                dataReg_dataIn => "00000000000000000000000000000000",
86
                                dataReg_dataOut => dataReg_dataOut,
87
                                dataReg_clk => dataReg_clk,
88
                                dataReg_writeEnable => dataReg_we);
89
 
90
        process(CLK_50M_I)
91
        begin
92
                if(CLK_50M_I = '1' and CLK_50M_I'event) then
93
                        state <= nextState;
94
 
95
                        case state is
96
                                when IDLE =>
97
                                when SETUP_1 =>
98
                                        dataReg_addr <= "000000";
99
                                        dataReg_clk <= '0';
100
                                        dataReg_we <= '0';
101
                                when CLK_1 =>
102
                                        dataReg_clk <= '1';
103
                                when DONE_1 =>
104
                                        LEDS_O <= dataReg_dataOut(2 downto 0);
105
                        end case;
106
                end if;
107
        end process;
108
 
109
        process(state)
110
        begin
111
                case state is
112
                        when IDLE =>
113
                                nextState <= SETUP_1;
114
                        when SETUP_1 =>
115
                                nextState <= CLK_1;
116
                        when CLK_1 =>
117
                                nextState <= DONE_1;
118
                        when DONE_1 =>
119
                                nextState <= IDLE;
120
                end case;
121
        end process;
122
 
123
 
124
end Behavioral;
125
 

powered by: WebSVN 2.1.0

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