小弟初学VHDL,看别人的结构写了个ALU的程序,但编译不过...

2019-07-16 00:48发布

LIBRARY IEEE;USE IEEE.std_logic_1164.ALL;USE IEEE.std_logic_unsigned.ALL;USE IEEE.std_logic_arith.ALL;entity ALU isport(cin: in std_logic;alu_function: in std_logic_vector(2 downto 0);a_in: in std_logic_vector(7 downto 0);b_in: in std_logic_vector(7 downto 0);alu_out: out std_logic_vector(7 downto 0);z: out std_logic;c: out std_logic;v: out std_logic;                s: out std_logic);end ALU;Architecture win of ALU issignal midout: std_logic_vector(15 downto 0);signal temp: std_logic_vector(15 downto 0);beginprocess(a_in,b_in,alu_function)constant ADD:std_logic_vector:="000";constant SUB:std_logic_vector:="001";constant ANDOP:std_logic_vector:="010";constant OROP:std_logic_vector:="011";constant XOROP:std_logic_vector:="100";constant SHL:std_logic_vector:="101";constant SHR:std_logic_vector:="110";cinextend:="000000000000000"&cin;begincase alu_function iswhen ADD=>midout<=a_in + b_in + cin;when SUB=>midout<=b_in - a_in;when ANDOP=>midout<=a_in and b_in;when OROP=>midout<=a_in or b_in;when XOROP=>midout<=a_in xor b_in;when SHL=>midout<=b_in(14 downto 0)&"0";when SHR=>midout<="0"&b_in(15 downto 0);when others=>midout<="ZZZZZZZZZZZZZZZZ";end case;if(alu_function="000" or "001")    if(a_in(15)="1" and b_in(15)="1" and midout(15)="0") or (a_in(15)="0" and b_in(15)="0" and midout(15)="1" )    then V<="1";    else V<="0";    end if;end if;if(alu_function="000") then temp:="1111111111111111"-b_in-cinextend; if temp<a_in then      c<="1"; else c<="0"; end if;else if(alu_function="001")  if b_in<a_in then      c<="1";  else c="0";  end if;else if(alu_function="101")c<a_in(15);else if(alu_function="110")c<=a_in(0);else c<="0";end if;end process;alu_out<=midout;end win;  非常感谢  非常感谢
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
该问题目前已经被作者或者管理员关闭, 无法添加新回复
4条回答
camp
1楼-- · 2019-07-16 01:29
你可以贴出综合不过 工具给出的提示是什么,有助于大家对你问题的解决。
psi1023
2楼-- · 2019-07-16 02:27
camp 发表于 2014-4-16 21:18
你可以贴出综合不过 工具给出的提示是什么,有助于大家对你问题的解决。

谢谢!已经把错误贴出来了!!求帮助啊!刚学这个,实在搞不大懂
camp
3楼-- · 2019-07-16 06:49
给你一个简单的分析吧! 不过于受人渔,不是鱼;
下面一个错误
“Error (10500): VHDL syntax error at alu.vhd(29) near text "cinextend";  expecting "begin", or a declaration statement”
这么一行,说明在alu.vhd文件第29行 ,靠近cinextend 的 begin 或者是上面出问题了。
仔细看看这些部分的代码吧。

查找问题是,必须从最上面第一个开始处理,(因为第一个问题可能会导致下面很多问题,所以...)
psi1023
4楼-- · 2019-07-16 12:06
 精彩回答 2  元偷偷看……

一周热门 更多>