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

Subversion Repositories risc5x

[/] [risc5x/] [trunk/] [mux2.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 MUX2 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
    DIN1          : in  std_logic_vector(WIDTH-1 downto 0);
39
    DIN0          : in  std_logic_vector(WIDTH-1 downto 0);
40
 
41
    SEL           : in  std_logic;
42
    ENA           : in  std_logic;
43
    CLK           : in  std_logic;
44
 
45
    DOUT          : out std_logic_vector(WIDTH-1 downto 0)
46
    );
47
end;
48
--
49
-- USE THIS ARCHITECTURE FOR XILINX
50
--
51
use work.pkg_xilinx_prims.all;
52
library ieee;
53
  use ieee.std_logic_1164.all;
54
  use ieee.std_logic_arith.all;
55
  use ieee.std_logic_unsigned.all;
56
 
57
architecture VIRTEX of MUX2 is
58
 
59
  signal dout_int : std_logic_vector(WIDTH-1 downto 0);
60
 
61
begin -- architecture
62
 
63
  ram_bit : for i in 0 to WIDTH-1 generate
64
  attribute RLOC of mux8_muxf5_1 : label is "R" & integer'image((WIDTH -1)-i) & "C0.S" & integer'image(SLICE);
65
  begin
66
 
67
    mux8_muxf5_1 : MUXF5
68
       port map (
69
          O  => dout_int(i),
70
          I0 => DIN0(i),
71
          I1 => DIN1(i),
72
          S  => SEL);
73
 
74
    opreg : if OP_REG generate
75
    attribute RLOC of reg : label is "R" & integer'image((WIDTH -1)-i) & "C0.S" & integer'image(SLICE);
76
    begin
77
     reg : FDE
78
       port map (
79
          D  => dout_int(i),
80
          C  => CLK,
81
          CE => ENA,
82
          Q  => DOUT(i));
83
    end generate;
84
 
85
    opwire : if not OP_REG generate
86
      DOUT(i) <= dout_int(i);
87
    end generate;
88
 
89
  end generate;
90
 
91
end VIRTEX;
92
 
93
--pragma translate_off
94
 
95
library ieee;
96
  use ieee.std_logic_1164.all;
97
  use ieee.std_logic_arith.all;
98
  use ieee.std_logic_unsigned.all;
99
 
100
architecture RTL of MUX2 is
101
  signal mux : std_logic_vector(WIDTH-1 downto 0);
102
begin -- architecture
103
 
104
  p_mux_comb : process(DIN0,DIN1,SEL)
105
    variable ram_addr : integer := 0;
106
  begin
107
    mux <= DIN0;
108
    if (SEL = '0') then
109
      mux <= DIN0;
110
    else
111
      mux <= DIN1;
112
    end if;
113
  end process;
114
 
115
  opreg : if OP_REG generate
116
    p_opreg : process
117
    begin
118
      wait until CLK'event and (CLK = '1');
119
      if (ENA = '1') then
120
        DOUT <= mux;
121
      end if;
122
    end process;
123
  end generate;
124
 
125
  opwire : if not OP_REG generate
126
    DOUT <= mux;
127
  end generate;
128
 
129
end RTL;
130
 
131
--pragma translate_on
132
 

powered by: WebSVN 2.1.0

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