vhdl中INOUT端口操作程序

这是一个关于如何在VHDL中操作和仿真INOUT端口的示例代码。文件包括gc_cpu.vhd,定义了一个包含INOUT端口的CPU实体,以及cpu_port_tb.vhd,提供了对应的ModelSim仿真测试平台,用于测试读写操作。
摘要由CSDN通过智能技术生成

--File   :   pc_cpu.vhd

library IEEE;
use IEEE.STD_LOGIC_1164.all;
use IEEE.STD_LOGIC_UNSIGNED.all;
use IEEE.STD_LOGIC_ARITH.all;

entity gc_cpu is
     port(
         SCLK: in std_logic; --50M--
         QCLK: in std_logic; --133M--
         ext_reset : in STD_LOGIC; --not (HRESET and SRESET) active high
         CPU_GE_CS : in STD_LOGIC;
         CPU_PORTX_A : in STD_LOGIC_VECTOR(21 downto 0);
         CPU_PORTX_OE : in STD_LOGIC;
         CPU_PORTX_WE : in STD_LOGIC;
         CPU_PORTX_D : inout STD_LOGIC_VECTOR(7 downto 0);
         CPU_PORTX_INT13 : out STD_LOGIC
         );
end gc_cpu;

architecture gc_cpu of gc_cpu is

type array_8bit  is array (21 downto 0) of std_logic_vector(7 downto 0);
signal ram : array_8bit;
signal cs : std_logic;
signal oe : std_logic;
signal we : std_logic;
signal addr_in: std_logic_vector(21 downto 0);
signal data_in, data_out: std_logic_vector(7 downto 0);   
begin
cs <= CPU_GE_CS;
oe <= CPU_PORTX_OE;
we <= CPU_PORTX_WE;
addr_in <= CPU_PORTX_A;

--write
process(QCLK)
begin
    if QCLK'event and QCLK = '1' then
        if we = '0'  and cs = '0' then
            ram(conv_integer(addr_in)) <= data_in;               
        end if;
    end if;
end process;

--read
process(QCLK, ext_reset)
begin
    if ext_reset = '1' then
        data_out <= (o

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值