搜索
bottom↓
回复: 3

求ssram读写控制资料

[复制链接]

出0入0汤圆

发表于 2010-4-27 15:56:11 | 显示全部楼层 |阅读模式
求ssram读写控制资料 求ssram读写控制资料 求ssram读写控制资料 求ssram读写控制资料

阿莫论坛20周年了!感谢大家的支持与爱护!!

该献的血还是要献的。你不献他不献。难道让我去献? --- 出自坛友:lovejp1981

出0入0汤圆

发表于 2010-4-27 16:12:08 | 显示全部楼层
这SSRAM容量上 价格上 性能上有优势吗

出0入0汤圆

 楼主| 发表于 2010-4-27 19:28:08 | 显示全部楼层
回复【1楼】888888888888
-----------------------------------------------------------------------

没办法,我正在学习,板上用的是ssram

出0入0汤圆

发表于 2011-2-2 03:02:23 | 显示全部楼层
--
--
--        S S R A M  i n t e r f a c e
--
-- various components for ssrams
--

library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_arith.all;

package SSRAM is
        component ssram_conn is
        generic(
                DWIDTH        : positive := 16;
                AWIDTH : positive := 18
        );
        port (
                clk : in std_logic;
                A : in unsigned(AWIDTH -1 downto 0);
                Din : in std_logic_vector(DWIDTH -1 downto 0);
                Dout : out std_logic_vector(DWIDTH -1 downto 0);
                rw : in std_logic;
                bw : in std_logic_vector((DWIDTH/8) downto 0) := (others => '0');

                ssramA : out unsigned(AWIDTH -1 downto 0);
                ssramD : inout std_logic_vector(DWIDTH -1 downto 0);
                ssramRW : out std_logic;
                ssramBW : out std_logic_vector((DWIDTH/8) downto 0)
        );
        end component ssram_conn;

        component cs_ssram is
        generic(
                DWIDTH : positive := 16;
                AWIDTH : positive := 18
        );
        port (
                clk : in std_logic;
                clk_div2 : in std_logic;                -- clk divided by 2

                p0_A : in unsigned(AWIDTH -1 downto 0);
                p0_Din : in std_logic_vector(DWIDTH -1 downto 0);
                p0_Dout : out std_logic_vector(DWIDTH -1 downto 0);
                p0_rw : in std_logic;
                p0_bw : in std_logic_vector((DWIDTH/8) downto 0) := (others => '0');

                p1_A : in unsigned(AWIDTH -1 downto 0);
                p1_Din : in std_logic_vector(DWIDTH -1 downto 0);
                p1_Dout : out std_logic_vector(DWIDTH -1 downto 0);
                p1_rw : in std_logic;
                p1_bw : in std_logic_vector((DWIDTH/8) downto 0) := (others => '0');

                ssramA : out unsigned(AWIDTH -1 downto 0);
                ssramD : inout std_logic_vector(DWIDTH -1 downto 0);
                ssramRW : out std_logic;
                ssramBW : out std_logic_vector((DWIDTH/8) downto 0)
        );
        end component cs_ssram;

end package SSRAM;

--
--
-- SSRAM cycle shared memory implementation
--
-- ssram can be accessed by 2 ports at clk_div2 frequency. SSRAM operates at clk frequency
-- clk_div2 is actually a clk_en signal (no extra clock-domain)
--
-- read command: data valid after 3 clk_div2 cycles
-- 1) set address, RW = '1' (read command)
-- 2) present address/RW to ssram
-- 3) ssram presents data
-- 4) data (p0_dout/p1_dout) valid
-- 5) take/use data
--
-- note: p0_dout Tsu = 1 clk_div2 cycle
--       p1_dout Tsu = 1 clk cycle (so half of p0_dout Tsu)

library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_arith.all;

entity cs_ssram is
        generic(
                DWIDTH : positive := 16;
                AWIDTH : positive := 18
        );
        port (
                clk : in std_logic;
                clk_div2 : in std_logic;                -- clk divided by 2

                p0_A : in unsigned(AWIDTH -1 downto 0);
                p0_Din : in std_logic_vector(DWIDTH -1 downto 0);
                p0_Dout : out std_logic_vector(DWIDTH -1 downto 0);
                p0_rw : in std_logic;
                p0_bw : in std_logic_vector((DWIDTH/8) downto 0) := (others => '0');

                p1_A : in unsigned(AWIDTH -1 downto 0);
                p1_Din : in std_logic_vector(DWIDTH -1 downto 0);
                p1_Dout : out std_logic_vector(DWIDTH -1 downto 0);
                p1_rw : in std_logic;
                p1_bw : in std_logic_vector((DWIDTH/8) downto 0) := (others => '0');

                ssramA : out unsigned(AWIDTH -1 downto 0);
                ssramD : inout std_logic_vector(DWIDTH -1 downto 0);
                ssramRW : out std_logic;
                ssramBW : out std_logic_vector((DWIDTH/8) downto 0)
        );
end entity cs_ssram;

architecture structural of cs_ssram is
        component ssram_conn is
        generic(
                DWIDTH        : positive;
                AWIDTH : positive
        );
        port (
                clk : in std_logic;
                A : in unsigned(AWIDTH -1 downto 0);
                Din : in std_logic_vector(DWIDTH -1 downto 0);
                Dout : out std_logic_vector(DWIDTH -1 downto 0);
                rw : in std_logic;
                bw : in std_logic_vector((DWIDTH/8) downto 0) := (others => '0');

                ssramA : out unsigned(AWIDTH -1 downto 0);
                ssramD : inout std_logic_vector(DWIDTH -1 downto 0);
                ssramRW : out std_logic;
                ssramBW : out std_logic_vector((DWIDTH/8) downto 0)
        );
        end component ssram_conn;

        signal A : unsigned(AWIDTH -1 downto 0);
        signal Din : std_logic_vector(DWIDTH -1 downto 0);        -- from SSRAMs
        signal Dout : std_logic_vector(DWIDTH -1 downto 0);        -- towards SSRAMs
        signal BW : std_logic_vector((DWIDTH/8) downto 0);
        signal RW : std_logic;
begin

        -- mux address / data-in / rw / bw
        gen_muxs: process (clk)
                variable iA : unsigned(AWIDTH -1 downto 0);
                variable iDout : std_logic_vector(DWIDTH -1 downto 0);
                variable iRW : std_logic;
                variable iBW : std_logic_vector((DWIDTH/8) downto 0);
        begin
                if (clk_div2 = '0') then
                        iA := p0_A;
                        iDout := p0_Din;
                        iRW := p0_rw;
                        for n in 0 to (DWIDTH/8) loop
                                iBW(n) := p0_bw(n);
                        end loop;
                else -- clk_div2 = '1'
                        iA := p1_A;
                        iDout := p1_Din;
                        iRW := p1_rw;
                        for n in 0 to (DWIDTH/8) loop
                                iBW(n) := p1_bw(n);
                        end loop;
                end if;

                if (clk'event and clk = '1') then
                        A <= iA;
                        Dout <= iDout;
                        RW <= iRW;
                        BW <= iBW;       
                end if;
        end process gen_muxs;

        -- instert ssram IO controller
        ssram_io_ctrl: ssram_conn generic map (DWIDTH => DWIDTH, AWIDTH => AWIDTH)
                        port map (clk, A, Dout, Din, RW, bw, ssramA, ssramD, ssramRW, ssramBW);

        -- demux data from ssram
        demux_din: process(clk)
        begin
                if (clk'event and clk = '1') then
                        if (clk_div2 = '1') then        -- switched
                                p0_Dout <= Din;
                        else
                                p1_Dout <= Din;
                        end if;
                end if;
        end process demux_din;

end architecture structural; -- of cs_ssram

--
--
--        SSRAM physical connection (IO) controller
--
--
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_arith.all;

entity ssram_conn is
        generic(
                DWIDTH        : positive := 16;
                AWIDTH : positive := 18
        );
        port (
                clk : in std_logic;
                A : in unsigned(AWIDTH -1 downto 0);
                Din : in std_logic_vector(DWIDTH -1 downto 0);
                Dout : out std_logic_vector(DWIDTH -1 downto 0);
                rw : in std_logic;
                bw : in std_logic_vector((DWIDTH/8) downto 0) := (others => '0');

                ssramA : out unsigned(AWIDTH -1 downto 0);
                ssramD : inout std_logic_vector(DWIDTH -1 downto 0);
                ssramRW : out std_logic;
                ssramBW : out std_logic_vector((DWIDTH/8) downto 0)
        );
end entity ssram_conn;

architecture structural of ssram_conn is
        signal dD, ddD, dddD : std_logic_vector(DWIDTH -1 downto 0);
        signal dsel, ddsel : std_logic;
        signal dddSel : std_logic_vector(DWIDTH -1 downto 0);
        attribute preserve_signal : boolean;
        attribute preserve_signal of dddSel: signal is true;        -- instruct compiler to leave these signals
        attribute preserve_signal of dddD: signal is true;
begin
        process(clk, dddD, dddSel)
        begin
                if(clk'event and clk = '1') then
                        -- compensate ssram pipeline delay
                        dD <= Din;                                                -- present address / rw
                        ddD <= dD;                                                -- ssram takes address / rw over
                        dddD <= ddD;                                        -- present data
                        dsel <= not RW;
                        ddsel <= dsel;

                        for n in 0 to (DWIDTH -1) loop
                                dddsel(n) <= ddsel;
                        end loop;

                        Dout <= ssramD;
                        ssramA <= A;
                        ssramRW <= RW;
                        ssramBW <= BW;
                end if;

                for n in 0 to (DWIDTH -1) loop
                        if (dddSel(n) = '1') then
                                ssramD(n) <= dddD(n);
                        else
                                ssramD(n) <= 'Z';
                        end if;
                end loop;

        end process;
end architecture structural; -- of ssram_conn
回帖提示: 反政府言论将被立即封锁ID 在按“提交”前,请自问一下:我这样表达会给举报吗,会给自己惹麻烦吗? 另外:尽量不要使用Mark、顶等没有意义的回复。不得大量使用大字体和彩色字。【本论坛不允许直接上传手机拍摄图片,浪费大家下载带宽和论坛服务器空间,请压缩后(图片小于1兆)才上传。压缩方法可以在微信里面发给自己(不要勾选“原图),然后下载,就能得到压缩后的图片。注意:要连续压缩2次才能满足要求!!】。另外,手机版只能上传图片,要上传附件需要切换到电脑版(不需要使用电脑,手机上切换到电脑版就行,页面底部)。
您需要登录后才可以回帖 登录 | 注册

本版积分规则

手机版|Archiver|amobbs.com 阿莫电子技术论坛 ( 粤ICP备2022115958号, 版权所有:东莞阿莫电子贸易商行 创办于2004年 (公安交互式论坛备案:44190002001997 ) )

GMT+8, 2024-8-27 21:21

© Since 2004 www.amobbs.com, 原www.ourdev.cn, 原www.ouravr.com

快速回复 返回顶部 返回列表