8位总线分两次传16位数据,用cpld 接收如何区分高低位问题!
用51单片机 向cpld 传数据,数据是16位的,总线方式写的分两次 先写低8位,再写高8位,
我在CPLD里接收后使用这个16位数据,
现在问题是如何准确做到接收的是先低8位后高8位。
程序如下:我是等待 WR 的下降沿时,再判断地址是否正确,如果正确就接收
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_arith.all;
use ieee.std_logic_unsigned.all;
entity selected is
PORT(
data:in std_logic_vector(7 downto 0);
WR: IN STD_LOGIC;
..........
)
end;
architecture behavioral of selected is
signal data0_lsb,data0_msb :STD_LOGIC_vector(7 downto 0);
begin
process(WR)
begin
if WR='0' and WR'event then
if AAD0='0' then----地址信号 低电平有效的
if num= 0 then
data0_lsb<=data;
num<=1;
end if;
if num= 1 then
data0_msb<=data;
num<=0;
end if;
end if;
end if;
end process;
......
end;
现在想在里面做个标记 接收完低8位后标记一下, 再接收高8位 ,接收完高8位后同样也做一下标记,下次就是低8位 如此循环。。。
不知道我那样用num标记是否可以?
怎样做到更准确些呢? 加多一根信号可以不?? 回复【楼主位】281229961 小朱
-----------------------------------------------------------------------
用num作标记可以的
页:
[1]