-
Notifications
You must be signed in to change notification settings - Fork 0
/
memoriaROM.vhd.bak
45 lines (39 loc) · 1.32 KB
/
memoriaROM.vhd.bak
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
library IEEE;
use IEEE.std_logic_1164.all;
use ieee.numeric_std.all;
entity memoriaROM is
generic (
dataWidth: natural := 4;
addrWidth: natural := 3
);
port (
Endereco : in std_logic_vector (addrWidth-1 DOWNTO 0);
Dado : out std_logic_vector (dataWidth-1 DOWNTO 0)
);
end entity;
architecture assincrona of memoriaROM is
constant NOP : std_logic_vector(3 downto 0) := "0000";
constant LDA : std_logic_vector(3 downto 0) := "0100";
constant SOMA : std_logic_vector(3 downto 0) := "1101";
constant SUB : std_logic_vector(3 downto 0) := "1100";
constant CLRA : std_logic_vector(3 downto 0) := "0010";
type blocoMemoria is array(0 TO 2**addrWidth - 1) of std_logic_vector(dataWidth-1 DOWNTO 0);
function initMemory
return blocoMemoria is variable tmp : blocoMemoria := (others => (others => '0'));
begin
-- Palavra de Controle = SelMUX, Habilita_A, Reset_A, Operacao_ULA
-- Inicializa os endereços:
tmp(0) := CLRA;
tmp(1) := SOMA;
tmp(2) := SOMA;
tmp(3) := SOMA;
tmp(4) := SUB;
tmp(5) := NOP;
tmp(6) := NOP;
tmp(7) := NOP;
return tmp;
end initMemory;
signal memROM : blocoMemoria := initMemory;
begin
Dado <= memROM (to_integer(unsigned(Endereco)));
end architecture;