我如何连接我的两个模块?

时间:2014-05-12 16:52:58

标签: verilog xilinx alu

我必须在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  

1 个答案:

答案 0 :(得分:0)

您在alu中遗漏了ralu的声明,即:

alu myALU(
    .op1(op1),
    .op2(op2),
    .func(func),
    .out(out)
);
相关问题