📄 wr_gray_cntr.vhd
字号:
-- fifo_wr_addr gray counter with synchronous reset
-- Gray counter is used for FIFO address counter
LIBRARY ieee;
USE ieee.std_logic_1164.all;
USE ieee.std_logic_arith.all;
-- pragma translate_off
library UNISIM;
use UNISIM.VCOMPONENTS.ALL;
-- pragma translate_on
--
ENTITY wr_gray_cntr IS
port (
clk : in std_logic;
reset : in std_logic;
cnt_en : in std_logic;
wgc_gcnt : out std_logic_vector(3 downto 0)
);
END wr_gray_cntr ;
ARCHITECTURE wr_gray_cntr OF wr_gray_cntr IS
component FDCE
port(
Q : out STD_ULOGIC;
C : in STD_ULOGIC;
CE : in STD_ULOGIC;
CLR : in STD_ULOGIC;
D : in STD_ULOGIC
);
end component;
-- gray encoded signals
signal d_in : std_logic_vector(3 downto 0);
signal gc_int : std_logic_vector(3 downto 0);
BEGIN
wgc_gcnt <= gc_int(3 downto 0);
process(gc_int)
begin
case gc_int is
when "0000" => d_in <= "0001"; --0 > 1
when "0001" => d_in <= "0011"; --1 > 3
when "0010" => d_in <= "0110"; --2 > 6
when "0011" => d_in <= "0010"; --3 > 2
when "0100" => d_in <= "1100"; --4 > c
when "0101" => d_in <= "0100"; --5 > 4
when "0110" => d_in <= "0111"; --6 > 7
when "0111" => d_in <= "0101"; --7 > 5
when "1000" => d_in <= "0000"; --8 > 0
when "1001" => d_in <= "1000"; --9 > 8
when "1010" => d_in <= "1011"; --10 > b
when "1011" => d_in <= "1001"; --11 > 9
when "1100" => d_in <= "1101"; --12 > d
when "1101" => d_in <= "1111"; --13 > f
when "1110" => d_in <= "1010"; --14 > a
when "1111" => d_in <= "1110"; --15 > e
when others => d_in <= "0001"; --0 > 1
end case;
end process;
bit0 : FDCE port map (
Q => gc_int(0),
C => clk,
CE => cnt_en,
CLR => reset,
D => d_in(0)
);
bit1 : FDCE port map (
Q => gc_int(1),
C => clk,
CE => cnt_en,
CLR => reset,
D => d_in(1)
);
bit2 : FDCE port map (
Q => gc_int(2),
C => clk,
CE => cnt_en,
CLR => reset,
D => d_in(2)
);
bit3 : FDCE port map (
Q => gc_int(3),
C => clk,
CE => cnt_en,
CLR => reset,
D => d_in(3)
);
END wr_gray_cntr;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -