1
0
mirror of https://github.com/myhdl/myhdl.git synced 2025-01-24 21:52:56 +08:00
myhdl/example/manual/ram.vhd

47 lines
809 B
VHDL
Raw Normal View History

2008-11-22 22:40:25 +01:00
-- File: ram.vhd
2010-07-02 13:24:04 +02:00
-- Generated by MyHDL 0.7dev
-- Date: Fri Jul 2 13:23:51 2010
2008-11-22 22:40:25 +01:00
library IEEE;
use IEEE.std_logic_1164.all;
use IEEE.numeric_std.all;
use std.textio.all;
2010-07-02 13:24:04 +02:00
use work.pck_myhdl_07dev.all;
2008-11-22 22:40:25 +01:00
entity ram is
port (
dout: out unsigned(7 downto 0);
din: in unsigned(7 downto 0);
addr: in unsigned(6 downto 0);
we: in std_logic;
clk: in std_logic
);
end entity ram;
2010-07-02 13:24:04 +02:00
-- Ram model
2008-11-22 22:40:25 +01:00
architecture MyHDL of ram is
type t_array_mem is array(0 to 128-1) of unsigned(7 downto 0);
signal mem: t_array_mem;
begin
2010-07-02 13:24:04 +02:00
2008-11-22 22:40:25 +01:00
RAM_WRITE: process (clk) is
begin
if rising_edge(clk) then
if to_boolean(we) then
mem(to_integer(addr)) <= din;
end if;
end if;
end process RAM_WRITE;
2010-07-02 13:24:04 +02:00
2008-11-22 22:40:25 +01:00
dout <= mem(to_integer(addr));
end architecture MyHDL;