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

Subversion Repositories risc5x

[/] [risc5x/] [trunk/] [mux4.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 MUX4 is
32
  generic (
33
    WIDTH         : in  natural := 8;
34
    SLICE         : in  natural := 1; -- 1 left, 0 right
35
    OP_REG        : in  boolean := FALSE
36
    );
37
  port (
38
    DIN3          : in  std_logic_vector(WIDTH-1 downto 0);
39
    DIN2          : in  std_logic_vector(WIDTH-1 downto 0);
40
    DIN1          : in  std_logic_vector(WIDTH-1 downto 0);
41
    DIN0          : in  std_logic_vector(WIDTH-1 downto 0);
42
 
43
    SEL           : in  std_logic_vector(1 downto 0);
44
    ENA           : in  std_logic;
45
    CLK           : in  std_logic;
46
 
47
    DOUT          : out std_logic_vector(WIDTH-1 downto 0)
48
    );
49
end;
50
--
51
-- USE THIS ARCHITECTURE FOR XILINX
52
--
53
use work.pkg_xilinx_prims.all;
54
library ieee;
55
  use ieee.std_logic_1164.all;
56
  use ieee.std_logic_arith.all;
57
  use ieee.std_logic_unsigned.all;
58
 
59
architecture VIRTEX of MUX4 is
60
 
61
  signal dout_int : std_logic_vector(WIDTH-1 downto 0);
62
  signal mux8_01  : std_logic_vector(WIDTH-1 downto 0);
63
  signal mux8_23  : std_logic_vector(WIDTH-1 downto 0);
64
 
65
begin -- architecture
66
 
67
  ram_bit : for i in 0 to WIDTH-1 generate
68
  attribute RLOC of mux8_lut1,mux8_lut2 : label is "R" & integer'image((WIDTH -1)-i) & "C0.S" & integer'image(SLICE);
69
  attribute RLOC of mux8_muxf5_1 : label is "R" & integer'image((WIDTH -1)-i) & "C0.S" & integer'image(SLICE);
70
 
71
  attribute INIT  of mux8_lut1 : label is "00CA";
72
  attribute INIT  of mux8_lut2 : label is "00CA";
73
  begin
74
 
75
    mux8_lut1:  LUT4
76
      --pragma translate_off
77
      generic map (
78
        INIT => str2slv(mux8_lut1'INIT)
79
        )
80
      --pragma translate_on
81
      port map (
82
        I0 => DIN0(i),
83
        I1 => DIN1(i),
84
        I2 => SEL(0),
85
        I3 => '0',
86
        O  => mux8_01(i));
87
 
88
    mux8_lut2:  LUT4
89
      --pragma translate_off
90
      generic map (
91
        INIT => str2slv(mux8_lut2'INIT)
92
        )
93
      --pragma translate_on
94
      port map (
95
        I0 => DIN2(i),
96
        I1 => DIN3(i),
97
        I2 => SEL(0),
98
        I3 => '0',
99
        O  => mux8_23(i));
100
 
101
    mux8_muxf5_1 : MUXF5
102
       port map (
103
          O  => dout_int(i),
104
          I0 => mux8_01(i),
105
          I1 => mux8_23(i),
106
          S  => SEL(1));
107
 
108
    opreg : if OP_REG generate
109
    attribute RLOC of reg : label is "R" & integer'image((WIDTH -1)-i) & "C0.S" & integer'image(SLICE);
110
    begin
111
     reg : FDE
112
       port map (
113
          D  => dout_int(i),
114
          C  => CLK,
115
          CE => ENA,
116
          Q  => DOUT(i));
117
    end generate;
118
 
119
    opwire : if not OP_REG generate
120
      DOUT(i) <= dout_int(i);
121
    end generate;
122
 
123
  end generate;
124
 
125
end VIRTEX;
126
 
127
--pragma translate_off
128
 
129
library ieee;
130
  use ieee.std_logic_1164.all;
131
  use ieee.std_logic_arith.all;
132
  use ieee.std_logic_unsigned.all;
133
 
134
architecture RTL of MUX4 is
135
  signal mux : std_logic_vector(WIDTH-1 downto 0);
136
begin -- architecture
137
 
138
  p_mux_comb : process(DIN0,DIN1,DIN2,DIN3,SEL)
139
    variable ram_addr : integer := 0;
140
  begin
141
    mux <= DIN0;
142
    case SEL is
143
      when "00" => mux <= DIN0;
144
      when "01" => mux <= DIN1;
145
      when "10" => mux <= DIN2;
146
      when "11" => mux <= DIN3;
147
      when others => null;
148
    end case;
149
 
150
  end process;
151
 
152
  opreg : if OP_REG generate
153
    p_opreg : process
154
    begin
155
      wait until CLK'event and (CLK = '1');
156
      if (ENA = '1') then
157
        DOUT <= mux;
158
      end if;
159
    end process;
160
  end generate;
161
 
162
  opwire : if not OP_REG generate
163
    DOUT <= mux;
164
  end generate;
165
 
166
end RTL;
167
 
168
--pragma translate_on

powered by: WebSVN 2.1.0

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