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

Subversion Repositories xucpu

[/] [xucpu/] [trunk/] [VHDL/] [pipeline/] [memory_pipeline.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 memory_pipeline IS
25
 
26
END ENTITY memory_pipeline;
27
 
28
ARCHITECTURE Structural OF memory_pipeline IS
29
 
30
  COMPONENT reset IS
31
 
32
    PORT (
33
      RST : OUT STD_LOGIC);
34
 
35
  END COMPONENT reset;
36
 
37
  COMPONENT clock IS
38
 
39
    PORT (
40
      CLK : OUT STD_LOGIC);
41
 
42
  END COMPONENT clock;
43
 
44
  COMPONENT multiplexer IS
45
 
46
    PORT (
47
      SEL : IN  STD_LOGIC_VECTOR(1 DOWNTO 0);
48
      S0  : IN  STD_LOGIC_VECTOR(7 DOWNTO 0);
49
      S1  : IN  STD_LOGIC_VECTOR(7 DOWNTO 0);
50
      S2  : IN  STD_LOGIC_VECTOR(7 DOWNTO 0);
51
      S3  : IN  STD_LOGIC_VECTOR(7 DOWNTO 0);
52
      Y   : OUT STD_LOGIC_VECTOR(7 DOWNTO 0));
53
 
54
  END COMPONENT multiplexer;
55
 
56
  COMPONENT adder IS
57
 
58
    PORT (
59
      ADDEND : IN  STD_LOGIC_VECTOR(7 DOWNTO 0);
60
      SUM    : OUT STD_LOGIC_VECTOR(7 DOWNTO 0));
61
 
62
  END COMPONENT adder;
63
 
64
  COMPONENT pipeline_reg IS
65
 
66
    PORT (
67
      D   : IN  STD_LOGIC_VECTOR(7 DOWNTO 0);
68
      Q   : OUT STD_LOGIC_VECTOR(7 DOWNTO 0);
69
      CLK : IN  STD_LOGIC;
70
      EN  : IN  STD_LOGIC);
71
 
72
  END COMPONENT pipeline_reg;
73
 
74
  COMPONENT memory IS
75
 
76
    PORT (
77
      CLK     : IN  STD_LOGIC;
78
      ADDRESS : IN  STD_LOGIC_VECTOR(7 DOWNTO 0);
79
      Q       : OUT STD_LOGIC_VECTOR(7 DOWNTO 0));
80
 
81
  END COMPONENT memory;
82
 
83
  COMPONENT memory_controller IS
84
 
85
    PORT (
86
      RST  : IN  STD_LOGIC;
87
      CLK  : IN  STD_LOGIC;
88
      SEL  : OUT STD_LOGIC_VECTOR(1 DOWNTO 0);
89
      EN0  : OUT STD_LOGIC;
90
      EN1  : OUT STD_LOGIC;
91
      FULL : OUT STD_LOGIC;
92
      PULL : IN  STD_LOGIC);
93
 
94
  END COMPONENT memory_controller;
95
 
96
  COMPONENT memory_processor IS
97
 
98
    PORT (
99
      CLK  : IN  STD_LOGIC;
100
      RST  : IN  STD_LOGIC;
101
      INST : IN  STD_LOGIC_VECTOR(7 DOWNTO 0);
102
      FULL : IN  STD_LOGIC;
103
      PULL : OUT STD_LOGIC);
104
 
105
  END COMPONENT memory_processor;
106
 
107
  -- Driving signals
108
  SIGNAL CLK : STD_LOGIC;
109
  SIGNAL RST : STD_LOGIC;
110
 
111
  -- Data signals
112
  SIGNAL address : STD_LOGIC_VECTOR(7 DOWNTO 0);
113
  SIGNAL pc      : STD_LOGIC_VECTOR(7 DOWNTO 0);
114
  SIGNAL inc     : STD_LOGIC_VECTOR(7 DOWNTO 0);
115
  SIGNAL mem_out : STD_LOGIC_VECTOR(7 DOWNTO 0);
116
  SIGNAL ir      : STD_LOGIC_VECTOR(7 DOWNTO 0);
117
 
118
  -- Control signals
119
  SIGNAL SEL  : STD_LOGIC_VECTOR(1 DOWNTO 0);
120
  SIGNAL EN0  : STD_LOGIC;
121
  SIGNAL EN1  : STD_LOGIC;
122
  SIGNAL FULL : STD_LOGIC;
123
  SIGNAL PULL : STD_LOGIC;
124
 
125
BEGIN  -- ARCHITECTURE Structural
126
 
127
  CLK1 : clock PORT MAP (
128
    CLK => CLK);
129
 
130
  RST1 : reset PORT MAP (
131
    RST => RST);
132
 
133
  M1 : multiplexer PORT MAP (
134
    SEL => SEL,
135
    S0  => X"00",
136
    S1  => pc,
137
    S2  => inc,
138
    S3  => X"00",
139
    Y   => address);
140
 
141
  -- Program counter register
142
  R0 : pipeline_reg PORT MAP (
143
    D   => address,
144
    Q   => pc,
145
    CLK => CLK,
146
    EN  => EN0);
147
 
148
  -- Increment
149
  I1 : adder PORT MAP (
150
    ADDEND => pc,
151
    SUM    => inc);
152
 
153
  -- Memory
154
  MEM1 : memory PORT MAP (
155
    CLK     => CLK,
156
    ADDRESS => address,
157
    Q       => mem_out);
158
 
159
  -- Output register
160
  R2 : pipeline_reg PORT MAP (
161
    D   => mem_out,
162
    Q   => ir,
163
    CLK => CLK,
164
    EN  => EN1);
165
 
166
  -- Controller
167
  CTRL1 : memory_controller PORT MAP (
168
    RST  => RST,
169
    CLK  => CLK,
170
    SEL  => SEL,
171
    EN0  => EN0,
172
    EN1  => EN1,
173
    FULL => FULL,
174
    PULL => PULL);
175
 
176
  -- Processor
177
  CTRL2 : memory_processor PORT MAP (
178
    CLK  => CLK,
179
    RST  => RST,
180
    INST => ir,
181
    FULL => FULL,
182
    PULL => PULL);
183
END ARCHITECTURE Structural;

powered by: WebSVN 2.1.0

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