所以,我正在开发一个用于MIPS架构的算术逻辑单元,我正在尝试进行左移和右移,这样算术逻辑单元就可以移动任何数量的位。
我的想法是将移位值转换为整数,并选择将出现在结果中的条目部分(整数存储在X中),但是Quartus不接受变量值,只接受常量。
我该怎么做才能做到这一点?(当"1000“=>...”和"WHEN "1001“=>...")
谢谢。
PROCESS ( ALU_ctl, Ainput, Binput, X )
BEGIN
-- Select ALU operation
--ALU_output_mux <= X"00000000"; --padrao
CASE ALU_ctl IS
WHEN "1000" => ALU_output_mux(31 DOWNTO X) <= (Ainput( 31-X DOWNTO 0 ));
WHEN "1001" => ALU_output_mux(31-X DOWNTO 0) <= (Ainput( 31 DOWNTO X ));
WHEN OTHERS => ALU_output_mux <= X"00000000";
END CASE;
END PROCESS;发布于 2011-06-22 22:42:32
如果Quartus不喜欢它,你有两个选择:
发布于 2011-06-22 22:40:28
我在Quartus中也遇到过这个问题,尽管您的代码也有一些隐式的闩锁(您没有在两个移位情况下分配输出的所有位)。
我使用的变通办法是定义一个包含所有可能结果的中间数组,然后使用选择器选择其中一个结果。在您的示例中,如下所示:
subtype DWORD_T is std_logic_vector( 31 downto 0);
type DWORD_A is array (natural range <>) of DWORD_T;
signal shift_L : DWORD_A(31 downto 0);
signal shift_R : DWORD_A(31 downto 0);
signal zero : DWORD_T;
...
zero <= (others=>'0');
process (Ainput)
begin
for index in Ainput'range loop
shift_L(index) <= Ainput(31 - index downto 0) & zero(index - 1 downto 0);
shift_R(index) <= zero(index - 1 downto 0) & Ainput(31 downto index);
end loop;
end process;
ALR_output_mux <= shift_L(to_integer(X)) when ALU_ctl="1000",
shift_R(to_integer(X)) when ALU_ctl="1001",
(others=>'0') when others;发布于 2011-07-12 22:30:27
您可以通过使用generate或for创建每个平移/旋转级别来解决此问题,也可以使用standard functions ({shift,rotate}_{left,right})进行平移和旋转。
https://stackoverflow.com/questions/6440363
复制相似问题