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

Subversion Repositories simpcon

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

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 8 martin
--
2 29 martin
--
3
--  This file is a part of JOP, the Java Optimized Processor
4
--
5
--  Copyright (C) 2001-2008, Martin Schoeberl (martin@jopdesign.com)
6
--
7
--  This program is free software: you can redistribute it and/or modify
8
--  it under the terms of the GNU General Public License as published by
9
--  the Free Software Foundation, either version 3 of the License, or
10
--  (at your option) any later version.
11
--
12
--  This program is distributed in the hope that it will be useful,
13
--  but WITHOUT ANY WARRANTY; without even the implied warranty of
14
--  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
--  GNU General Public License for more details.
16
--
17
--  You should have received a copy of the GNU General Public License
18
--  along with this program.  If not, see <http://www.gnu.org/licenses/>.
19
--
20
 
21
 
22
--
23 8 martin
--      sc_test_slave.vhd
24
--
25
--      A simple test slave for the SimpCon interface
26
--      
27
--      Author: Martin Schoeberl        martin@jopdesign.com
28
--
29
--
30
--      resources on Cyclone
31
--
32
--              xx LCs, max xx MHz
33
--
34
--
35
--      2005-11-29      first version
36
--
37
--      todo:
38
--
39
--
40
 
41
 
42
library ieee;
43
use ieee.std_logic_1164.all;
44
use ieee.numeric_std.all;
45
 
46
entity sc_test_slave is
47
generic (addr_bits : integer);
48
 
49
port (
50
        clk             : in std_logic;
51
        reset   : in std_logic;
52
 
53
-- SimpCon interface
54
 
55
        address         : in std_logic_vector(addr_bits-1 downto 0);
56
        wr_data         : in std_logic_vector(31 downto 0);
57
        rd, wr          : in std_logic;
58
        rd_data         : out std_logic_vector(31 downto 0);
59
        rdy_cnt         : out unsigned(1 downto 0)
60
 
61
);
62
end sc_test_slave;
63
 
64
architecture rtl of sc_test_slave is
65
 
66
        signal xyz                      : std_logic_vector(31 downto 0);
67
        signal cnt                      : unsigned(31 downto 0);
68
 
69
begin
70
 
71
        rdy_cnt <= "00";        -- no wait states
72
 
73
--
74
--      The registered MUX is all we need for a SimpCon read.
75
--      The read data is stored in registered rd_data.
76
--
77
process(clk, reset)
78
begin
79
 
80
        if (reset='1') then
81
                rd_data <= (others => '0');
82
        elsif rising_edge(clk) then
83
 
84
                if rd='1' then
85
                        -- that's our very simple address decoder
86
                        if address(0)='0' then
87
                                rd_data <= std_logic_vector(cnt);
88
                        else
89
                                rd_data <= xyz;
90
                        end if;
91
                end if;
92
        end if;
93
 
94
end process;
95
 
96
 
97
--
98
--      SimpCon write is very simple
99
--
100
process(clk, reset)
101
 
102
begin
103
 
104
        if (reset='1') then
105
                xyz <= (others => '0');
106
                cnt <= (others => '0');
107
 
108
        elsif rising_edge(clk) then
109
 
110
                if wr='1' then
111
                        xyz <= wr_data;
112
                end if;
113
 
114
                cnt <= cnt+1;
115
 
116
        end if;
117
 
118
end process;
119
 
120
 
121
end rtl;

powered by: WebSVN 2.1.0

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