OpenCores
URL https://opencores.org/ocsvn/igor/igor/trunk

Subversion Repositories igor

[/] [igor/] [trunk/] [processor/] [mc/] [reg_mem.vhd] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 atypic
library ieee;
2
 
3
use ieee.std_logic_1164.all;
4
use ieee.std_logic_unsigned.all;
5
use work.leval_package.all;
6
use ieee.numeric_std.all;
7
use std.textio.all;
8
 
9
entity reg_mem is
10
        port (
11
                clk : in std_logic;
12
                we : in std_logic;
13
                a : in std_logic_vector(SCRATCH_ADDR_SIZE - 1 downto 0);
14
                b : in std_logic_vector(SCRATCH_ADDR_SIZE - 1 downto 0);
15
                dia : in std_logic_vector(WORD_SIZE - 1 downto 0);
16
                doa : out std_logic_vector(WORD_SIZE - 1 downto 0);
17
                dob : out  std_logic_vector(WORD_SIZE - 1 downto 0)
18
        );
19
end entity reg_mem;
20
 
21
architecture behav of reg_mem is
22
        type ram_type is array (0 to SCRATCH_SIZE - 1) of bit_vector(WORD_SIZE - 1
23
        downto 0);
24
 
25
        signal read_a : std_logic_vector(SCRATCH_ADDR_SIZE - 1 downto 0);
26
        signal read_b : std_logic_vector(SCRATCH_ADDR_SIZE - 1 downto 0);
27
 
28
 
29
        impure function init_ram(filename : in string) return ram_type is
30
        file ramfile : text is in filename;
31
        variable li : line;
32
        variable RAM : ram_type;
33
        begin
34
                for i in ram_type'range loop
35
                        readline(ramfile, li);
36
                        read(li, RAM(i));
37
                end loop;
38
        return RAM;
39
        end function;
40
 
41
signal RAM : ram_type := init_ram("testing/mc10/regfile.foo");
42
begin
43
        process(clk)
44
                begin
45
                        if rising_edge(clk) then
46
                                if (we = '1') then
47
                                        RAM(to_integer(unsigned(a))) <= to_bitvector(dia);
48
                                end if;
49
                                read_a <= a;
50
                                read_b <= b;
51
                        end if;
52
        end process;
53
        doa <= to_stdlogicvector(RAM(to_integer(unsigned(read_a))));
54
        dob <= to_stdlogicvector(RAM(to_integer(unsigned(read_b))));
55
end behav;
56
 
57
 
58
 
59
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.