1
그래서 나는 그것을 배우는 동안 Verilog에서 ALU를 설계하고 있습니다. 다음 코드를 내놓았다 : 테스트 벤치 : 나는 점점 오전 출력에 따라서내 ALU Verilog에서 어려움
module ALUtb;
reg clock = 1'b0;
reg [0:7] val1;
reg [0:7] val2;
initial begin
val1 = 8'b01010100;
val2 = 8'b10101000;
#50 $finish;
end
ALU piet(val1, val2,, clock);
always begin
#5 clock = ~clock
;
end
endmodule
Main code:
// Code your design here
module ALU(
a1, a2, out, clock
);
output [0:7] out;
input [0:7] a1;
input [0:7] a2;
input clock;
wire clock;
reg out;
wire co;
wire a1, a2;
wire [0:7] poep;
initial begin
$monitor("Out=%d, co=%d, a=%d, a2=%d, poep=%d, clock=%d", out, co, a1, a2, poep, clock);
end
always @ (posedge clock) begin
out <= poep;
end
adder addy(.output_byte(poep), .co(co), .a1(a1), .a2(a2), .clock(clock));
endmodule
module adder(
output_byte, co, a1, a2, clock
);
initial begin
output_byte = 8'b00000011;
end
input [0:7] a1;
input [0:7] a2;
input clock;
output [0:7] output_byte;
output output_bit;
output co;
wire c1;
reg b1, b2;
reg [0:7] output_byte;
wire output_bit;
integer i;
always @ (posedge clock) begin
for(i = 0; i < 8; i = i + 1) begin
b1 = (a1[i] & (1 << i));
b2 = (a2[i] & (1 << i));
#1 output_byte[i] = output_bit;
end
end
bitadder b_adder(.out(output_bit), .co(), .a1(b1), .a2(b2), .c1(c1));
endmodule
// Deze module is een 1-bits adder.
module bitadder(out, co, a1, a2, c1);
output out, co;
input a1, a2, c1;
wire out, co;
wire a1;
wire a2;
wire c1;
assign {co, out} = a1 + a2 + c1;
endmodule
:
Out= x, co=z, a= 84, a2=168, poep= 3, clock=0
Out= 3, co=z, a= 84, a2=168, poep= x, clock=1
Out= 3, co=z, a= 84, a2=168, poep= x, clock=0
Out= x, co=z, a= 84, a2=168, poep= x, clock=1
Out= x, co=z, a= 84, a2=168, poep= x, clock=0
Out= x, co=z, a= 84, a2=168, poep= x, clock=1
Out= x, co=z, a= 84, a2=168, poep= x, clock=0
Out= x, co=z, a= 84, a2=168, poep= x, clock=1
Out= x, co=z, a= 84, a2=168, poep= x, clock=0
Out= x, co=z, a= 84, a2=168, poep= x, clock=1
Out= x, co=z, a= 84, a2=168, poep= x, clock=0
이는 8 비트 가산기입니다 볼 수 있듯이. 아직까지는 작동하지 않기 때문에 아직 진행하지 않았습니다. 궁금한 점은 출력이 제대로 바뀌지 않는 이유는 무엇입니까? Poep은 실제 출력을위한 버퍼와 같습니다. co는 캐리 아웃 비트, a는 첫 번째 숫자, a2는 두 번째 숫자, c1은 캐리 인 비트이며 나머지는 자체적으로 말해야합니다. 출력이 정의되지 않은 이유는 무엇입니까?
도움이 될 것입니다.
미리 감사드립니다.
'# 1 output_byte [i] = output_bit; '은 합성 할 수 없습니다. '덧셈기'에 '항상'블록이 필요하지 않은 경우, 함께 링크 된 8 개의 '비둘기'가 필요합니다. – Greg