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

Subversion Repositories risc5x

[/] [risc5x/] [trunk/] [mux8.vhd] - Blame information for rev 3

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 mikej
--
2
-- Risc5x
3
-- www.OpenCores.Org - November 2001
4
--
5
--
6
-- This library is free software; you can distribute it and/or modify it
7
-- under the terms of the GNU Lesser General Public License as published
8
-- by the Free Software Foundation; either version 2.1 of the License, or
9
-- (at your option) any later version.
10
--
11
-- This library is distributed in the hope that it will be useful, but
12
-- WITHOUT ANY WARRANTY; without even the implied warranty of
13
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
14
-- See the GNU Lesser General Public License for more details.
15
--
16
-- A RISC CPU core.
17
--
18
-- (c) Mike Johnson 2001. All Rights Reserved.
19
-- mikej@opencores.org for support or any other issues.
20
--
21
-- Revision list
22
--
23
-- version 1.0 initial opencores release
24
--
25
 
26
library ieee;
27
  use ieee.std_logic_1164.all;
28
  use ieee.std_logic_arith.all;
29
  use ieee.std_logic_unsigned.all;
30
 
31
entity MUX8 is
32
  generic (
33
    WIDTH         : in  natural := 8;
34
    OP_REG        : in  boolean := FALSE
35
    );
36
  port (
37
    DIN7          : in  std_logic_vector(WIDTH-1 downto 0);
38
    DIN6          : in  std_logic_vector(WIDTH-1 downto 0);
39
    DIN5          : in  std_logic_vector(WIDTH-1 downto 0);
40
    DIN4          : in  std_logic_vector(WIDTH-1 downto 0);
41
    DIN3          : in  std_logic_vector(WIDTH-1 downto 0);
42
    DIN2          : in  std_logic_vector(WIDTH-1 downto 0);
43
    DIN1          : in  std_logic_vector(WIDTH-1 downto 0);
44
    DIN0          : in  std_logic_vector(WIDTH-1 downto 0);
45
 
46
    SEL           : in  std_logic_vector(2 downto 0);
47
    ENA           : in  std_logic;
48
    CLK           : in  std_logic;
49
 
50
    DOUT          : out std_logic_vector(WIDTH-1 downto 0)
51
    );
52
end;
53
--
54
-- USE THIS ARCHITECTURE FOR XILINX
55
--
56
use work.pkg_xilinx_prims.all;
57
library ieee;
58
  use ieee.std_logic_1164.all;
59
  use ieee.std_logic_arith.all;
60
  use ieee.std_logic_unsigned.all;
61
 
62
architecture VIRTEX of MUX8 is
63
 
64
  signal dout_int : std_logic_vector(WIDTH-1 downto 0);
65
  signal mux8_01  : std_logic_vector(WIDTH-1 downto 0);
66
  signal mux8_23  : std_logic_vector(WIDTH-1 downto 0);
67
  signal mux8_45  : std_logic_vector(WIDTH-1 downto 0);
68
  signal mux8_67  : std_logic_vector(WIDTH-1 downto 0);
69
  signal mux8_03  : std_logic_vector(WIDTH-1 downto 0);
70
  signal mux8_47  : std_logic_vector(WIDTH-1 downto 0);
71
 
72
begin -- architecture
73
 
74
  ram_bit : for i in 0 to WIDTH-1 generate
75
  attribute RLOC of mux8_lut1,mux8_lut2 : label is "R" & integer'image((WIDTH -1)-i) & "C0.S1";
76
  attribute RLOC of mux8_lut3,mux8_lut4 : label is "R" & integer'image((WIDTH -1)-i) & "C0.S0";
77
  attribute RLOC of mux8_muxf5_1 : label is "R" & integer'image((WIDTH -1)-i) & "C0.S1";
78
  attribute RLOC of mux8_muxf5_2 : label is "R" & integer'image((WIDTH -1)-i) & "C0.S0";
79
  attribute RLOC of mux8_muxf6_1 : label is "R" & integer'image((WIDTH -1)-i) & "C0.S0";
80
 
81
  attribute INIT  of mux8_lut1 : label is "00CA";
82
  attribute INIT  of mux8_lut2 : label is "00CA";
83
  attribute INIT  of mux8_lut3 : label is "00CA";
84
  attribute INIT  of mux8_lut4 : label is "00CA";
85
  begin
86
 
87
    mux8_lut1:  LUT4
88
      --pragma translate_off
89
      generic map (
90
        INIT => str2slv(mux8_lut1'INIT)
91
        )
92
      --pragma translate_on
93
      port map (
94
        I0 => DIN0(i),
95
        I1 => DIN1(i),
96
        I2 => SEL(0),
97
        I3 => '0',
98
        O  => mux8_01(i));
99
 
100
    mux8_lut2:  LUT4
101
      --pragma translate_off
102
      generic map (
103
        INIT => str2slv(mux8_lut2'INIT)
104
        )
105
      --pragma translate_on
106
      port map (
107
        I0 => DIN2(i),
108
        I1 => DIN3(i),
109
        I2 => SEL(0),
110
        I3 => '0',
111
        O  => mux8_23(i));
112
 
113
    mux8_lut3:  LUT4
114
      --pragma translate_off
115
      generic map (
116
        INIT => str2slv(mux8_lut3'INIT)
117
        )
118
      --pragma translate_on
119
      port map (
120
        I0 => DIN4(i),
121
        I1 => DIN5(i),
122
        I2 => SEL(0),
123
        I3 => '0',
124
        O  => mux8_45(i));
125
 
126
    mux8_lut4:  LUT4
127
      --pragma translate_off
128
      generic map (
129
        INIT => str2slv(mux8_lut4'INIT)
130
        )
131
      --pragma translate_on
132
      port map (
133
        I0 => DIN6(i),
134
        I1 => DIN7(i),
135
        I2 => SEL(0),
136
        I3 => '0',
137
        O  => mux8_67(i));
138
 
139
    mux8_muxf5_1 : MUXF5
140
       port map (
141
          O  => mux8_03(i),
142
          I0 => mux8_01(i),
143
          I1 => mux8_23(i),
144
          S  => SEL(1));
145
    mux8_muxf5_2 : MUXF5
146
       port map (
147
          O  => mux8_47(i),
148
          I0 => mux8_45(i),
149
          I1 => mux8_67(i),
150
          S  => SEL(1));
151
 
152
    mux8_muxf6_1 : MUXF6
153
       port map (
154
          O  => dout_int(i),
155
          I0 => mux8_03(i),
156
          I1 => mux8_47(i),
157
          S  => SEL(2));
158
 
159
    opreg : if OP_REG generate
160
    attribute RLOC of reg : label is "R" & integer'image((WIDTH -1)-i) & "C0.S1";
161
    begin
162
     reg : FDE
163
       port map (
164
          D  => dout_int(i),
165
          C  => CLK,
166
          CE => ENA,
167
          Q  => DOUT(i));
168
    end generate;
169
 
170
    opwire : if not OP_REG generate
171
      DOUT(i) <= dout_int(i);
172
    end generate;
173
 
174
  end generate;
175
 
176
end VIRTEX;
177
 
178
--pragma translate_off
179
 
180
library ieee;
181
  use ieee.std_logic_1164.all;
182
  use ieee.std_logic_arith.all;
183
  use ieee.std_logic_unsigned.all;
184
 
185
architecture RTL of MUX8 is
186
  signal mux : std_logic_vector(WIDTH-1 downto 0);
187
begin -- architecture
188
 
189
  p_mux_comb : process(DIN0,DIN1,DIN2,DIN3,DIN4,DIN5,DIN6,DIN7,SEL)
190
    variable ram_addr : integer := 0;
191
  begin
192
    mux <= DIN0;
193
    case SEL is
194
      when "000" => mux <= DIN0;
195
      when "001" => mux <= DIN1;
196
      when "010" => mux <= DIN2;
197
      when "011" => mux <= DIN3;
198
      when "100" => mux <= DIN4;
199
      when "101" => mux <= DIN5;
200
      when "110" => mux <= DIN6;
201
      when "111" => mux <= DIN7;
202
      when others => null;
203
    end case;
204
 
205
  end process;
206
 
207
  opreg : if OP_REG generate
208
    p_opreg : process
209
    begin
210
      wait until CLK'event and (CLK = '1');
211
      if (ENA = '1') then
212
        DOUT <= mux;
213
      end if;
214
    end process;
215
  end generate;
216
 
217
  opwire : if not OP_REG generate
218
    DOUT <= mux;
219
  end generate;
220
 
221
end RTL;
222
 
223
--pragma translate_on
224
 

powered by: WebSVN 2.1.0

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