【发布时间】:2015-11-30 19:58:24
【问题描述】:
更新
我更新了测试台代码,但现在似乎数据缓冲区不驱动信号。
LIBRARY ieee;
USE ieee.std_logic_1164.all;
ENTITY databus_buffer_tb IS
END databus_buffer_tb;
ARCHITECTURE dataflow OF databus_buffer_tb IS
SIGNAL T_Idata:STD_LOGIC_VECTOR(7 DOWNTO 0);
SIGNAL T_Odata:STD_LOGIC_VECTOR(7 DOWNTO 0);
SIGNAL T_Ctrl:STD_LOGIC:='0';
COMPONENT databus_buffer IS
PORT
(
--IDATA represent the bus lines that comes from the uC for reading and writing;
--ODATA represents the bus lines that communicate with the internal bus;
IDATA: INOUT STD_LOGIC_VECTOR(7 DOWNTO 0):="00000000";
CTRL: IN STD_LOGIC;
ODATA: INOUT STD_LOGIC_VECTOR(7 DOWNTO 0):="00000000"
);
END COMPONENT;
BEGIN
databuffer:databus_buffer PORT MAP
(
IDATA=>T_Idata,
CTRL=>T_Ctrl,
ODATA=>T_Odata
);
PROCESS
BEGIN
T_Idata<="00001111";
T_Ctrl<='0';
WAIT FOR 10 ns;
assert(T_Odata="00001111") REPORT "Expected 00001111" SEVERITY error;
T_Odata<="11110000";
T_Ctrl<='1';
WAIT FOR 10 ns;
assert(T_Idata="11110000") REPORT "Expected 11110000" SEVERITY error;
T_Ctrl<='Z';
WAIT FOR 10 ns;
assert(T_Idata="ZZZZZZZZ") REPORT "Expected Z FOR T_Idata" SEVERITY error;
assert(T_Odata="ZZZZZZZZ") REPORT "Expected Z FOR T_Odata" SEVERITY error;
wait;
END PROCESS;
END dataflow;
我试图了解如何在 VHDL 中实现 INOUT 端口,但我失败了。 代码如下:
library ieee;
use ieee.std_logic_1164.all;
----------------------------
-- Databus Buffer
----------------------------
ENTITY databus_buffer IS
-- data bus buffer have the next ports:
-- IDATA: 8 bit bus ->inout
-- CTRL: 1 bit control ->in
-- ODATA: 8 bit bus ->inout
PORT
(
--IDATA represent the bus lines that comes from the uC for reading and writing;
--ODATA represents the bus lines that communicate with the internal bus;
IDATA: INOUT STD_LOGIC_VECTOR(7 DOWNTO 0);
CTRL: IN STD_LOGIC;
ODATA: INOUT STD_LOGIC_VECTOR(7 DOWNTO 0)
);
END databus_buffer;
ARCHITECTURE behaviour OF databus_buffer IS
-- behaviour of databus buffer;
BEGIN
-- is a 3 state bidirection 8 bit buffer.
-- if CTRL is 1, IDATA=ODATA; reading from counter operation
-- if CTRL is 0, ODATA=IDATA; writing to control word
-- if CTRL is Z, IDATA=Z; this happens when nor read and write are active but
-- cs is active;
-- also, data bus can be in 3rd state if the chip is not selected, this means
-- that CTRL will be Z;
ODATA<=IDATA WHEN CTRL='0' else "ZZZZZZZZ" WHEN CTRL='Z' else (OTHERS=>'Z');
IDATA<=ODATA WHEN CTRL='1' else "ZZZZZZZZ" WHEN CTRL='Z' else (OTHERS=>'Z');
END behaviour;
此代码在 CTRL 为 0 或 1 时有效。但是当我将 CTRL 设置为 'Z' 时,在高阻状态下,IDATA 和 ODATA 未设置为高阻。
我的测试平台:
LIBRARY ieee;
USE ieee.std_logic_1164.all;
ENTITY databus_buffer_tb IS
END databus_buffer_tb;
ARCHITECTURE dataflow OF databus_buffer_tb IS
SIGNAL T_Idata:STD_LOGIC_VECTOR(7 DOWNTO 0):="00000000";
SIGNAL T_Odata:STD_LOGIC_VECTOR(7 DOWNTO 0):="00000000";
SIGNAL T_Ctrl:STD_LOGIC:='0';
COMPONENT databus_buffer IS
PORT
(
--IDATA represent the bus lines that comes from the uC for reading and writing;
--ODATA represents the bus lines that communicate with the internal bus;
IDATA: INOUT STD_LOGIC_VECTOR(7 DOWNTO 0);
CTRL: IN STD_LOGIC;
ODATA: INOUT STD_LOGIC_VECTOR(7 DOWNTO 0)
);
END COMPONENT;
BEGIN
databuffer:databus_buffer PORT MAP
(
IDATA=>T_Idata,
CTRL=>T_Ctrl,
ODATA=>T_Odata
);
PROCESS
BEGIN
T_Idata<="00000000";
T_Odata<="00000000";
T_Ctrl<='0';
T_Idata<="00001111";
T_ODATA<="ZZZZZZZZ";
T_Ctrl<='0';
WAIT FOR 10 ns;
assert(T_Odata="00001111") REPORT "Expected 00001111" SEVERITY error;
T_Odata<="11110000";
T_IDATA<="ZZZZZZZZ";
T_Ctrl<='1';
WAIT FOR 10 ns;
assert(T_Idata="11110000") REPORT "Expected 11110000" SEVERITY error;
T_IData<="00000000";
T_OData<="00000000";
T_Ctrl<='Z';
WAIT FOR 10 ns;
assert(T_Idata="ZZZZZZZZ") REPORT "Expected Z FOR T_Idata" SEVERITY error;
assert(T_Odata="ZZZZZZZZ") REPORT "Expected Z FOR T_Odata" SEVERITY error;
wait;
END PROCESS;
END dataflow;
另外,如何按顺序控制进程中的输入输出端口?
【问题讨论】:
标签: vhdl