VHDL 中的不兼容切片
Incompatibile Slices in VHDL
我正在学习 VHDL,对于第一个项目,我选择了简单的 Brainfuck 处理器。当我尝试编译它时,出现有关不兼容切片的错误。我正在使用 EdWinXP。如何修复我的代码?我的代码中有很多错误吗?有没有对 C 程序员来说更简单的 VHDL 替代方案?
use ieee.std_logic_1164.all;
entity BFCPU is
port (
I0 : in std_logic; --INPUT
I1 : in std_logic; --PROGRAM
I2 : in std_logic; --PROGRAM READY
O1 : out std_logic; --PROGRAM NEEDED
O2 : out std_logic; --OUTPUT
O3 : out std_logic; --OUTPUT WRITTEN
O4 : out std_logic); --INPUT NEEDED
--O5 : out std_logic); --INPUT POOLING CLOCK
end BFCPU;
architecture work of BFCPU is
type t_Memory is array (0 to 127) of std_logic_vector(7 downto 0);
signal rammem : t_Memory;
signal pointer : std_logic;
begin
pointer <= 0;
workflow: process (I2) is
begin
if I1=1 then
rammem(pointer) <= std_logic_vector(unsigned(rammem(pointer)) + 1);
elsif I1=2 then
rammem(pointer) <= std_logic_vector(unsigned(rammem(pointer)) - 1);
elsif I1=3 then
pointer <= pointer - 1;
elsif I1=4 then
pointer <= pointer + 1;
elsif I1=5 then
O2 <= rammem(pointer);
elsif I1=6 then
O4 <= not O4;
inwait: while( I0 = 0 ) loop
if not (I0 = 0) then
rammem(pointer) <= I0;
end if;
end loop inwait;
O4 <= not O4;
end if;
end process workflow;
end work;
您在 begin 语句下方和进程外部所写的内容始终为真,因此这不是任何形式的顺序。想象一下,FPGA 引脚被焊接到地。
您尝试从进程内操纵指针信号,但您做不到,因为您的指针固定为“0”。
如果你想让指针初始化为“0”,就像它看起来的那样,你必须把这一行放在进程中。但是,我看到您尝试使用指针信号调用算术运算,但您将信号定义为 std_logic。 std_logic 可以表示“0”、“1”和其他几种状态,例如 High-Z,但不能表示数字。您应该取整数或自然数进行计算。
我正在学习 VHDL,对于第一个项目,我选择了简单的 Brainfuck 处理器。当我尝试编译它时,出现有关不兼容切片的错误。我正在使用 EdWinXP。如何修复我的代码?我的代码中有很多错误吗?有没有对 C 程序员来说更简单的 VHDL 替代方案?
use ieee.std_logic_1164.all;
entity BFCPU is
port (
I0 : in std_logic; --INPUT
I1 : in std_logic; --PROGRAM
I2 : in std_logic; --PROGRAM READY
O1 : out std_logic; --PROGRAM NEEDED
O2 : out std_logic; --OUTPUT
O3 : out std_logic; --OUTPUT WRITTEN
O4 : out std_logic); --INPUT NEEDED
--O5 : out std_logic); --INPUT POOLING CLOCK
end BFCPU;
architecture work of BFCPU is
type t_Memory is array (0 to 127) of std_logic_vector(7 downto 0);
signal rammem : t_Memory;
signal pointer : std_logic;
begin
pointer <= 0;
workflow: process (I2) is
begin
if I1=1 then
rammem(pointer) <= std_logic_vector(unsigned(rammem(pointer)) + 1);
elsif I1=2 then
rammem(pointer) <= std_logic_vector(unsigned(rammem(pointer)) - 1);
elsif I1=3 then
pointer <= pointer - 1;
elsif I1=4 then
pointer <= pointer + 1;
elsif I1=5 then
O2 <= rammem(pointer);
elsif I1=6 then
O4 <= not O4;
inwait: while( I0 = 0 ) loop
if not (I0 = 0) then
rammem(pointer) <= I0;
end if;
end loop inwait;
O4 <= not O4;
end if;
end process workflow;
end work;
您在 begin 语句下方和进程外部所写的内容始终为真,因此这不是任何形式的顺序。想象一下,FPGA 引脚被焊接到地。
您尝试从进程内操纵指针信号,但您做不到,因为您的指针固定为“0”。 如果你想让指针初始化为“0”,就像它看起来的那样,你必须把这一行放在进程中。但是,我看到您尝试使用指针信号调用算术运算,但您将信号定义为 std_logic。 std_logic 可以表示“0”、“1”和其他几种状态,例如 High-Z,但不能表示数字。您应该取整数或自然数进行计算。