今天郁闷了一天,麻烦大侠们帮我看一下.<br />想写一条程序实现单片机并行发数据3个8位的数据给FPGA,共24位,FPGA提取前20位.一个时钟口和一个FPGA数据输出使能.时钟由单片机控制,每个时钟周期输入8位数据.程序如下,可就是实现不了.能帮个忙说下哪里没弄好吗?<br />LIBRARY IEEE;<br />USE IEEE.STD_LOGIC_1164.ALL;<br />Use ieee.std_logic_unsigned.all;<br />Entity Buf is<br /> port(datain:in std_logic_vector(7 downto 0);--数据进<br /> clk :in std_logic;--时钟<br /> en :in std_logic;--输出使能<br /> dataout:inout std_logic_vector(19 downto 0)--数据出<br /> );<br />end Buf;<br />architecture rtl of Buf is<br />signal databuf:std_logic_vector(23 downto 0);<br />signal count:std_logic_vector(1 downto 0);<br />begin<br /> process(clk)<br /> begin<br /> if(clk 'event and clk='1')then<br /> if(count="10")then<br /> count<="00";<br /> else count<=count+1;<br /> end if; <br /> end if;<br /> end process;<br /> process(count)<br /> begin <br /> CASE count IS<br /> WHEN "00" =><br /> databuf(23 downto 16)<=datain;<br /> WHEN "01" =><br /> databuf(15 downto 8)<=datain;<br /> WHEN "10"=><br /> databuf(7 downto 0)<=datain;<br /> WHEN others =><br /> databuf<=databuf;<br /> END CASE; <br /> end process;<br /> process(clk)<br /> begin<br /> if(en='1')then<br /> dataout<=databuf(19 downto 0);<br /> else dataout<=dataout;<br /> end if;<br /> end process;<br />end rtl; |
|