📄 yimaqi.vhd
字号:
-----通用M-N译码器,电路有两个输入端口和一个输出端口:sel,ena,x.
-----假设N是2的M次幂,如果ena='0',那么x的所有输出都变成高电平,否则。。。
-----使用GENERIC语句来指定M和N的值,代码变得易于重用
----------------------------------
library ieee;
use ieee.std_logic_1164.all;
entity yimaqi is
port (ena :in std_logic;
sel :in std_logic_vector(2 downto 0);
x : out std_logic_vector(7 downto 0));
end yimaqi;
------------------------------------
architecture generic_decoder of yimaqi is
begin
process( ena,sel)
variable temp1 : std_logic_vector(x'high downto 0);
variable temp2 : integer range 0 to x'high;
begin
temp1 := (others => '1');
temp2 :=0;
if (ena= '1') then
for i in sel' range loop-----------sel的位宽是3
if (sel(i) ='1')then ----------二进制到十进制的转换
temp2 :=2*temp2+1;
else
temp2 :=2*temp2;
end if;
end loop;
temp1(temp2) :='0';
end if;
x <= temp1;
end process;
end generic_decoder;
-----------------------------------------
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -