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

Subversion Repositories socwire

[/] [socwire/] [trunk/] [Switch/] [entrance.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 ..... entrance.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
USE IEEE.STD_LOGIC_UNSIGNED.ALL;
44
 
45
ENTITY entrance IS
46
  GENERIC(
47
          --== Number Of Ports ==--
48
 
49
          datawidth : NATURAL RANGE 8 TO 8192;
50
          nports : NATURAL RANGE 2 TO 32
51
         );
52
  PORT(
53
       --==  General Interface ==--
54
 
55
       clk     : IN  STD_LOGIC;
56
       rst     : IN  STD_LOGIC;
57
 
58
       --== Input Interface ==--
59
 
60
       nwrite  : IN  STD_LOGIC;
61
       full    : OUT STD_LOGIC;
62
       din     : IN  STD_LOGIC_VECTOR(datawidth DOWNTO 0);
63
 
64
       --== Connection Interface ==--
65
 
66
       full_in : IN  STD_LOGIC;
67
       connect : OUT STD_LOGIC;
68
       wanted  : OUT STD_LOGIC_VECTOR(nports-1 DOWNTO 0)
69
      );
70
END entrance;
71
 
72
 
73
ARCHITECTURE rtl OF entrance IS
74
 
75
---=========================---
76
--== Function Declarations ==--
77
---=========================---
78
 
79
FUNCTION ports2bus(nports : NATURAL RANGE 2 TO 32) RETURN NATURAL IS
80
BEGIN
81
  CASE nports IS
82
    WHEN 2        => RETURN 1;
83
    WHEN 3  TO  4 => RETURN 2;
84
    WHEN 5  TO  8 => RETURN 3;
85
    WHEN 9  TO 16 => RETURN 4;
86
    WHEN 17 TO 32 => RETURN 5;
87
  END CASE;
88
END ports2bus;
89
 
90
---=====================---
91
--== Type Declarations ==--
92
---=====================---
93
 
94
TYPE states IS
95
  (wait4hdr,
96
   transfer
97
  );
98
 
99
---=======================---
100
--== Signal Declarations ==--
101
---=======================---
102
 
103
SIGNAL state         : states;
104
SIGNAL ditch_data    : STD_LOGIC;
105
SIGNAL hw_addr       : STD_LOGIC_VECTOR(nports-1 DOWNTO 0);
106
SIGNAL wanted_int    : STD_LOGIC_VECTOR(nports-1 DOWNTO 0);
107
SIGNAL full_i        : STD_LOGIC;
108
 
109
BEGIN
110
 
111
  ---===========================---
112
  --== Create Hardware Address ==--
113
  ---===========================---
114
 
115
  G0 : FOR i IN 0 TO nports-1 GENERATE
116
    hw_addr(i) <= '1' WHEN (din(ports2bus(nports)-1 DOWNTO 0) = i) ELSE '0';
117
  END GENERATE G0;
118
 
119
 
120
  ---================================---
121
  --== Desired connection selection ==--
122
  ---================================---
123
 
124
  wanted_int <= hw_addr WHEN (state = wait4hdr) ELSE (others => '0');
125
 
126
  ---============================---
127
  --== Desired connection logic ==--
128
  ---============================---
129
 
130
  PROCESS(clk)
131
  BEGIN
132
    IF RISING_EDGE(clk) THEN
133
      IF (rst = '1') THEN
134
        wanted <= (OTHERS => '0');
135
      ELSIF (state = wait4hdr) THEN
136
        wanted <= wanted_int;
137
      END IF;
138
    END IF;
139
  END PROCESS;
140
 
141
 
142
  ---=================---
143
  --== State Machine ==--
144
  ---=================---
145
 
146
  PROCESS(clk)
147
  BEGIN
148
    IF RISING_EDGE(clk) THEN
149
      IF (rst = '1') THEN
150
        state <= wait4hdr;
151
        ditch_data <= '0';
152
        connect <= '0';
153
      ELSE
154
        CASE state IS
155
 
156
          WHEN wait4hdr =>
157
            IF (nwrite = '0') THEN
158
                ditch_data <= '1';
159
                connect <= '1';
160
                state <= transfer;
161
            END IF;
162
 
163
          WHEN transfer =>
164
            ditch_data <= '0';
165
            IF (nwrite = '0') AND (full_i = '0') AND (din(datawidth) = '1') THEN
166
              connect <= '0';
167
              state <= wait4hdr;
168
            END IF;
169
 
170
        END CASE;
171
      END IF;
172
    END IF;
173
  END PROCESS;
174
 
175
  ---========================---
176
  --== Drive output signals ==--
177
  ---========================---
178
 
179
  full_i <= '0' WHEN (ditch_data = '1') OR (full_in = '0') ELSE '1';
180
  full <= full_i;
181
 
182
END rtl;

powered by: WebSVN 2.1.0

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