求助帮忙看看程序,很短

2020-02-04 10:26发布

LIBRARY IEEE;
USE IEEE.STD_LOGIC_1164.ALL;
---------------------------
PACKAGE MY_PACKAGE IS
TYPE ROM IS ARRAY(0 TO 7) OF STD_LOGIC_VECTOR(3 DOWNTO 0);
END MY_PACKAGE;
---------------------------
LIBRARY IEEE;
USE IEEE.STD_LOGIC_1164.ALL;
USE IEEE.STD_LOGIC_ARITH.ALL;
USE WORK.MY_PACKAGE.ALL;
---------------------------
ENTITY ROMS IS
PORT(ADDR:IN STD_LOGIC_VECTOR(3 DOWNTO 0);
  DATA:OUT STD_LOGIC_VECTOR(3 DOWNTO 0));
END ROMS;
---------------------------
ARCHITECTURE ROMS OF ROMS IS
CONSTANT MY_ROM1:ROM:=("0000","0001","0010","0011","0100","0101","0110","0111");
CONSTANT MY_ROM2:ROM:=("1000","1001","1010","1011","1100","1101","1110","1111");
SIGNAL SEL: STD_LOGIC;
SIGNAL ADD: STD_LOGIC_VECTOR(2 DOWNTO 0);
SIGNAL AD : INTEGER;
BEGIN
SEL<=ADDR(3);
ADD<=ADDR(2 DOWNTO 0);
AD <=CONV_INTEGER(AD);

CASE SEL IS
  WHEN '0' => DATA<=MY_ROM1(AD);
  WHEN '1' => DATA<=MY_ROM2(AD);
  WHEN OTHERS => DATA<="ZZZZ";
END CASE;
END ROMS;

这是我练习的程序,就是模仿ROM,输入一个地址,输出对应处的数据。但是在case那里总是出错:
Error (10500): VHDL syntax error at ROMS.vhd(29) near text "CASE";  expecting "end", or "(", or an identifier ("case" is a reserved keyword), or a concurrent statement
Error (10500): VHDL syntax error at ROMS.vhd(31) near text "WHEN";  expecting "end", or "(", or an identifier ("when" is a reserved keyword), or a concurrent statement
类似这种错误。
我一开始用if语句,就一直出这种错,改了几次后,改成case,还是这样 expecting "end", or "(", or an identifier的错误。
求助!!谢谢!!
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
该问题目前已经被作者或者管理员关闭, 无法添加新回复
7条回答
玄德
1楼-- · 2020-02-04 16:24

不懂VHDL,
但是语法错误,怎么都好办吧?!



TUee_1994
2楼-- · 2020-02-04 19:00
 精彩回答 2  元偷偷看……
waiter
3楼-- · 2020-02-04 21:50
WHEN '0' => DATA<=MY_ROM1(AD);
  WHEN '1' => DATA<=MY_ROM2(AD);
你改成:
WHEN 0 => DATA<=MY_ROM1(AD);
  WHEN 1 => DATA<=MY_ROM2(AD);
试试?
TUee_1994
4楼-- · 2020-02-04 22:21
waiter 发表于 2016-7-9 14:43
WHEN '0' => DATA DATA DATA DATA

这样不行。不是定义的是STD_LOGIC类型,就是要加单引号吗?
一直出这个错。本来是用if,也是这种错误。
戈卫东
5楼-- · 2020-02-05 02:19
ENTITY ARCHITECTURE  用了同样的名字会不会有问题?
戈卫东
6楼-- · 2020-02-05 06:50
case 语句是不是必须放到某个 process里面?

一周热门 更多>