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

Subversion Repositories socwire

[/] [socwire/] [trunk/] [Switch/] [matrix.vhd] - Blame information for rev 23

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 10 bjoerno
---====================== Start Software License ========================---
2
--==                                                                    ==--
3
--== This license governs the use of this software, and your use of     ==--
4
--== this software constitutes acceptance of this license. Agreement    ==--
5
--== with all points is required to use this software.                  ==--
6
--==                                                                    ==--
7
--== 1. This source file may be used and distributed without            ==--
8
--== restriction provided that this software license statement is not   ==--
9
--== removed from the file and that any derivative work contains the    ==--
10
--== original software license notice and the associated disclaimer.    ==--
11
--==                                                                    ==--
12
--== 2. This source file is free software; you can redistribute it      ==--
13
--== and/or modify it under the restriction that UNDER NO CIRCUMTANCES  ==--
14
--== this Software is to be used to CONSTRUCT a SPACEWIRE INTERFACE     ==--
15
--== This implies modification and/or derivative work of this Software. ==--
16
--==                                                                    ==--
17
--== 3. This source is distributed in the hope that it will be useful,  ==--
18
--== but WITHOUT ANY WARRANTY; without even the implied warranty of     ==--
19
--== MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.               ==--
20
--==                                                                    ==--
21
--== Your rights under this license are terminated immediately if you   ==--
22
--== breach it in any way.                                              ==--
23
--==                                                                    ==--
24
---======================= End Software License =========================---
25
 
26
 
27
---====================== Start Copyright Notice ========================---
28
--==                                                                    ==--
29
--== Filename ..... matrix.vhd                                          ==--
30
--== Download ..... http://www.ida.ing.tu-bs.de                         ==--
31
--== Company ...... IDA TU Braunschweig, Prof. Dr.-Ing. Harald Michalik ==--
32
--== Authors ...... Björn Osterloh, Karel Kotarowski                    ==--
33
--== Contact ...... Björn Osterloh (b.osterloh@tu-bs.de)                ==--
34
--== Copyright .... Copyright (c) 2008 IDA                              ==--
35
--== Project ...... SoCWire Switch                                      ==--
36
--== Version ...... 1.00                                                ==--
37
--== Conception ... 11 November 2008                                    ==--
38
--== Modified ..... N/A                                                 ==--
39
--==                                                                    ==--
40
---======================= End Copyright Notice =========================---
41
LIBRARY IEEE;
42
USE IEEE.STD_LOGIC_1164.ALL;
43
 
44
ENTITY matrix IS
45
  GENERIC(
46
          --== Number Of Ports ==--
47
 
48
          datawidth : NATURAL RANGE 8 TO 8192;
49
          nports : NATURAL RANGE 2 TO 32
50
         );
51
  PORT(
52
       --==  General Inputs ==--
53
 
54
       clk       : IN  STD_LOGIC;
55
       rst       : IN  STD_LOGIC;
56
 
57
       --== Input Interface ==--
58
 
59
       nwrite    : IN  STD_LOGIC_VECTOR(nports-1 DOWNTO 0);
60
       full      : OUT STD_LOGIC_VECTOR(nports-1 DOWNTO 0);
61
       din       : IN  STD_LOGIC_VECTOR((datawidth+1)*nports-1 DOWNTO 0);
62
 
63
       --== Output Interface ==--
64
 
65
       empty     : OUT STD_LOGIC_VECTOR(nports-1 DOWNTO 0);
66
       nread     : IN  STD_LOGIC_VECTOR(nports-1 DOWNTO 0);
67
       dout      : OUT STD_LOGIC_VECTOR((datawidth+1)*nports-1 DOWNTO 0);
68
 
69
       --== Vertical Inputs ==--
70
 
71
       op_eop    : IN  STD_LOGIC_VECTOR(nports-1 DOWNTO 0);
72
       op_active : IN  STD_LOGIC_VECTOR(nports-1 DOWNTO 0);
73
       op_wanted : IN  STD_LOGIC_VECTOR(nports*nports-1 DOWNTO 0);
74
 
75
       --== Horizontal Inputs ==--
76
 
77
       ip_eop    : IN  STD_LOGIC_VECTOR(nports-1 DOWNTO 0);
78
       connect   : IN  STD_LOGIC_VECTOR(nports-1 DOWNTO 0)
79
      );
80
END matrix;
81
 
82
ARCHITECTURE rtl OF matrix IS
83
 
84
---=========================---
85
--== Constant Declarations ==--
86
---=========================---
87
 
88
CONSTANT all_ones  : STD_LOGIC_VECTOR(nports-1 DOWNTO 0) := (OTHERS => '1');
89
CONSTANT all_zeros : STD_LOGIC_VECTOR(nports-1 DOWNTO 0) := (OTHERS => '0');
90
 
91
---==========================---
92
--== Component Declarations ==--
93
---==========================---
94
 
95
COMPONENT cell
96
  PORT(--==  General Inputs ==--
97
       clk                 : IN  STD_LOGIC;
98
       rst                 : IN  STD_LOGIC;
99
       --== Vertical Connectivity ==--
100
       op_eop              : IN  STD_LOGIC;
101
       op_active           : IN  STD_LOGIC;
102
       op_taken_in         : IN  STD_LOGIC;
103
       op_taken_out        : OUT STD_LOGIC;
104
       --== Horizontal Connectivity ==--
105
       enable              : IN  STD_LOGIC;
106
       connect             : IN  STD_LOGIC;
107
       ip_eop              : IN  STD_LOGIC;
108
       op_wanted           : IN  STD_LOGIC;
109
       ip_taken_in         : IN  STD_LOGIC;
110
       ip_taken_out        : OUT STD_LOGIC;
111
       connected           : OUT STD_LOGIC
112
      );
113
END COMPONENT;
114
 
115
 
116
---=======================---
117
--== Signal Declarations ==--
118
---=======================---
119
 
120
TYPE MULTIPLEX IS ARRAY(0 TO datawidth+1) OF STD_LOGIC_VECTOR(nports*nports-1 DOWNTO 0);
121
 
122
SIGNAL enable          : STD_LOGIC_VECTOR(nports-1 DOWNTO 0);
123
SIGNAL op_taken        : STD_LOGIC_VECTOR(nports*nports-1 DOWNTO 0);
124
SIGNAL ip_taken        : STD_LOGIC_VECTOR(nports*nports-1 DOWNTO 0);
125
SIGNAL connected       : STD_LOGIC_VECTOR(nports*nports-1 DOWNTO 0);
126
SIGNAL full_mux        : STD_LOGIC_VECTOR(nports*nports-1 DOWNTO 0);
127
SIGNAL empty_mux       : STD_LOGIC_VECTOR(nports*nports-1 DOWNTO 0);
128
SIGNAL dout_mux        : MULTIPLEX;
129
 
130
 
131
BEGIN
132
 
133
  ---===========================================---
134
  --== Data multiplexing and handshake routing ==--
135
  ---===========================================---
136
 
137
  GH : FOR h IN 0 TO nports-1 GENERATE
138
    GV : FOR v IN 0 TO nports-1 GENERATE
139
      full_mux(nports*h + v) <= nread(v) WHEN connected(nports*h + v) = '1' ELSE '1';
140
      empty_mux(nports*h + v) <= nwrite(v) WHEN connected(nports*v + h) = '1' ELSE '1';
141
      GI : FOR i IN 0 TO (datawidth) GENERATE
142
        dout_mux(i)(nports*h + v) <= din((datawidth+1)*v + i) WHEN connected(nports*v + h) = '1' ELSE '0';
143
      END GENERATE GI;
144
 
145
    END GENERATE GV;
146
    full(h) <= '1' WHEN (full_mux(nports*(h+1)-1 DOWNTO nports*h)) = all_ones ELSE '0';
147
    empty(h) <= '1' WHEN (empty_mux(nports*(h+1)-1 DOWNTO nports*h)) = all_ones ELSE '0';
148
    GJ : FOR j IN 0 TO (datawidth) GENERATE
149
    dout((datawidth+1)*h + j) <= '0' WHEN (dout_mux(j)(nports*(h+1)-1 DOWNTO nports*h)) = all_zeros ELSE '1';
150
    END GENERATE GJ;
151
  END GENERATE GH;
152
 
153
 
154
  ---=========================================---
155
  --== Connection cell pipeline enable logic ==--
156
  ---=========================================---
157
 
158
  PROCESS(clk)
159
  BEGIN
160
    IF RISING_EDGE(clk) THEN
161
      IF (rst = '1') THEN
162
        enable(nports-2 DOWNTO 0) <= (OTHERS => '0');
163
        enable(nports-1) <= '1';
164
      ELSE
165
        enable <= enable(nports-2 DOWNTO 0) & enable(nports-1);
166
      END IF;
167
    END IF;
168
  END PROCESS;
169
 
170
  ---===================---
171
  --== Connection Cell ==--
172
  ---===================---
173
 
174
  G0 : FOR h IN 0 TO nports-1 GENERATE
175
    G1 : FOR v IN 0 TO nports-1 GENERATE
176
      U0 : cell
177
        PORT MAP
178
          (--==  General Inputs ==--
179
           clk                 => clk,
180
           rst                 => rst,
181
           --== Vertical Connectivity ==--
182
           op_eop              => op_eop(h),
183
           op_active           => op_active(h),
184
           op_taken_in         => op_taken(h*nports + (v+nports-1) MOD nports),
185
           op_taken_out        => op_taken(h*nports + v),
186
           --== Horizontal Connectivity ==--
187
           enable              => enable((v + h) MOD nports),
188
           connect             => connect(v),
189
           ip_eop              => ip_eop(v),
190
           op_wanted           => op_wanted(v*nports + h),
191
           ip_taken_in         => ip_taken(v*nports + (h+nports-1) MOD nports),
192
           ip_taken_out        => ip_taken(v*nports + h),
193
           connected           => connected(v*nports + h)
194
          );
195
    END GENERATE G1;
196
  END GENERATE G0;
197
 
198
 
199
END rtl;

powered by: WebSVN 2.1.0

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