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

Subversion Repositories xucpu

[/] [xucpu/] [trunk/] [src/] [components/] [BRAM/] [tb_generic_ram.vhdl] - Blame information for rev 12

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

Line No. Rev Author Line
1 2 lcdsgmtr
-- Copyright 2015, Jürgen Defurne
2
--
3
-- This file is part of the Experimental Unstable CPU System.
4
--
5
-- The Experimental Unstable CPU System Is free software: you can redistribute
6
-- it and/or modify it under the terms of the GNU Lesser General Public License
7
-- as published by the Free Software Foundation, either version 3 of the
8
-- License, or (at your option) any later version.
9
--
10
-- The Experimental Unstable CPU System is distributed in the hope that it will
11
-- be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
12
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser
13
-- General Public License for more details.
14
--
15
-- You should have received a copy of the GNU Lesser General Public License
16
-- along with Experimental Unstable CPU System. If not, see
17
-- http://www.gnu.org/licenses/lgpl.txt.
18
 
19
 
20
LIBRARY ieee;
21
USE ieee.std_logic_1164.ALL;
22
USE ieee.numeric_std.ALL;
23
USE work.ram_parts.ALL;
24
 
25
-- Test bench for instatiating a memory and initialising
26
-- it from a file.
27
 
28
ENTITY tb_generic_ram IS
29
END ENTITY tb_generic_ram;
30
 
31
ARCHITECTURE Structural OF tb_generic_ram IS
32
 
33
  CONSTANT w_addr : INTEGER := 12;
34
 
35
  SIGNAL clock  : STD_LOGIC                             := '0';
36
  SIGNAL we     : STD_LOGIC                             := '0';
37
  SIGNAL data_a : STD_LOGIC_VECTOR(w_addr - 1 DOWNTO 0) := (OTHERS => '0');
38
  SIGNAL inst_a : STD_LOGIC_VECTOR(w_addr - 1 DOWNTO 0);
39
  SIGNAL data_i : STD_LOGIC_VECTOR(15 DOWNTO 0)         := (OTHERS => '0');
40
  SIGNAL data_o : STD_LOGIC_VECTOR(15 DOWNTO 0);
41
  SIGNAL inst_o : STD_LOGIC_VECTOR(15 DOWNTO 0);
42
 
43
  SIGNAL ctr_a : NATURAL RANGE 0 TO (2**w_addr - 1);
44
 
45
BEGIN  -- ARCHITECTURE Structural
46
 
47
  RAM1 : generic_ram
48
    GENERIC MAP (
49
      filename => "test_data.txt",
50
      w_addr   => 12)
51
    PORT MAP (
52
      clk => clock,
53
      we  => we,
54
      a1  => data_a,
55
      a2  => inst_a,
56
      d1  => data_i,
57
      q1  => data_o,
58
      q2  => inst_o);
59
 
60
  CTR1 : PROCESS (clock) IS
61
  BEGIN  -- PROCESS CTR1
62
    IF rising_edge(clock) THEN          -- rising clock edge
63
      IF ctr_a = 4095 THEN
64
        ctr_a <= 0;
65
      ELSE
66
        ctr_a <= ctr_a + 1;
67
      END IF;
68
    END IF;
69
  END PROCESS CTR1;
70
 
71
  inst_a <= STD_LOGIC_VECTOR(to_unsigned(ctr_a, w_addr));
72
 
73
  CLK1 : PROCESS IS
74
  BEGIN  -- PROCESS CLK1
75
    clock <= '0';
76
    WAIT FOR 10 NS;
77
    clock <= '1';
78
    WAIT FOR 10 NS;
79
  END PROCESS CLK1;
80
 
81
END ARCHITECTURE Structural;

powered by: WebSVN 2.1.0

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