我正试图从一点alu创建一个涟漪,
除了slt操作外,每件事情都能正常工作
它是这样实现的,因为有一点alu输入'less'
除了LSB之外它被设置为零,它从减法的MSB得到了它的价值
one_bit_alu alu0 (.op(op), .a(a[0]), .b(b[0]), .cin(1'b0 ), .less(set), .r(z[0]), .cout(carry[0]));
one_bit_alu alu1 (.op(op), .a(a[1]), .b(b[1]), .cin(carry[0]), .less(1'b0), .r(z[1]), .cout(carry[1]));
one_bit_alu alu2 (.op(op), .a(a[2]), .b(b[2]), .cin(carry[1]), .less(1'b0), .r(z[2]), .cout(carry[2]));
one_bit_alu alu3 (.op(op), .a(a[3]), .b(b[3]), .cin(carry[2]), .less(1'b0), .r(z[3]), .cout(carry[3]));
one_bit_alu alu4 (.op(op), .a(a[4]), .b(b[4]), .cin(carry[3]), .less(1'b0), .r(z[4]), .cout(carry[4]));
one_bit_alu alu5 (.op(op), .a(a[5]), .b(b[5]), .cin(carry[4]), .less(1'b0), .r(z[5]), .cout(carry[5]));
one_bit_alu alu6 (.op(op), .a(a[6]), .b(b[6]), .cin(carry[5]), .less(1'b0), .r(z[6]), .cout(carry[6]));
one_bit_alu alu7 (.op(op), .a(a[7]), .b(b[7]), .cin(carry[6]), .less(1'b0), .r(z[7]), .set(set));
这是one_bit_alu模块中“set”信号的逻辑
full_subtractor subtract(.d(subOP), .a(b), .b(a), .Bor_in(cin), .Bor_out(subOP_bout));
and (set, subOP, 1'b1);
似乎每件事情都很好,但我得到'x'了!
=================================
one_bit_alu模块
`include "../lib/mux_16to1.v"
`include "../lib/full_adder.v"
`include "../lib/full_subtractor.v"
module one_bit_alu (
input [3:0] op,
input a, b, cin, less, sub,
output r, cout, bout, set
);
wire int0, int1, int2, int3, addOP, subOP, addOP_cout, subOP_bout;
and (int0 , a, b);
or (int1 , a, b);
xor (int2 , a, b);
nor (int3, a, b);
xor (xorB, b, sub);
full_adder add (.sum(addOP), .a(a), .b(b), .cin(cin), .cout(addOP_cout));
full_subtractor subtract(.d (subOP), .a(b), .b(a), .Bor_in(cin), .Bor_out(subOP_bout));
and (set, subOP, 1'b1);
mux_16to1 mux0(
.s (op ),
.i0 (int0 ),
.i1 (int1 ),
.i2 (addOP),
.i6 (subOP),
.i7 (less ),
.i12(int3 ),
.z (r )
);
mux_16to1 mux1(
.s(op),
.i2(addOP_cout),
.i6(subOP_bout),
.z(cout));
endmodule
full_subtractor模块
module full_subtractor (
output Bor_out, d,
input a, b, Bor_in
);
wire int1, int2, int3, int4, b_bar;
// d = (a xor b) xor Bor_in
xor (int1, a, b);
xor (d, int1, Bor_in);
// Bor_out = ((a xor b)' and Bor_in) or (a and b')
not (int2, int1);
and (int3, int2, Bor_in); //(a xor b)' and Bor_in
not (b_bar, b);
and (int4, b_bar, a); //a and b'
or (Bor_out, int4, int3);
endmodule
答案 0 :(得分:0)
发现它!
stl操作取决于减法操作,在我的设计中我为cout制作了一个多路复用器,可以从加法器或减法器中取出它,具体取决于' op',所以我应该输出它将用于stl操作, mux1会是这样的
mux_16to1 mux1(
.s(op),
.i2(addOP_cout),
.i6(subOP_bout),
.i7(subOP_bout), //2 days to find this line!
.z(cout));