|
Message
From: cvs at opencores.org<cvs@o...>
Date: Wed Nov 30 11:46:58 CET 2005
Subject: [cvs-checkins] MODIFIED: simpcon ...
Date: 00/05/11 30:11:46 Added: simpcon/vhdl sc_test_slave.vhd sc_test_top.vhd Log: Test IO slave and simple IO top Revision Changes Path 1.1 simpcon/vhdl/sc_test_slave.vhd http://www.opencores.org/cvsweb.shtml/simpcon/vhdl/sc_test_slave.vhd?rev=1.1&content-type=text/x-cvsweb-markup Index: sc_test_slave.vhd =================================================================== -- -- sc_test_slave.vhd -- -- A simple test slave for the SimpCon interface -- -- Author: Martin Schoeberl martin@j... -- -- -- resources on Cyclone -- -- xx LCs, max xx MHz -- -- -- 2005-11-29 first version -- -- todo: -- -- library ieee; use ieee.std_logic_1164.all; use ieee.numeric_std.all; entity sc_test_slave is generic (addr_bits : integer); port ( clk : in std_logic; reset : in std_logic; -- SimpCon interface address : in std_logic_vector(addr_bits-1 downto 0); wr_data : in std_logic_vector(31 downto 0); rd, wr : in std_logic; rd_data : out std_logic_vector(31 downto 0); rdy_cnt : out unsigned(1 downto 0) ); end sc_test_slave; architecture rtl of sc_test_slave is signal xyz : std_logic_vector(31 downto 0); signal cnt : unsigned(31 downto 0); begin rdy_cnt <= "00"; -- no wait states -- -- The registered MUX is all we need for a SimpCon read. -- The read data is stored in registered rd_data. -- process(clk, reset) begin if (reset='1') then rd_data <= (others => '0'); elsif rising_edge(clk) then if rd='1' then -- that's our very simple address decoder if address(0)='0' then rd_data <= std_logic_vector(cnt); else rd_data <= xyz; end if; end if; end if; end process; -- -- SimpCon write is very simple -- process(clk, reset) begin if (reset='1') then xyz <= (others => '0'); cnt <= (others => '0'); elsif rising_edge(clk) then if wr='1' then
xyz <= wr_data;
end if;
cnt <= cnt+1;
end if;
end process;
end rtl;
1.1 simpcon/vhdl/sc_test_top.vhd
http://www.opencores.org/cvsweb.shtml/simpcon/vhdl/sc_test_top.vhd?rev=1.1&content-type=text/x-cvsweb-markup
Index: sc_test_top.vhd
===================================================================
--
-- scio_test_top.vhd
--
-- The top level to test SimpCon IO devices.
-- Do the address decoding here for the various slaves.
--
-- Author: Martin Schoeberl martin@j...
--
--
-- 2005-11-30 first version with two simple test slaves
--
--
--
library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;
use work.jop_types.all;
entity scio is
generic (addr_bits : integer);
port (
clk : in std_logic;
reset : in std_logic;
-- SimpCon interface
address : in std_logic_vector(addr_bits-1 downto 0);
wr_data : in std_logic_vector(31 downto 0);
rd, wr : in std_logic;
rd_data : out std_logic_vector(31 downto 0);
rdy_cnt : out unsigned(1 downto 0)
);
end scio;
architecture rtl of scio is
constant SLAVE_CNT : integer := 2;
constant SLAVE_ADDR_BITS : integer := 4;
type slave_bit is array(0 to SLAVE_CNT-1) of std_logic;
signal sc_rd, sc_wr : slave_bit;
type slave_dout is array(0 to SLAVE_CNT-1) of std_logic_vector(31 downto 0);
signal sc_dout : slave_dout;
type slave_rdy_cnt is array(0 to SLAVE_CNT-1) of unsigned(1 downto 0);
signal sc_rdy_cnt : slave_rdy_cnt;
signal rd_mux : std_logic;
begin
--
-- Connect two simple test slaves
--
gsl: for i in 0 to SLAVE_CNT-1 generate
wbsl: entity work.sc_test_slave
generic map (
-- shall we use less address bits inside the slaves?
addr_bits => SLAVE_ADDR_BITS
)
port map (
clk => clk,
reset => reset,
address => address(SLAVE_ADDR_BITS-1 downto 0),
wr_data => wr_data,
rd => sc_rd(i),
wr => sc_wr(i),
rd_data => sc_dout(i),
rdy_cnt => sc_rdy_cnt(i)
);
end generate;
--
-- Address decoding
--
process(address, rd, wr)
begin
-- How can we formulate this more elegant?
sc_rd(0) <= '0';
sc_wr(0) <= '0';
sc_rd(1) <= '0';
sc_wr(1) <= '0';
if address(SLAVE_ADDR_BITS)='0' then
sc_rd(0) <= rd;
sc_wr(0) <= wr;
else
sc_rd(1) <= rd;
sc_wr(1) <= wr;
end if;
end process;
--
-- Read mux selector
--
process(clk, reset)
begin
if (reset='1') then
rd_mux <= '0';
elsif rising_edge(clk) then
if rd='1' then
rd_mux <= address(SLAVE_ADDR_BITS);
end if;
end if;
end process;
--
-- Read data and rdy_cnt mux
--
-- Or should we simple or the rdy_cnt values?
--
process(rd_mux, sc_dout, sc_rdy_cnt)
begin
if rd_mux='0' then
rd_data <= sc_dout(0);
rdy_cnt <= sc_rdy_cnt(0);
else
rd_data <= sc_dout(1);
rdy_cnt <= sc_rdy_cnt(1);
end if;
end process;
end rtl;
|
 |