打印

郁闷 端口buffer

[复制链接]
1219|0
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
gggman|  楼主 | 2007-5-11 12:37 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
小弟进来做个小程序 仿真过不了!
index 是个buffer端口 通过查表所得数值与其做加法运算 然后传给下一级使用,同时返回给输入端,由下一个输入再次更新~~
程序如下
--------------------------------------------------------------------

------------
-- Company: 
-- Engineer:
--
-- Create Date:    22:48:39 05/04/07
-- Design Name:    
-- Module Name:    kuis_1 - Behavioral
-- Project Name:   
-- Target Device:  
-- Tool versions:  
-- Description:
--
-- Dependencies:
-- 
-- Revision:
-- Revision 0.01 - File Created
-- Additional Comments:
-- 
--------------------------------------------------------------------

------------
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;

---- Uncomment the following library declaration if instantiating
---- any Xilinx primitives in this code.
--library UNISIM;
--use UNISIM.VComponents.all;

entity kuis_1 is
    Port ( code : in std_logic_vector(3 downto 0);
           index : buffer std_logic_vector(8 downto 0));
end kuis_1;

architecture Behavioral of kuis_1 is
function adder9
    ( a:std_logic_vector;
     b:std_logic_vector
     )
     return std_logic_vector is
variable vsum : std_logic_vector(8 downto 0);
variable carry : std_logic;
variable i:integer;
begin     

        carry :='0';
        for i in 0 to 8 loop
            vsum(i):= (a(i) xor b(i)) xor carry;
            carry := (a(i) and b(i)) or (carry and (a(i) or b(i)));
        end loop;
          return vsum;
end adder9;
signal tmp:std_logic_vector(8 downto 0);
signal tmp1:std_logic_vector(8 downto 0);
begin
p1:process(code)
begin
    case code is
        when"0000"=> tmp<="111111111"; 
        when"0001"=> tmp<="111111111"; 
        when"0010"=> tmp<="111111111";      
        when"0011"=> tmp<="111111111";     
        when"0100"=> tmp<="000000010";    
        when"0101"=> tmp<="000000100";  
        when"0110"=> tmp<="000000110"; 
        when"0111"=> tmp<="000001000";
        when"1000"=> tmp<="111111111";        
        when"1001"=> tmp<="111111111";         
        when"1010"=> tmp<="111111111";        
        when"1011"=> tmp<="111111111";        
        when"1100"=> tmp<="000000010";         
        when"1101"=> tmp<="000000100";        
        when"1110"=> tmp<="000000110";        
        when"1111"=> tmp<="000001000";  
        when others=> tmp<="ZZZZZZZZZ"; 
    end case;
end process p1;
p2:process(tmp,index)
begin
tmp1<=adder9(index,tmp);
index<=tmp1;
end process p2;
end Behavioral;

相关帖子

发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

12

主题

13

帖子

0

粉丝