switch_bus.vhd

来自「《FPGA数字电子系统设计与开发实例导航》的配套光盘」· VHDL 代码 · 共 26 行

VHD
26
字号
-- 库声明
library IEEE;
use IEEE.STD_LOGIC_1164.all;

-- 实体声明
entity switch_bus is
	-- 类属参数
	generic (
	BUS_WIDTH : integer := 8 );					-- 总线宽度
	port (
	din1 : in std_logic_vector(BUS_WIDTH-1 downto 0);	-- 输入总线一
	din2 : in std_logic_vector(BUS_WIDTH-1 downto 0);	-- 输入总线二
	sel : in std_logic;								-- 选择信号
	dout : out std_logic_vector(BUS_WIDTH-1 downto 0) );	-- 输出总线
end switch_bus;

--}} End of automatically maintained section
-- 结构体
architecture switch_bus of switch_bus is
begin
	-- 使用select语句
	with sel select
	dout <= din1 when '0',
			din2 when others;
end switch_bus;

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?