-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathfreqmux.vhd
73 lines (63 loc) · 1.76 KB
/
freqmux.vhd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
----------------------------------------------------------------------------------
-- Company:
-- Engineer:
--
-- Create Date: 22:52:00 04/20/2019
-- Design Name:
-- Module Name: freqmux - Behavioral
-- Project Name:
-- Target Devices:
-- Tool versions:
-- Description:
--
-- Dependencies:
--
-- Revision:
-- Revision 0.01 - File Created
-- Additional Comments:
--
----------------------------------------------------------------------------------
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
-- Uncomment the following library declaration if using
-- arithmetic functions with Signed or Unsigned values
--use IEEE.NUMERIC_STD.ALL;
-- Uncomment the following library declaration if instantiating
-- any Xilinx primitives in this code.
--library UNISIM;
--use UNISIM.VComponents.all;
entity freqmux is
Port ( reset : in STD_LOGIC;
f0in : in STD_LOGIC;
f1in : in STD_LOGIC;
sel : in STD_LOGIC;
fout : out STD_LOGIC);
end freqmux;
architecture Behavioral of freqmux is
signal s1, s0, i1, i0, f: std_logic;
begin
f <= (s0 and (i0 xor f0in)) or (s1 and (i1 xor f1in));
fout <= f;
switch: process(reset, f, sel, s1, s0)
begin
if (reset = '1') then
s0 <= '1';
s1 <= '0';
i0 <= '0';
i1 <= '0';
else
if (rising_edge(f)) then
if (sel = '0' and s1 = '1') then -- switching from source 1 to 0
s0 <= '1';
s1 <= '0';
i0 <= not f0in; -- flip new input f to keep the high level during switch
end if;
if (sel = '1' and s0 = '1') then -- switching from source 0 to 1
s0 <= '0';
s1 <= '1';
i1 <= not f1in; -- flip new input f to keep the high level during switch
end if;
end if;
end if;
end process;
end Behavioral;