0

我必须在 8 个函数的 ralu 中创建一个 alu,但是当我尝试模拟“ralu”的行为模型时,我得到的只是 X(输出)和 Z(输入)。我究竟做错了什么?(当我只模拟 alu 时它工作得很好)

module alu(
      input [3:0] op1,
      input [3:0] op2,
      input [2:0] func,
      output reg[3:0] out
    );
always@(*)
  case(func)
    3'b000: out=op1&op2; // functia AND
    3'b001: out=op1|op2; // OR
    3'b010: out=~(op1&op2);// NAND
    3'b011: out=~(op1|op2); //NOR
    3'b100: out=op1^op2; // XOR
    3'b101: out=op1~^op2; //XNOR
    3'b110: out=op1+op2;
    3'b111: out=op1-op2;
  endcase
endmodule

module ralu(
      input [3:0] in,
      input [2:0] func,
      input clk,
      input load,
      output [3:0] out
    );
reg [3:0] op1;
reg [3:0] op2;
always@(posedge clk)
  if(load) op2<=in;
  else op1<=in;
endmodule  
4

1 回答 1

0

您缺少aluin 的声明ralu,即:

alu myALU(
    .op1(op1),
    .op2(op2),
    .func(func),
    .out(out)
);
于 2014-05-12T17:15:50.223 回答