导航: 老古网老古论坛XMOS公共讨论区XMOS开源项目区单片机程序设计嵌入式系统广告区域
→HDL中双向数据使用的困惑[asia_li]

 *第12277篇: HDL中双向数据使用的困惑

  
楼 主:asia_li 2003年5月19日19:41
 HDL中双向数据使用的困惑
本人写了一段程序,用到了双向数据,但仿真时却发现输入并没有实现,只有输出,为此感到很是困惑,请大侠解惑!
程序如下:
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;

--  Uncomment the following lines to use the declarations that are
--  provided for instantiating Xilinx primitive components.
--library UNISIM;
--use UNISIM.VComponents.all;

--Describe:
--   sclk   : in std_logic;   --__|--|__|--|__...|--|_______|--|__|--|_...
--                                         0     1        7          0     1
--
entity getinfo is
    Port (
  wraddr  : in std_logic;   --   1us

  sclk   : in std_logic;        -- from board
  framehead : in std_logic; --___|-|______..._______|-|________.._______
  sdin   : in std_logic;        -- from board

  read_en  : in std_logic;         --from 860
  byte   : out std_logic_vector(5 downto 0); --just test
  shift  : out std_logic;
  dinout  : inout std_logic_vector(7 downto 0);
  rdy   : out std_logic         -- 0 active
  );
end getinfo;

architecture Behavioral of getinfo is

 signal reg   : std_logic_vector(7 downto 0);
 signal cnt   : std_logic_vector(8 downto 0);  -- 6 bit as bytenum   3 bit as bit select
-- signal bitcnt  : std_logic_vector(2 downto 0);  -- 
 signal bytenum  : std_logic_vector(5 downto 0);  -- 6 bit register of byte number  
 signal bytenum_set : std_logic;
 signal shift_en : std_logic;
 signal ready  : std_logic;
 signal data_valid: std_logic;

begin
 process(wraddr,shift_en) 
 begin
   if shift_en='1' then       -- 1  enable shift 
    bytenum_set  <='0';
   elsif (wraddr'event and wraddr ='1') then
     bytenum  <=dinout(5 downto 0);
     bytenum_set  <='1';       -- bytenum has been set
      end if;
 end process;
   byte  <=bytenum;     --test
  shift  <=shift_en;

 process(sclk,framehead)
 begin
    if framehead='0' then
    cnt  <="111111111";
    elsif sclk'event and sclk='0' then
   cnt  <=cnt+1;
   end if;
   end process;

 process(sclk,bytenum_set)
 begin
  if sclk'event and sclk='0' then
    if bytenum_set='1' and cnt(2 downto 0)="111" then
     shift_en  <='1';
    elsif cnt(8 downto 3)=bytenum and cnt(2 downto 0)="111"  and bytenum_set='0'then  
     shift_en  <='0';
    end if;
  end if;
 end process;

 process(sclk,shift_en)
 begin
  if sclk'event and sclk='0' then  --rising latch,falling sample
   if shift_en='1' then
    reg  <=sdin®(7 downto 1);
   end if;
  end if;
 end process;
-- dinout  <=reg when read_en='0' else "ZZZZZZZZ";         -- 0 active

 process(read_en,shift_en)
 begin
  if read_en='0'then
   dinout  <=reg;
   rdy  <='1';
   elsif shift_en'event and shift_en='0' then
   rdy  <='0';
  end if;
 end process;

-- process(shift_en)
-- begin
--  if shift_en'event and shift_en='0' then
--    rdy  <='0';
--  end if;
-- end process;

end Behavioral;


>>>>>>对该主题发表你的看法

本主题贴数1,分页: [第1页]


[上一篇主题]:帮我驱动液晶,谢谢!

[下一篇主题]:[求助] 关于内存拷贝 DPTR or Rx