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

Subversion Repositories mkjpeg

[/] [mkjpeg/] [trunk/] [design/] [BufFifo/] [SUB_RAMZ_LUT.vhd] - Blame information for rev 67

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 67 mikel262
--------------------------------------------------------------------------------
2
--                                                                            --
3
--                          V H D L    F I L E                                --
4
--                          COPYRIGHT (C) 2006                                --
5
--                                                                            --
6
--------------------------------------------------------------------------------
7
--                                                                            --
8
-- Title       : SUB_RAMZ                                                         --
9
-- Design      : EV_JPEG_ENC                                                         --
10
-- Author      : Michal Krepa                                                 --                                                             --                                                           --
11
--                                                                            --
12
--------------------------------------------------------------------------------
13
--
14
-- File        : SUB_RAMZ.VHD
15
-- Created     : 22/03/2009
16
--
17
--------------------------------------------------------------------------------
18
--
19
--  Description : RAM memory simulation model
20
--
21
--------------------------------------------------------------------------------
22
 
23
library ieee;
24
use ieee.std_logic_1164.all;
25
use ieee.std_logic_unsigned.all;
26
use IEEE.NUMERIC_STD.all;
27
use IEEE.std_logic_textio.all;
28
 
29
library std;
30
use std.textio.all;
31
 
32
 
33
entity SUB_RAMZ_LUT is
34
  generic
35
    (
36
      RAMADDR_W     : INTEGER := 6;
37
      RAMDATA_W     : INTEGER := 12
38
    );
39
  port (
40
        d                 : in  STD_LOGIC_VECTOR(RAMDATA_W-1 downto 0);
41
        waddr             : in  STD_LOGIC_VECTOR(RAMADDR_W-1 downto 0);
42
        raddr             : in  STD_LOGIC_VECTOR(RAMADDR_W-1 downto 0);
43
        we                : in  STD_LOGIC;
44
        clk               : in  STD_LOGIC;
45
 
46
        q                 : out STD_LOGIC_VECTOR(RAMDATA_W-1 downto 0)
47
  );
48
end SUB_RAMZ_LUT;
49
 
50
architecture RTL of SUB_RAMZ_LUT is
51
  type mem_type is array ((2**RAMADDR_W)-1 downto 0) of
52
                              STD_LOGIC_VECTOR(RAMDATA_W-1 downto 0);
53
 
54
--type mem_type is array (( 1296*8)-1 downto 0) of --/*1296*8*/
55
  --                          STD_LOGIC_VECTOR(RAMDATA_W-1 downto 0);
56
 
57
  impure function InitRamFromFile (RamFileName : in string) return mem_type is
58
                FILE RamFile : text is in RamFileName;
59
                variable RamFileLine : line;
60
                variable RAM : mem_type;
61
        begin
62
                for I in 0 to (2**RAMADDR_W)-1 loop
63
                        readline (RamFile, RamFileLine);
64
                        --Write (RamFileLine, I * 8);
65
                        hread(RamFileLine, RAM(I));
66
 
67
 
68
                        --write(   (I * 8),RamFileLine );
69
                        --read (RamFileLine, RAM(I), LEFT, 10); 
70
                end loop;
71
                return RAM;
72
        end function;
73
 
74
  signal mem                    : mem_type := InitRamFromFile("../design/BufFifo/counter_8.txt") ;
75
  signal read_addr              : STD_LOGIC_VECTOR(RAMADDR_W-1 downto 0);
76
 
77
  --attribute ram_style: string;
78
  --attribute ram_style of mem : signal is "distributed"; 
79
 
80
 
81
begin
82
 
83
  -------------------------------------------------------------------------------
84
  q_sg:
85
  -------------------------------------------------------------------------------
86
  q <= mem(TO_INTEGER(UNSIGNED(read_addr)));
87
 
88
  -------------------------------------------------------------------------------
89
  read_proc: -- register read address
90
  -------------------------------------------------------------------------------
91
  process (clk)
92
  begin
93
    if clk = '1' and clk'event then
94
      read_addr <= raddr;
95
    end if;
96
  end process;
97
 
98
  -------------------------------------------------------------------------------
99
  write_proc: --write access
100
  -------------------------------------------------------------------------------
101
  process (clk) begin
102
    if clk = '1' and clk'event then
103
      if we = '1'  then
104
        mem(TO_INTEGER(UNSIGNED(waddr))) <= d;
105
      end if;
106
    end if;
107
  end process;
108
 
109
end RTL;

powered by: WebSVN 2.1.0

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