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 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_spi 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_spi
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
                SPI_MISO_O                      : out   STD_LOGIC;
32
                SPI_MOSI_I                      : in    STD_LOGIC;
33
                SPI_EN_I                        : in    STD_LOGIC;
34
                SPI_CLK_I                       : in    STD_LOGIC);
35
end top;
36
 
37
architecture Behavioral of top is
38
 
39
        component uTosNet_spi is
40
        Port (  clk_50M                                         : in    STD_LOGIC;
41
                        spi_miso                                        : out   STD_LOGIC;
42
                        spi_mosi                                        : in    STD_LOGIC;
43
                        spi_clk                                         : in    STD_LOGIC;
44
                        spi_en                                          : in    STD_LOGIC;
45
                        dataReg_addr                            : in    STD_LOGIC_VECTOR(5 downto 0);
46
                        dataReg_dataIn                          : in    STD_LOGIC_VECTOR(31 downto 0);
47
                        dataReg_dataOut                         : out   STD_LOGIC_VECTOR(31 downto 0);
48
                        dataReg_clk                                     : in    STD_LOGIC;
49
                        dataReg_writeEnable                     : in    STD_LOGIC);
50
        end component;
51
 
52
        type STATES is (IDLE, SETUP, CLK, DONE);
53
 
54
        signal state            : STATES := IDLE;
55
        signal nextState        : STATES := IDLE;
56
 
57
        signal dataReg_addr             : STD_LOGIC_VECTOR(5 downto 0);
58
        signal dataReg_dataIn   : STD_LOGIC_VECTOR(31 downto 0);
59
        signal dataReg_dataOut  : STD_LOGIC_VECTOR(31 downto 0);
60
        signal dataReg_clk              : STD_LOGIC;
61
        signal dataReg_we               : STD_LOGIC;
62
begin
63
 
64
        uTosNet_spiInst : uTosNet_spi
65
        Port map (      clk_50M => CLK_50M_I,
66
                                spi_miso => SPI_MISO_O,
67
                                spi_mosi => SPI_MOSI_I,
68
                                spi_en => SPI_EN_I,
69
                                spi_clk => SPI_CLK_I,
70
                                dataReg_addr => dataReg_addr,
71
                                dataReg_dataIn => dataReg_dataIn,
72
                                dataReg_dataOut => dataReg_dataOut,
73
                                dataReg_clk => dataReg_clk,
74
                                dataReg_writeEnable => dataReg_we);
75
 
76
        process(CLK_50M_I)
77
        begin
78
                if(CLK_50M_I = '1' and CLK_50M_I'event) then
79
                        state <= nextState;
80
 
81
                        case state is
82
                                when IDLE =>
83
                                when SETUP =>
84
                                        dataReg_addr <= "000000";
85
                                        dataReg_clk <= '0';
86
                                        dataReg_we <= '0';
87
                                when CLK =>
88
                                        dataReg_clk <= '1';
89
                                when DONE =>
90
                                        LEDS_O <= dataReg_dataOut(2 downto 0);
91
                        end case;
92
                end if;
93
        end process;
94
 
95
        process(state)
96
        begin
97
                case state is
98
                        when IDLE =>
99
                                nextState <= SETUP;
100
                        when SETUP =>
101
                                nextState <= CLK;
102
                        when CLK =>
103
                                nextState <= DONE;
104
                        when DONE =>
105
                                nextState <= IDLE;
106
                end case;
107
        end process;
108
 
109
 
110
end Behavioral;
111
 

powered by: WebSVN 2.1.0

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