1
0
mirror of https://github.com/myhdl/myhdl.git synced 2024-12-14 07:44:38 +08:00
myhdl/example/manual/bin2gray.vhd

36 lines
650 B
VHDL
Raw Normal View History

2008-11-22 22:40:25 +01:00
-- File: bin2gray.vhd
2008-11-23 11:36:16 +01:00
-- Generated by MyHDL 0.6
-- Date: Sun Nov 23 11:34:35 2008
2008-11-22 22:40:25 +01:00
library IEEE;
use IEEE.std_logic_1164.all;
use IEEE.numeric_std.all;
use std.textio.all;
2008-11-23 11:36:16 +01:00
use work.pck_myhdl_06.all;
2008-11-22 22:40:25 +01:00
entity bin2gray is
port (
B: in unsigned(7 downto 0);
G: out unsigned(7 downto 0)
);
end entity bin2gray;
architecture MyHDL of bin2gray is
begin
BIN2GRAY_LOGIC: process (B) is
variable Bext: unsigned(8 downto 0);
begin
Bext := to_unsigned(0, 9);
Bext := resize(B, 9);
for i in 0 to 8-1 loop
G(i) <= (Bext((i + 1)) xor Bext(i));
end loop;
end process BIN2GRAY_LOGIC;
end architecture MyHDL;