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

Subversion Repositories spacewire_light

[/] [spacewire_light/] [trunk/] [syn/] [streamtest_digilent-xc3s200/] [streamtest_top.vhd] - Blame information for rev 2

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

Line No. Rev Author Line
1 2 jorisvr
--
2
--  Test of spwstream on Digilent XC3S200 board.
3
--
4
--  LED 0 = link started
5
--  LED 1 = link connecting
6
--  LED 2 = link run
7
--  LED 3 = link error (sticky until clear button)
8
--  LED 4 = gotdata
9
--  LED 5 = off
10
--  LED 6 = data error (sticky until reset)
11
--  LED 7 = time code error (sticky until reset)
12
--
13
--  Button 0 = reset
14
--  Button 1 = clear LED 3
15
--
16
--  Switch 0 = link autostart
17
--  Switch 1 = link start
18
--  Switch 2 = link disable
19
--  Switch 3 = send data and time codes
20
--  Switch 4-7 = bits 0-3 of tx bit rate scale factor
21
--
22
--  SpaceWire signals on A2 expansion connector:
23
--    Data In    pos,neg  =  B5,C5  =  pin 19,6
24
--    Strobe In  pos,neg  =  D6,E6  =  pin 7,4
25
--    Data Out   pos,neg  =  B6,C6  =  pin 21,8
26
--    Strobe Out pos,neg  =  D7,E7  =  pin 11,9
27
--
28
--  Note: these are not true LVDS signals; they are configured as LVDS25
29
--  but powered from 3.3V instead of 2.5V, not differentially routed and
30
--  not properly terminated.
31
--
32
--  The SpaceWire port should be looped back to itself with wires from
33
--  outputs to corresponding inputs.
34
--
35
 
36
library ieee;
37
use ieee.std_logic_1164.all, ieee.numeric_std.all;
38
library unisim;
39
use unisim.vcomponents.all;
40
use work.spwpkg.all;
41
 
42
entity streamtest_top is
43
 
44
    port (
45
        clk50:      in  std_logic;
46
        button:     in  std_logic_vector(3 downto 0);
47
        switch:     in  std_logic_vector(7 downto 0);
48
        led:        out std_logic_vector(7 downto 0);
49
        spw_di_p:   in  std_logic;
50
        spw_di_n:   in  std_logic;
51
        spw_si_p:   in  std_logic;
52
        spw_si_n:   in  std_logic;
53
        spw_do_p:   out std_logic;
54
        spw_do_n:   out std_logic;
55
        spw_so_p:   out std_logic;
56
        spw_so_n:   out std_logic );
57
 
58
end entity streamtest_top;
59
 
60
architecture streamtest_top_arch of streamtest_top is
61
 
62
    -- Clock generation.
63
    signal boardclk:        std_logic;
64
    signal sysclk:          std_logic;
65
    signal fastclk:         std_logic;
66
 
67
    -- Synchronize buttons
68
    signal s_resetbtn:      std_logic := '0';
69
    signal s_clearbtn:      std_logic := '0';
70
 
71
    -- Sticky LED
72
    signal s_linkerrorled:  std_logic := '0';
73
 
74
    -- Interface signals.
75
    signal s_rst:           std_logic := '1';
76
    signal s_linkstart:     std_logic := '0';
77
    signal s_autostart:     std_logic := '0';
78
    signal s_linkdisable:   std_logic := '0';
79
    signal s_senddata:      std_logic := '0';
80
    signal s_txdivcnt:      std_logic_vector(7 downto 0) := "00000000";
81
    signal s_linkstarted:   std_logic;
82
    signal s_linkconnecting: std_logic;
83
    signal s_linkrun:       std_logic;
84
    signal s_linkerror:     std_logic;
85
    signal s_gotdata:       std_logic;
86
    signal s_dataerror:     std_logic;
87
    signal s_tickerror:     std_logic;
88
    signal s_spwdi:         std_logic;
89
    signal s_spwsi:         std_logic;
90
    signal s_spwdo:         std_logic;
91
    signal s_spwso:         std_logic;
92
 
93
    -- Make clock nets visible to UCF file.
94
    attribute KEEP: string;
95
    attribute KEEP of sysclk: signal is "SOFT";
96
    attribute KEEP of fastclk: signal is "SOFT";
97
 
98
    component streamtest is
99
        generic (
100
            sysfreq:    real;
101
            tickdiv:    integer range 12 to 24 := 20;
102
            rximpl:     spw_implementation_type := impl_generic;
103
            rxchunk:    integer range 1 to 4 := 1;
104
            tximpl:     spw_implementation_type := impl_generic;
105
            rxfifosize_bits: integer range 6 to 14 := 11;
106
            txfifosize_bits: integer range 2 to 14 := 11 );
107
        port (
108
            clk:        in  std_logic;
109
            rxclk:      in  std_logic;
110
            txclk:      in  std_logic;
111
            rst:        in  std_logic;
112
            linkstart:  in  std_logic;
113
            autostart:  in  std_logic;
114
            linkdisable: in std_logic;
115
            senddata:   in  std_logic;
116
            sendtick:   in  std_logic;
117
            txdivcnt:   in  std_logic_vector(7 downto 0);
118
            linkstarted: out std_logic;
119
            linkconnecting: out std_logic;
120
            linkrun:    out std_logic;
121
            linkerror:  out std_logic;
122
            gotdata:    out std_logic;
123
            dataerror:  out std_logic;
124
            tickerror:  out std_logic;
125
            spw_di:     in  std_logic;
126
            spw_si:     in  std_logic;
127
            spw_do:     out std_logic;
128
            spw_so:     out std_logic );
