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

Subversion Repositories xucpu

[/] [xucpu/] [trunk/] [VHDL/] [pipeline/] [test_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 test_pipeline IS
25
 
26
END ENTITY test_pipeline;
27
 
28
ARCHITECTURE Structural OF test_pipeline IS
29
 
30
  COMPONENT pipeline_controller IS
31
 
32
    PORT (
33
    CLK  : IN  STD_LOGIC;
34
    RST  : IN  STD_LOGIC;
35
    SUM  : OUT STD_LOGIC;
36
    EN   : OUT STD_LOGIC_VECTOR(2 DOWNTO 0);
37
    FULL : OUT STD_LOGIC;
38
    PULL : IN  STD_LOGIC);
39
 
40
  END COMPONENT pipeline_controller;
41
 
42
  COMPONENT pipeline_reg IS
43
 
44
    PORT (
45
      D   : IN  STD_LOGIC_VECTOR(7 DOWNTO 0);
46
      Q   : OUT STD_LOGIC_VECTOR(7 DOWNTO 0);
47
      CLK : IN  STD_LOGIC;
48
      EN  : IN  STD_LOGIC);
49
 
50
  END COMPONENT pipeline_reg;
51
 
52
  COMPONENT processor IS
53
 
54
    PORT (
55
      CLK  : IN  STD_LOGIC;
56
      RST  : IN  STD_LOGIC;
57
      FULL : IN  STD_LOGIC;
58
      PULL : OUT STD_LOGIC;
59
      D_IN : IN  STD_LOGIC_VECTOR(7 DOWNTO 0));
60
 
61
  END COMPONENT processor;
62
 
63
  SIGNAL clock : STD_LOGIC := '0';
64
  SIGNAL reset : STD_LOGIC := '0';
65
 
66
  SIGNAL D0 : STD_LOGIC_VECTOR(7 DOWNTO 0);
67
  SIGNAL Q0 : STD_LOGIC_VECTOR(7 DOWNTO 0);
68
  SIGNAL D1 : STD_LOGIC_VECTOR(7 DOWNTO 0);
69
  SIGNAL Q1 : STD_LOGIC_VECTOR(7 DOWNTO 0);
70
  SIGNAL D2 : STD_LOGIC_VECTOR(7 DOWNTO 0);
71
  SIGNAL Q2 : STD_LOGIC_VECTOR(7 DOWNTO 0);
72
 
73
  SIGNAL EN : STD_LOGIC_VECTOR(2 DOWNTO 0) := "000";
74
  SIGNAL SUM : STD_LOGIC;
75
 
76
  SIGNAL FULL : STD_LOGIC;
77
  SIGNAL PULL : STD_LOGIC;
78
 
79
BEGIN  -- ARCHITECTURE Structural
80
 
81
  -- purpose: Clock generator
82
  --          This is simulation only
83
  -- type   : combinational
84
  -- inputs : 
85
  -- outputs: clock
86
  PROCESS IS
87
  BEGIN  -- PROCESS
88
    WAIT FOR 10 NS;
89
    clock <= '1';
90
 
91
    WAIT FOR 10 NS;
92
    clock <= '0';
93
 
94
  END PROCESS;
95
 
96
  -- purpose: Reset generator
97
  --          This is simulation only
98
  -- type   : combinational
99
  -- inputs : 
100
  -- outputs: RST
101
  PROCESS IS
102
  BEGIN  -- PROCESS
103
    WAIT FOR 17 NS;
104
    reset <= '1';
105
 
106
    WAIT FOR 31 NS;
107
    reset <= '0';
108
 
109
    WAIT;
110
  END PROCESS;
111
 
112
  -- End of simulation part
113
 
114
  -- Start of structural part
115
 
116
  -- purpose: Incrementing circuit
117
  -- type   : combinational
118
  -- inputs : Q0 (output from first pipeline register)
119
  -- outputs: D0 (input to first pipeline register)
120
  PROCESS (Q0, SUM) IS
121
  BEGIN  -- PROCESS
122
    IF SUM = '0' THEN
123
      D0 <= "00000000";
124
    ELSE
125
      IF Q0 = "11111111" THEN
126
        D0 <= "00000000";
127
      ELSE
128
        D0 <= STD_LOGIC_VECTOR(UNSIGNED(Q0) + 1);
129
      END IF;
130
    END IF;
131
  END PROCESS;
132
 
133
  -- Pipeline registers
134
  R0 : pipeline_reg PORT MAP (
135
    D   => D0,
136
    Q   => Q0,
137
    CLK => clock,
138
    EN  => EN(0));
139
 
140
  R1 : pipeline_reg PORT MAP (
141
    D   => D1,
142
    Q   => Q1,
143
    CLK => clock,
144
    EN  => EN(1));
145
 
146
  R2 : pipeline_reg PORT MAP (
147
    D   => D2,
148
    Q   => Q2,
149
    CLK => clock,
150
    EN  => EN(2));
151
 
152
  -- Interconnect pipeline registers
153
  D1 <= Q0;
154
  D2 <= Q1;
155
 
156
  CTRL : pipeline_controller PORT MAP (
157
    CLK  => clock,
158
    RST  => reset,
159
    SUM  => SUM,
160
    EN   => EN,
161
    FULL => FULL,
162
    PULL => PULL);
163
 
164
  PR1 : processor PORT MAP (
165
    CLK  => clock,
166
    RST  => reset,
167
    FULL => FULL,
168
    PULL => PULL,
169
    D_IN => Q2);
170
 
171
END ARCHITECTURE Structural;

powered by: WebSVN 2.1.0

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