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

Subversion Repositories xucpu

[/] [xucpu/] [trunk/] [VHDL/] [queue_2/] [tb_prod_cons.vhdl] - Blame information for rev 7

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
USE work.mux_parts.ALL;
25
 
26
ENTITY tb_prod_cons IS
27
END ENTITY tb_prod_cons;
28
 
29
ARCHITECTURE Structural OF tb_prod_cons IS
30
 
31
  COMPONENT queue IS
32
    GENERIC (
33
      w_data : NATURAL := 16);
34
    PORT (
35
      rst   : IN  STD_LOGIC;
36
      clk   : IN  STD_LOGIC;
37
      we    : IN  STD_LOGIC;
38
      sh    : IN  STD_LOGIC;
39
      full  : OUT STD_LOGIC;
40
      empty : OUT STD_LOGIC;
41
      d     : IN  STD_LOGIC_VECTOR(w_data - 1 DOWNTO 0);
42
      q     : OUT STD_LOGIC_VECTOR(w_data - 1 DOWNTO 0));
43
  END COMPONENT queue;
44
 
45
  SIGNAL clock : STD_LOGIC := '0';
46
  SIGNAL reset : STD_LOGIC := '0';
47
 
48
  SIGNAL PC      : INTEGER RANGE 0 TO 1023 := 0;
49
  SIGNAL address : STD_LOGIC_VECTOR(9 DOWNTO 0);
50
  SIGNAL IR      : STD_LOGIC_VECTOR(15 DOWNTO 0);
51
  SIGNAL ENA     : STD_LOGIC;
52
 
53
  SIGNAL QF  : STD_LOGIC;
54
  SIGNAL NQF : STD_LOGIC;
55
 
56
  SIGNAL get : STD_LOGIC;
57
  SIGNAL c3  : INTEGER RANGE 0 TO 2;
58
 
59
BEGIN  -- ARCHITECTURE Structural
60
 
61
  -- Clock generator 50 MHz
62
  CLK1 : PROCESS IS
63
  BEGIN  -- PROCESS CLK1
64
    WAIT FOR 10 NS;
65
    clock <= '1';
66
    WAIT FOR 10 NS;
67
    clock <= '0';
68
  END PROCESS CLK1;
69
 
70
  -- Reset signaal
71
  RST1 : PROCESS IS
72
  BEGIN  -- PROCESS RST1
73
    WAIT FOR 65 NS;
74
    reset <= '1';
75
    WAIT FOR 120 NS;
76
    reset <= '0';
77
    WAIT;
78
  END PROCESS RST1;
79
 
80
  -- Programma teller met synchrone reset
81
  PC_CTR : PROCESS (clock, reset) IS
82
  BEGIN  -- PROCESS PC_CTR
83
    IF rising_edge(clock) THEN          -- rising clock edge
84
      IF reset = '1' THEN
85
        PC <= 0;
86
      ELSE
87
        IF ENA = '1' THEN
88
          IF PC < 1023 THEN
89
            PC <= PC + 1;
90
          ELSE
91
            PC <= 0;
92
          END IF;
93
        END IF;
94
      END IF;
95
    END IF;
96
  END PROCESS PC_CTR;
97
 
98
  address <= STD_LOGIC_VECTOR(TO_UNSIGNED(PC, 10));
99
 
100
  RAM1 : generic_ram
101
    GENERIC MAP (
102
      filename => "random_data.txt")
103
    PORT MAP (
104
      clk => clock,
105
      we  => '0',
106
      a1  => address(9 DOWNTO 0),
107
      a2  => "0000000000",
108
      d1  => X"0000",
109
      q1  => IR,
110
      q2  => OPEN);
111
 
112
  queue1 : queue
113
    PORT MAP (
114
      rst   => reset,
115
      clk   => clock,
116
      we    => ENA,
117
      sh    => get,
118
      full  => QF,
119
      empty => OPEN,
120
      d     => IR,
121
      q     => OPEN);
122
 
123
  ENA <= NOT QF;
124
 
125
  -- Consumer
126
  -- Generate a shift every three clockcycles
127
  -- Programma teller met synchrone reset
128
  GET_CTR : PROCESS (clock, reset) IS
129
  BEGIN  -- PROCESS GET_CTR
130
    IF rising_edge(clock) THEN          -- rising clock edge
131
 
132
      get <= '0';
133
 
134
      IF reset = '1' THEN
135
 
136
        C3 <= 0;
137
 
138
      ELSE
139
 
140
        IF c3 = 0 THEN
141
          c3 <= 1;
142
        ELSE
143
          c3 <= 0;
144
        END IF;
145
 
146
        IF C3 = 1 THEN
147
          get <= '1';
148
        END IF;
149
 
150
      END IF;
151
    END IF;
152
  END PROCESS GET_CTR;
153
 
154
END ARCHITECTURE Structural;

powered by: WebSVN 2.1.0

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