129
    end component;
130
 
131
begin
132
 
133
    -- Buffer incoming clock.
134
    bufg0: BUFG port map ( I => clk50, O => boardclk );
135
 
136
    -- Generate 60 MHz system clock.
137
    dcm0: DCM
138
        generic map (
139
            CLKFX_DIVIDE        => 5,
140
            CLKFX_MULTIPLY      => 6,
141
            CLK_FEEDBACK      => "NONE",
142
            CLKIN_DIVIDE_BY_2   => false,
143
            CLKIN_PERIOD        => 20.0,
144
            CLKOUT_PHASE_SHIFT  => "NONE",
145
            DESKEW_ADJUST       => "SYSTEM_SYNCHRONOUS",
146
            DFS_FREQUENCY_MODE  => "LOW",
147
            DUTY_CYCLE_CORRECTION => true,
148
            STARTUP_WAIT        => true )
149
        port map (
150
            CLKIN       => boardclk,
151
            RST         => '0',
152
            CLKFX       => sysclk );
153
 
154
    -- Generate 200 MHz fast clock.
155
    dcm1: DCM
156
        generic map (
157
            CLKFX_DIVIDE        => 1,
158
            CLKFX_MULTIPLY      => 4,
159
            CLK_FEEDBACK        => "NONE",
160
            CLKIN_DIVIDE_BY_2   => false,
161
            CLKIN_PERIOD        => 20.0,
162
            CLKOUT_PHASE_SHIFT  => "NONE",
163
            DESKEW_ADJUST       => "SYSTEM_SYNCHRONOUS",
164
            DFS_FREQUENCY_MODE  => "LOW",
165
            DUTY_CYCLE_CORRECTION => true,
166
            STARTUP_WAIT        => true )
167
        port map (
168
            CLKIN       => boardclk,
169
            RST         => '0',
170
            CLKFX       => fastclk );
171
 
172
    -- Streamtest instance
173
    streamtest_inst: streamtest
174
        generic map (
175
            sysfreq     => 60.0e6,
176
            tickdiv     => 22,
177
            rximpl      => impl_fast,
178
            rxchunk     => 4,
179
            tximpl      => impl_fast,
180
            rxfifosize_bits => 11,
181
            txfifosize_bits => 10 )
182
        port map (
183
            clk         => sysclk,
184
            rxclk       => fastclk,
185
            txclk       => fastclk,
186
            rst         => s_rst,
187
            linkstart   => s_linkstart,
188
            autostart   => s_autostart,
189
            linkdisable => s_linkdisable,
190
            senddata    => s_senddata,
191
            sendtick    => s_senddata,
192
            txdivcnt    => s_txdivcnt,
193
            linkstarted => s_linkstarted,
194
            linkconnecting => s_linkconnecting,
195
            linkrun     => s_linkrun,
196
            linkerror   => s_linkerror,
197
            gotdata     => s_gotdata,
198
            dataerror   => s_dataerror,
199
            tickerror   => s_tickerror,
200
            spw_di      => s_spwdi,
201
            spw_si      => s_spwsi,
202
            spw_do      => s_spwdo,
203
            spw_so      => s_spwso );
204
 
205
    -- LVDS buffers
206
    spwdi_pad: IBUFDS
207
        generic map ( IOSTANDARD => "LVDS_25" )
208
        port map ( O => s_spwdi, I => spw_di_p, IB => spw_di_n );
209
    spwsi_pad: IBUFDS
210
        generic map ( IOSTANDARD => "LVDS_25" )
211
        port map ( O => s_spwsi, I => spw_si_p, IB => spw_si_n );
212
    spwdo_pad: OBUFDS
213
        generic map ( IOSTANDARD => "LVDS_25" )
214
        port map ( O => spw_do_p, OB => spw_do_n, I => s_spwdo );
215
    spwso_pad: OBUFDS
216
        generic map ( IOSTANDARD => "LVDS_25" )
217
        port map ( O => spw_so_p, OB => spw_so_n, I => s_spwso );
218
 
219
    process (sysclk) is
220
    begin
221
        if rising_edge(sysclk) then
222
 
223
            -- Synchronize buttons
224
            s_resetbtn  <= button(0);
225
            s_rst       <= s_resetbtn;
226
            s_clearbtn  <= button(1);
227
 
228
            -- Synchronize switch settings
229
            s_autostart <= switch(0);
230
            s_linkstart <= switch(1);
231
            s_linkdisable <= switch(2);
232
            s_senddata  <= switch(3);
233
            s_txdivcnt(3 downto 0) <= switch(7 downto 4);
234
 
235
            -- Sticky link error LED
236
            s_linkerrorled <= (s_linkerrorled or s_linkerror) and
237
                              (not s_clearbtn) and
238
                              (not s_resetbtn);
239
 
240
            -- Drive LEDs
241
            led(0)  <= s_linkstarted;
242
            led(1)  <= s_linkconnecting;
243
            led(2)  <= s_linkrun;
244
            led(3)  <= s_linkerrorled;
245
            led(4)  <= s_gotdata;
246
            led(5)  <= '0';
247
            led(6)  <= s_dataerror;
248
            led(7)  <= s_tickerror;
249
 
250
        end if;
251
    end process;
252
 
253
end architecture streamtest_top_arch;

powered by: WebSVN 2.1.0

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