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

Subversion Repositories xucpu

[/] [xucpu/] [trunk/] [VHDL/] [ROM/] [ROM.vhdl] - Blame information for rev 2

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
 
24
ENTITY rams_01 IS
25
  PORT (clk  : IN  STD_LOGIC;
26
        we   : IN  STD_LOGIC;
27
        en   : IN  STD_LOGIC;
28
        addr : IN  STD_LOGIC_VECTOR(5 DOWNTO 0);
29
        di   : IN  STD_LOGIC_VECTOR(15 DOWNTO 0);
30
        do   : OUT STD_LOGIC_VECTOR(15 DOWNTO 0));
31
END rams_01;
32
 
33
ARCHITECTURE syn OF rams_01 IS
34
 
35
  TYPE ram_type IS ARRAY (0 TO 63) OF STD_LOGIC_VECTOR (15 DOWNTO 0);
36
 
37
  SIGNAL RAM : ram_type :=
38
    (X"0000", X"0001", X"0002", X"0004", X"0008",
39
     X"0010", X"0020", X"0040", X"0080", X"0100",
40
     OTHERS => X"1111");
41
 
42
  ATTRIBUTE ram_style        : STRING;
43
  ATTRIBUTE ram_style OF RAM : SIGNAL IS "block";
44
 
45
BEGIN
46
 
47
  PROCESS (clk)
48
  BEGIN
49
    IF rising_edge(clk) THEN
50
      IF en = '1' THEN
51
        IF we = '1' THEN
52
          RAM(to_integer(UNSIGNED(addr))) <= di;
53
        END IF;
54
        do <= RAM(to_integer(UNSIGNED(addr)));
55
      END IF;
56
    END IF;
57
  END PROCESS;
58
 
59
END syn;
60
 
61
LIBRARY ieee;
62
USE ieee.std_logic_1164.ALL;
63
USE ieee.numeric_std.ALL;
64
 
65
ENTITY driver IS
66
 
67
  PORT (
68
    clk : IN  STD_LOGIC;
69
    led : OUT STD_LOGIC_VECTOR(7 DOWNTO 0));
70
 
71
END driver;
72
 
73
ARCHITECTURE Structural OF driver IS
74
 
75
  COMPONENT rams_01 IS
76
    PORT (clk  : IN  STD_LOGIC;
77
          we   : IN  STD_LOGIC;
78
          en   : IN  STD_LOGIC;
79
          addr : IN  STD_LOGIC_VECTOR(5 DOWNTO 0);
80
          di   : IN  STD_LOGIC_VECTOR(15 DOWNTO 0);
81
          do   : OUT STD_LOGIC_VECTOR(15 DOWNTO 0));
82
  END COMPONENT rams_01;
83
 
84
  SIGNAL counter : STD_LOGIC_VECTOR(5 DOWNTO 0) := "000000";
85
  SIGNAL result  : STD_LOGIC_VECTOR(15 DOWNTO 0);
86
 
87
BEGIN  -- Structural
88
 
89
  RAM1 : rams_01
90
    PORT MAP (
91
      clk  => clk,
92
      we   => '0',
93
      en   => '1',
94
      addr => counter,
95
      di   => X"0000",
96
      do   => result);
97
 
98
  PROCESS (clk)
99
  BEGIN  -- PROCESS
100
    IF rising_edge(clk) THEN
101
      IF counter = "111111" THEN
102
        counter <= "000000";
103
      ELSE
104
        counter <= STD_LOGIC_VECTOR(UNSIGNED(counter)
105
                                    + to_unsigned(1, 6));
106
      END IF;
107
    END IF;
108
  END PROCESS;
109
 
110
  led <= result(7 DOWNTO 0);
111
 
112
END Structural;

powered by: WebSVN 2.1.0

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