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 26

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 20 lcdsgmtr
USE work.RAM.ALL;
24 25 lcdsgmtr
USE work.hexio.ALL;
25 2 lcdsgmtr
 
26
-- Test bench for instatiating a memory and initialising
27
-- it from a file.
28
 
29
ENTITY tb_generic_ram IS
30
END ENTITY tb_generic_ram;
31
 
32
ARCHITECTURE Structural OF tb_generic_ram IS
33
 
34 26 lcdsgmtr
  CONSTANT w_addr : INTEGER := 15;
35 2 lcdsgmtr
 
36
  SIGNAL clock  : STD_LOGIC                             := '0';
37
  SIGNAL we     : STD_LOGIC                             := '0';
38
  SIGNAL data_a : STD_LOGIC_VECTOR(w_addr - 1 DOWNTO 0) := (OTHERS => '0');
39
  SIGNAL inst_a : STD_LOGIC_VECTOR(w_addr - 1 DOWNTO 0);
40
  SIGNAL data_i : STD_LOGIC_VECTOR(15 DOWNTO 0)         := (OTHERS => '0');
41
  SIGNAL data_o : STD_LOGIC_VECTOR(15 DOWNTO 0);
42
  SIGNAL inst_o : STD_LOGIC_VECTOR(15 DOWNTO 0);
43
 
44
  SIGNAL ctr_a : NATURAL RANGE 0 TO (2**w_addr - 1);
45 25 lcdsgmtr
  CONSTANT dummy : INTEGER := notify_f("Initialising tb_generic_ram");
46 2 lcdsgmtr
 
47
BEGIN  -- ARCHITECTURE Structural
48
 
49 25 lcdsgmtr
  -- purpose: Data dumping when simulation starts
50
  -- type   : combinational
51
  -- inputs : 
52
  -- outputs: 
53
  dump1: PROCESS IS
54
  BEGIN  -- PROCESS dump1
55
    notify("Simulation of tb_generic_ram starts");
56
    WAIT;
57
  END PROCESS dump1;
58
 
59 20 lcdsgmtr
  RAM1 : memory
60 2 lcdsgmtr
    GENERIC MAP (
61
      filename => "test_data.txt",
62 20 lcdsgmtr
      w_addr   => w_addr)
63 2 lcdsgmtr
    PORT MAP (
64
      clk => clock,
65
      we  => we,
66
      a1  => data_a,
67
      a2  => inst_a,
68
      d1  => data_i,
69
      q1  => data_o,
70
      q2  => inst_o);
71
 
72
  CTR1 : PROCESS (clock) IS
73
  BEGIN  -- PROCESS CTR1
74
    IF rising_edge(clock) THEN          -- rising clock edge
75 20 lcdsgmtr
      IF ctr_a = (2**w_addr) - 1 THEN
76 2 lcdsgmtr
        ctr_a <= 0;
77
      ELSE
78
        ctr_a <= ctr_a + 1;
79
      END IF;
80
    END IF;
81
  END PROCESS CTR1;
82
 
83
  inst_a <= STD_LOGIC_VECTOR(to_unsigned(ctr_a, w_addr));
84
 
85
  CLK1 : PROCESS IS
86
  BEGIN  -- PROCESS CLK1
87
    clock <= '0';
88
    WAIT FOR 10 NS;
89
    clock <= '1';
90
    WAIT FOR 10 NS;
91
  END PROCESS CLK1;
92
 
93
END ARCHITECTURE Structural;

powered by: WebSVN 2.1.0

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