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

Subversion Repositories utosnet

[/] [utosnet/] [trunk/] [gateware/] [uTosNet_example/] [uTosNet_spi/] [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_spi 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_spi
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_spi 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_spi 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_spi 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
                SPI_MISO_O                      : out   STD_LOGIC;
51
                SPI_MOSI_I                      : in    STD_LOGIC;
52
                SPI_EN_I                        : in    STD_LOGIC;
53
                SPI_CLK_I                       : in    STD_LOGIC);
54
end top;
55
 
56
architecture Behavioral of top is
57
 
58
        component uTosNet_spi is
59 4 sonicwave
        Port (  clk_50M                                         : in    STD_LOGIC;
60
                        spi_miso                                        : out   STD_LOGIC;
61
                        spi_mosi                                        : in    STD_LOGIC;
62
                        spi_clk                                         : in    STD_LOGIC;
63 3 sonicwave
                        spi_en                                          : in    STD_LOGIC;
64 4 sonicwave
                        dataReg_addr                            : in    STD_LOGIC_VECTOR(5 downto 0);
65 3 sonicwave
                        dataReg_dataIn                          : in    STD_LOGIC_VECTOR(31 downto 0);
66
                        dataReg_dataOut                         : out   STD_LOGIC_VECTOR(31 downto 0);
67
                        dataReg_clk                                     : in    STD_LOGIC;
68
                        dataReg_writeEnable                     : in    STD_LOGIC);
69
        end component;
70
 
71
        type STATES is (IDLE, SETUP, CLK, DONE);
72
 
73
        signal state            : STATES := IDLE;
74
        signal nextState        : STATES := IDLE;
75
 
76
        signal dataReg_addr             : STD_LOGIC_VECTOR(5 downto 0);
77
        signal dataReg_dataIn   : STD_LOGIC_VECTOR(31 downto 0);
78
        signal dataReg_dataOut  : STD_LOGIC_VECTOR(31 downto 0);
79
        signal dataReg_clk              : STD_LOGIC;
80
        signal dataReg_we               : STD_LOGIC;
81
begin
82
 
83
        uTosNet_spiInst : uTosNet_spi
84
        Port map (      clk_50M => CLK_50M_I,
85
                                spi_miso => SPI_MISO_O,
86
                                spi_mosi => SPI_MOSI_I,
87
                                spi_en => SPI_EN_I,
88
                                spi_clk => SPI_CLK_I,
89
                                dataReg_addr => dataReg_addr,
90
                                dataReg_dataIn => dataReg_dataIn,
91
                                dataReg_dataOut => dataReg_dataOut,
92
                                dataReg_clk => dataReg_clk,
93
                                dataReg_writeEnable => dataReg_we);
94
 
95
        process(CLK_50M_I)
96
        begin
97
                if(CLK_50M_I = '1' and CLK_50M_I'event) then
98
                        state <= nextState;
99
 
100
                        case state is
101
                                when IDLE =>
102
                                when SETUP =>
103
                                        dataReg_addr <= "000000";
104
                                        dataReg_clk <= '0';
105
                                        dataReg_we <= '0';
106
                                when CLK =>
107
                                        dataReg_clk <= '1';
108
                                when DONE =>
109
                                        LEDS_O <= dataReg_dataOut(2 downto 0);
110
                        end case;
111
                end if;
112
        end process;
113
 
114
        process(state)
115
        begin
116
                case state is
117
                        when IDLE =>
118
                                nextState <= SETUP;
119
                        when SETUP =>
120
                                nextState <= CLK;
121
                        when CLK =>
122
                                nextState <= DONE;
123
                        when DONE =>
124
                                nextState <= IDLE;
125
                end case;
126
        end process;
127
 
128
 
129
end Behavioral;
130
 

powered by: WebSVN 2.1.0

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