我是 VHDL 编程的新手。该项目涉及检测内存阵列中的故障。我得到了错误的数据和地址。现在我想获取在内存数组中找到的特定地址的相应行号或列号。在 VHDL 中实现这一点的代码将不胜感激!这是我创建 SRAM 和执行读写操作的简单代码:
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
entity memory is
port( Clock : in std_logic;
Write : in std_logic;
Read : in std_logic;
-- Addr : in std_logic_vector(7 downto 0);
Data_in : in std_logic_vector(7 downto 0);
Data_out: out std_logic_vector(7 downto 0);
Data_out_f: out std_logic_vector(7 downto 0);
add_out : out std_logic_vector(7 downto 0)
);
end memory;
architecture behav of memory is
--Declaration of type and signal of a 256 element RAM
--with each element being 8 bit wide.
type ram_type is array (0 to 255) of std_logic_vector(7 downto 0);
signal tmp_ram: ram_type:=(others=>"00000000");
signal Addr : std_logic_vector(7 downto 0):="00000000";
begin
process(Clock,addr,Write,read)
begin
if (Clock'event and Clock='1') then
if addr <"00001111" and write='1' and Data_in(7)/='U' then
addr <= addr + '1';
elsif addr >"00000000" and read='1' then
addr <= addr - '1';
end if;
end if;
end process;
-- Write Functional Section
process(Clock,Write,Addr)
begin
if Write='1' then
tmp_ram(conv_integer(Addr)) <= Data_in;
end if;
end process;
process(Clock,Read,Addr)
begin
if Read='1' then
Data_out <= tmp_ram(conv_integer(Addr));
end if;
end process;
end behav;