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 3

Go to most recent revision | 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
-- Project Name:        uTosNet
9
-- Target Devices:      SDU XC3S50AN Board
10
-- Tool versions:       Xilinx ISE 11.4
11
-- Description:         This is a simple example showing the use of the uTosNet_uart
12
--                                      module.
13
--
14
-- Revision: 
15
-- Revision 0.10 -      Initial release
16
--
17
----------------------------------------------------------------------------------
18
library IEEE;
19
use IEEE.STD_LOGIC_1164.ALL;
20
use IEEE.STD_LOGIC_ARITH.ALL;
21
use IEEE.STD_LOGIC_UNSIGNED.ALL;
22
 
23
---- Uncomment the following library declaration if instantiating
24
---- any Xilinx primitives in this code.
25
--library UNISIM;
26
--use UNISIM.VComponents.all;
27
 
28
entity top is
29
Port (  CLK_50M_I                       : in    STD_LOGIC;
30
                LEDS_O                          : out   STD_LOGIC_VECTOR(2 downto 0);
31
                SERIAL_O                        : out   STD_LOGIC;
32
                SERIAL_I                        : in    STD_LOGIC);
33
end top;
34
 
35
architecture Behavioral of top is
36
 
37
        component uTosNet_uart is
38
        Port (  clk_50M                                         : in    STD_LOGIC;
39
                        serial_out                                      : out   STD_LOGIC;
40
                        serial_in                                       : in    STD_LOGIC;
41
                        dataReg_addr                            : in    STD_LOGIC_VECTOR(5 downto 0);
42
                        dataReg_dataIn                          : in    STD_LOGIC_VECTOR(31 downto 0);
43
                        dataReg_dataOut                         : out   STD_LOGIC_VECTOR(31 downto 0);
44
                        dataReg_clk                                     : in    STD_LOGIC;
45
                        dataReg_writeEnable                     : in    STD_LOGIC);
46
        end component;
47
 
48
        type STATES is (IDLE, SETUP_1, CLK_1, DONE_1);
49
 
50
        signal state            : STATES := IDLE;
51
        signal nextState        : STATES := IDLE;
52
 
53
        signal dataReg_addr             : STD_LOGIC_VECTOR(5 downto 0);
54
        signal dataReg_dataIn   : STD_LOGIC_VECTOR(31 downto 0) := (others => '0');
55
        signal dataReg_dataOut  : STD_LOGIC_VECTOR(31 downto 0) := (others => '0');
56
        signal dataReg_clk              : STD_LOGIC;
57
        signal dataReg_we               : STD_LOGIC;
58
 
59
begin
60
 
61
        uTosNet_uartInst : uTosNet_uart
62
        Port map (      clk_50M => CLK_50M_I,
63
                                serial_out => SERIAL_O,
64
                                serial_in => SERIAL_I,
65
                                dataReg_addr => dataReg_addr,
66
                                dataReg_dataIn => "00000000000000000000000000000000",
67
                                dataReg_dataOut => dataReg_dataOut,
68
                                dataReg_clk => dataReg_clk,
69
                                dataReg_writeEnable => dataReg_we);
70
 
71
        process(CLK_50M_I)
72
        begin
73
                if(CLK_50M_I = '1' and CLK_50M_I'event) then
74
                        state <= nextState;
75
 
76
                        case state is
77
                                when IDLE =>
78
                                when SETUP_1 =>
79
                                        dataReg_addr <= "000000";
80
                                        dataReg_clk <= '0';
81
                                        dataReg_we <= '0';
82
                                when CLK_1 =>
83
                                        dataReg_clk <= '1';
84
                                when DONE_1 =>
85
                                        LEDS_O <= dataReg_dataOut(2 downto 0);
86
                        end case;
87
                end if;
88
        end process;
89
 
90
        process(state)
91
        begin
92
                case state is
93
                        when IDLE =>
94
                                nextState <= SETUP_1;
95
                        when SETUP_1 =>
96
                                nextState <= CLK_1;
97
                        when CLK_1 =>
98
                                nextState <= DONE_1;
99
                        when DONE_1 =>
100
                                nextState <= IDLE;
101
                end case;
102
        end process;
103
 
104
 
105
end Behavioral;
106
 

powered by: WebSVN 2.1.0

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