当前位置: 代码迷 >> 单片机 >> 求Vhdl大神debug!小弟初学着实找不出了
  详细解决方案

求Vhdl大神debug!小弟初学着实找不出了

热度:41   发布时间:2016-04-28 15:54:10.0
求Vhdl大神debug!!小弟初学实在找不出了。
以下为一个cpu运算单元设计
里面有8个寄存器。。。指令系统
IRin为指令
15-11位为操作码,若双寄存器则8-10和2-0为这两个寄存器地址。
若单寄存器则只有8-10表示

前期有个指令地址部分(根据有地址的指令系统,jmp之类的指令,低8位)和r7并接给addr。

cout为进位符号输出
ct为进位信号
alu为9位结果最后赋值的时候将低8位给结果输出ALUout,若为算术运算给ct进位标志。。。
大致情况就是以上了。。。
以下为代码,modelsim模拟的时候,若输入接口IRin与t1对齐则cout总是中间出现毛刺或红线,若不对齐aluout和cout都红线了。

求指导啊。


library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
entity cacu is
  port(t1, Rupdate,rst: in std_logic;
IRin: in std_logic_vector(15 downto 0);
Rnew: in std_logic_vector(7 downto 0);
ALUout: out std_logic_vector(7 downto 0);
addr: out std_logic_vector(15 downto 0); 
cout: out std_logic);
end cacu;
architecture main of cacu is
type Reg is array(7 downto 0) of std_logic_vector(7 downto 0); --二维数组
signal R: Reg;
signal A, B: std_logic_vector(8 downto 0);
signal alu:std_logic_vector(8 downto 0);
signal ct:std_logic;
begin  
process (t1, Rupdate)
begin  
  if(Rupdate = '1') then --更新寄存器  
R(conv_integer(IRin(10 downto 8))) <= Rnew;
elsif(t1 = '1' and t1'event) then --第二节拍将两寄存器提取到A.B
A <= '0'&R(conv_integer(IRin(10 downto 8))); --先将待操作的寄存器的内容转移
B <= '0'&R(conv_integer(IRin(2 downto 0)));
addr(15 downto 8) <= R(7); --拼接地址
  addr(7 downto 0) <= IRin(7 downto 0);
  end if;
  end process;
  process(IRin, A, B) --按OP讨论操作
begin

case IRin(15 downto 11) is
when "10110" => 
alu<= A; --JZ Ri, X
when "00010" => 
alu <= A - B-ct; -- SUB Ri, Rj
when "00100" => 
alu <= A + B+ct; -- add Ri, Rj
when "11000" => 
alu <= IRin(8 downto 0); -- MVI Ri, X
when "11010" => 
alu <= B; -- MOV Ri, Rj
when "11100" => 
alu <= A; -- STA Ri, X
when "10010"=>--and
alu<=A and B;
when "10100"=> --or
alu<=A or B;
when others => 
alu <= "0ZZZZZZZZ";
  end case;
end process;
ALUout<=alu(7 downto 0);
process(rst,alu(8))
begin
if(rst='1') then
ct<='0';
else
if(IRin(15)='0')then
ct<=alu(8);
end if;
end if;
end process;
cout<=ct;
end main;


------解决方案--------------------
对我这个只会C的,略微了解C++的来说这完全就是天书
------解决方案--------------------
VHDL,我最近也在学,建议到FPGA论坛去问一下。
------解决方案--------------------
VHDL,没有学过,帮不了楼主。
  相关解决方案