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

Subversion Repositories simpcon

[/] [simpcon/] [trunk/] [vhdl/] [sc_test_slave.vhd] - Blame information for rev 26

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

Line No. Rev Author Line
1 8 martin
--
2
--      sc_test_slave.vhd
3
--
4
--      A simple test slave for the SimpCon interface
5
--      
6
--      Author: Martin Schoeberl        martin@jopdesign.com
7
--
8
--
9
--      resources on Cyclone
10
--
11
--              xx LCs, max xx MHz
12
--
13
--
14
--      2005-11-29      first version
15
--
16
--      todo:
17
--
18
--
19
 
20
 
21
library ieee;
22
use ieee.std_logic_1164.all;
23
use ieee.numeric_std.all;
24
 
25
entity sc_test_slave is
26
generic (addr_bits : integer);
27
 
28
port (
29
        clk             : in std_logic;
30
        reset   : in std_logic;
31
 
32
-- SimpCon interface
33
 
34
        address         : in std_logic_vector(addr_bits-1 downto 0);
35
        wr_data         : in std_logic_vector(31 downto 0);
36
        rd, wr          : in std_logic;
37
        rd_data         : out std_logic_vector(31 downto 0);
38
        rdy_cnt         : out unsigned(1 downto 0)
39
 
40
);
41
end sc_test_slave;
42
 
43
architecture rtl of sc_test_slave is
44
 
45
        signal xyz                      : std_logic_vector(31 downto 0);
46
        signal cnt                      : unsigned(31 downto 0);
47
 
48
begin
49
 
50
        rdy_cnt <= "00";        -- no wait states
51
 
52
--
53
--      The registered MUX is all we need for a SimpCon read.
54
--      The read data is stored in registered rd_data.
55
--
56
process(clk, reset)
57
begin
58
 
59
        if (reset='1') then
60
                rd_data <= (others => '0');
61
        elsif rising_edge(clk) then
62
 
63
                if rd='1' then
64
                        -- that's our very simple address decoder
65
                        if address(0)='0' then
66
                                rd_data <= std_logic_vector(cnt);
67
                        else
68
                                rd_data <= xyz;
69
                        end if;
70
                end if;
71
        end if;
72
 
73
end process;
74
 
75
 
76
--
77
--      SimpCon write is very simple
78
--
79
process(clk, reset)
80
 
81
begin
82
 
83
        if (reset='1') then
84
                xyz <= (others => '0');
85
                cnt <= (others => '0');
86
 
87
        elsif rising_edge(clk) then
88
 
89
                if wr='1' then
90
                        xyz <= wr_data;
91
                end if;
92
 
93
                cnt <= cnt+1;
94
 
95
        end if;
96
 
97
end process;
98
 
99
 
100
end rtl;

powered by: WebSVN 2.1.0

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