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

Subversion Repositories mkjpeg

[/] [mkjpeg/] [trunk/] [design/] [JFIFGen/] [HeaderRAM.vhd] - Blame information for rev 67

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 66 mikel262
LIBRARY ieee, std;
2
USE ieee.std_logic_1164.ALL;
3
USE ieee.numeric_std.ALL;
4
use ieee.std_logic_textio.all;
5
use std.textio.all;
6 65 mikel262
 
7 66 mikel262
ENTITY HeaderRam IS
8
        GENERIC
9
        (
10
                ADDRESS_WIDTH   : integer := 10;
11
                DATA_WIDTH              : integer := 8
12
        );
13
        PORT
14
        (
15
                clk                             : IN  std_logic;
16
                d                               : IN  std_logic_vector(DATA_WIDTH - 1 DOWNTO 0);
17
                waddr                   : IN  std_logic_vector(ADDRESS_WIDTH - 1 DOWNTO 0);
18
                raddr                   : IN  std_logic_vector(ADDRESS_WIDTH - 1 DOWNTO 0);
19
                we                              : IN  std_logic;
20
                q                               : OUT std_logic_vector(DATA_WIDTH - 1 DOWNTO 0)
21
        );
22
END HeaderRam;
23 65 mikel262
 
24 66 mikel262
ARCHITECTURE rtl OF HeaderRam IS
25
 
26
TYPE RamType IS ARRAY(0 TO 2 ** ADDRESS_WIDTH - 1) OF std_logic_vector(DATA_WIDTH - 1 DOWNTO 0);
27
 
28
impure function InitRamFromFile(RamFileName : in string) return RamType is
29
        FILE RamFile : text is in RamFileName;
30
        variable RamFileLine : line;
31
        variable RAM : RamType;
32 65 mikel262
begin
33 66 mikel262
        for l in RamType'range loop
34
                readline(RamFile, RamFileLine);
35
                hread(RamFileLine, RAM(l));
36
        end loop;
37
        return RAM;
38
end function;
39
 
40
--SIGNAL ram_block : RamType := InitRamFromFile("../design/jfifgen/header.hex");
41
SIGNAL ram_block : RamType;
42
attribute ram_init_file : string;
43
attribute ram_init_file of ram_block :
44
signal is "./src/jpg/JFIFGen/header.mif";
45
BEGIN
46
        PROCESS (clk)
47
        BEGIN
48
                IF (clk'event AND clk = '1') THEN
49
                        IF (we = '1') THEN
50
                            ram_block(to_integer(unsigned(waddr))) <= d;
51
                        END IF;
52
 
53
                        q <= ram_block(to_integer(unsigned(raddr)));
54
                END IF;
55
        END PROCESS;
56
END rtl;

powered by: WebSVN 2.1.0

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