格雷码计数器用vhdl怎样实现?
发布时间:2008/5/28 0:00:00 访问次数:716
variable count:std_logic_vector(3 downto 0);
if clk'event and clk='1' then
case count is
when "0000"=>count:="0001";
when "0001"=>count:="0011";
when "0011"=>count:="0010";
when "0010"=>count:="0110";
when "0110"=>count:="0111";
when "0111"=>count:="0101";
when "0101"=>count:="0100";
when "0100"=>count:="1100";
when "1100"=>count:="1101";
when "1101"=>count:="1111";
when "1111"=>count:="1110";
when "1110"=>count:="1010";
when "1010"=>count:="1011";
when "1011"=>count:="1001";
when "1001"=>count:="1000";
when "1000"=>count:="0000";
when others=>count:="0000";
end case;
end if;
经典做法:
gray code --> general code --> gray code
自然码转格雷码
library ieee;
use ieee.std_logic_1164.all;
entity norm2grey is
generic (width: integer := 8);
port (
norm: in std_logic_vector(width - 1 downto 0);
grey: out std_logic_vector(width - 1 downto 0)
);
end norm2grey;
architecture behav of norm2grey is
begin
grey <= norm xor ('0' & norm(width - 1 downto 1));
end behav;
if clk'event and clk='1' then
case count is
when "0000"=>count:="0001";
when "0001"=>count:="0011";
when "0011"=>count:="0010";
when "0010"=>count:="0110";
when "0110"=>count:="0111";
when "0111"=>count:="0101";
when "0101"=>count:="0100";
when "0100"=>count:="1100";
when "1100"=>count:="1101";
when "1101"=>count:="1111";
when "1111"=>count:="1110";
when "1110"=>count:="1010";
when "1010"=>count:="1011";
when "1011"=>count:="1001";
when "1001"=>count:="1000";
when "1000"=>count:="0000";
when others=>count:="0000";
end case;
end if;
经典做法:
gray code --> general code --> gray code
自然码转格雷码
library ieee;
use ieee.std_logic_1164.all;
entity norm2grey is
generic (width: integer := 8);
port (
norm: in std_logic_vector(width - 1 downto 0);
grey: out std_logic_vector(width - 1 downto 0)
);
end norm2grey;
architecture behav of norm2grey is
begin
grey <= norm xor ('0' & norm(width - 1 downto 1));
end behav;
variable count:std_logic_vector(3 downto 0);
if clk'event and clk='1' then
case count is
when "0000"=>count:="0001";
when "0001"=>count:="0011";
when "0011"=>count:="0010";
when "0010"=>count:="0110";
when "0110"=>count:="0111";
when "0111"=>count:="0101";
when "0101"=>count:="0100";
when "0100"=>count:="1100";
when "1100"=>count:="1101";
when "1101"=>count:="1111";
when "1111"=>count:="1110";
when "1110"=>count:="1010";
when "1010"=>count:="1011";
when "1011"=>count:="1001";
when "1001"=>count:="1000";
when "1000"=>count:="0000";
when others=>count:="0000";
end case;
end if;
经典做法:
gray code --> general code --> gray code
自然码转格雷码
library ieee;
use ieee.std_logic_1164.all;
entity norm2grey is
generic (width: integer := 8);
port (
norm: in std_logic_vector(width - 1 downto 0);
grey: out std_logic_vector(width - 1 downto 0)
);
end norm2grey;
architecture behav of norm2grey is
begin
grey <= norm xor ('0' & norm(width - 1 downto 1));
end behav;
if clk'event and clk='1' then
case count is
when "0000"=>count:="0001";
when "0001"=>count:="0011";
when "0011"=>count:="0010";
when "0010"=>count:="0110";
when "0110"=>count:="0111";
when "0111"=>count:="0101";
when "0101"=>count:="0100";
when "0100"=>count:="1100";
when "1100"=>count:="1101";
when "1101"=>count:="1111";
when "1111"=>count:="1110";
when "1110"=>count:="1010";
when "1010"=>count:="1011";
when "1011"=>count:="1001";
when "1001"=>count:="1000";
when "1000"=>count:="0000";
when others=>count:="0000";
end case;
end if;
经典做法:
gray code --> general code --> gray code
自然码转格雷码
library ieee;
use ieee.std_logic_1164.all;
entity norm2grey is
generic (width: integer := 8);
port (
norm: in std_logic_vector(width - 1 downto 0);
grey: out std_logic_vector(width - 1 downto 0)
);
end norm2grey;
architecture behav of norm2grey is
begin
grey <= norm xor ('0' & norm(width - 1 downto 1));
end behav;
热门点击
- 激光打靶游戏机
- 10KV线路单相接地故障处理方法初探
- 常见连接器和插座介绍
- 用LM324等设计的低成本高精度温度测量电路
- 电池低电压指示及控制电路设计
- 红外枪打靶游戏
- 集成电路中的MOS晶体管模型
- MOS管的阈值电压探讨
- 准同期并网控制电路
- 电流、磁力线方向演示器
推荐技术资料
- Seeed Studio
- Seeed Studio绐我们的印象总是和绘画脱离不了... [详细]