【发布时间】:2019-04-12 14:00:34
【问题描述】:
我有一个 FPGA 试图读取/写入同一芯片上的 SDRAM 值。 sdram 将其视为 IN,顶层视为 OUT,否则。 SDRAM“路径”被实例化并被带到顶层。这些路径没有方向。但是,我知道顶层读取和写入 sdram。我尝试了显示的代码的变体并编译了它。下面的代码是将两个值传递给 SDRAM 并读取第三个值的示例。我已经为路径指定了方向。我的逻辑是否正确,因为它发送两个值并接收第三个?
使用 IEEE.STD_LOGIC_UNSIGNED.ALL; -- 参见使用 VHDL 进行电路设计的第 36 页
port(
-- ---------------------------------------------------------------------
-- Global signals ------------------------------------------------------
CLK : in std_logic;
RESET : in std_logic;
A : out std_logic_vector(15 downto 0);
B : out std_logic_vector(15 downto 0);
C : in std_logic_vector(15 downto 0);
结束实体 sigma_k_top;
function_top 的架构 rtl 是
signal cntr : std_logic_vector(31 downto 0);
signal sig_A : std_logic_vector(15 downto 0);
signal sig_B : std_logic_vector(15 downto 0);
signal sig_C : std_logic_vector(15 downto 0);
开始
sdram_inst : entity work.sdram
port map (
CLK => sdram_CLK_in, --CLK shared by all
A => sdram_A_in, -- Write to sdram
B => sdram_B_in,-- Write to sdram
C => sdram_C_out, --Read from sdram
);
transfer: process(CLK)
begin
IF rising_edge(CLK) then
cntr <= cntr + 1;
if cntr = 1000 then --
sig_A <= "1000000000000000";
sig_B <= "1000000000000000";
end if;
if cntr = 1001 then
if C(0) = '1' then
sig_A <= sig_A - 1; -- Writing
sig_B <= sig_B + 1; -- Writing
xfer <= C ; -- Reading
end if;
end if;
if cntr > 2000 then
cntr <= (others => '0');
end if;
END IF;
end process;
-- -------------------------------------------------------------------------
-- Top-level ports ---------------------------------------------------------
TEST_LED(7 downto 0) <= xfer(7 downto 0); -- Making some sdram output visible
A <= sig_A; -- Sending value to sdram
B <= sig_B; -- Sending value to sdram
结束架构 rtl;
【问题讨论】: