我在verilog中有一个8位的ALU单元,可以添加,反转等。这个单元被测试并正确执行。当我结合其中4个做出更大的ALU时,除了当我选择加法运算时,每个输出都是正确的,它出现为 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx01010101
,基本上第一个alu完成工作,然后第二个输出是xxxxxxxx
,第三个第四。这真是令人沮丧!使用创建的ALU做出更大的一个
8位模块(这将是很好的点,如果这种模式是一种行为或结构模型我去的前!)
module alu_8bit(
output reg [7:0] out,
output reg cout,g,e,
input [7:0] A,B,
input cin,
input [2:0] S
);
//used functions
parameter BUF_A = 3'b000;
parameter NOT_A = 3'b001;
parameter ADD = 3'b010;
parameter OR = 3'b011;
parameter AND = 3'b100;
parameter NOT_B = 3'b101;
parameter BUF_B = 3'b110;
parameter LOW = 3'b111;
always @(A or B or S) begin
//Comparator
g = A>B;
e = A==B;
//Other selective functions
case(S)
BUF_A: out = A;
NOT_A: out = ~A;
ADD: {cout,out} = A+B+cin;
OR: out = A | B;
AND: out = A & B;
NOT_B: out = ~B;
BUF_B: out = B;
LOW: out = {8{1'b0}};
endcase
end
endmodule
这里是大的代码:
module alu_32bit(
output [31:0] out,
output cout,g,e,
input [31:0] A,B,
input cin,
input [2:0] S
);
wire e1,e2,e3,e4;
wire g1,g2,g3,g4;
alu_8bit ALU1(out[7:0],cin2,g1,e1,A[7:0],B[7:0],cin,S);
alu_8bit ALU2(out[15:8],cin3,g2,e2,A[15:8],B[15:8],cin2,S);
alu_8bit ALU3(out[23:16],cin4,g3,e3,A[23:16],B[23:16],cin3,S);
alu_8bit ALU4(out[31:24],cout,g4,e4,A[31:24],B[31:24],cin4,S);
assign g = g4 | (e4 & g3) |(e4 & e3 & g2) | (e4& e3 & e2 & g1);
assign e = e4 & e3 & e2 & e1;
endmodule
任何人都可以帮忙吗?!如果您需要更多信息,请告诉我。
编辑:
波形PIC清楚地输入进来正确的,但产量不
数据流图显示,ALU1输出就好了
您是否检查过从ALU1(加法器)执行的不是X? – Morgan 2013-04-28 13:29:52
是的进位是零和输入到下一个是正确的你想我把8位的不满足? – 2013-04-28 14:05:10
8位ALU可能很有用,ALU2波形的屏幕截图也可能有用。 – Morgan 2013-04-29 06:37:54