verilog编译仿真时出现问题(程序如下)
module compare(A,B,C,Max,Min,Med);parameter width=8;
input A,B,C;
output Max,Min,Med;
reg Max,Min,Med;
reg a,b,c;
always @(A or B or C)
begin
if(A>B)
a=2'b10;
else if (A<B)
a=2'b00;
else a=2'b01;
if (B>C)
b=2'b10;
else if (B<C)
b=2'b00;
else
b=2'b01;
if(A>C)
c=2'b10;
else if (A<C)
c=2'b00;
else
c=2'b01;
case({a,b,c})
6'b101010: begin
Max=A; Med=B; Min=C;
end //A>B>C
6'b100010: begin
Max=A; Med=C; Min=B;
end //A>C>B
6'b100000: begin
Max=C; Med=A; Min=B;
end //C>A>B
6'b100001: begin
Max=A;Med=A;Min=B;
end //A=C>B
6'b100110: begin
Max=A;Med=B;Min=B;
end //A>B=C
6'b001010: begin
Max=B;Med=A; Min=C;
end //B>A>C
6'b001000: begin
Max=B; Med=C; Min=A;
end //B>C>A
6'b000101: begin
Max=B;Med=C;Min=C;
end //B>A=C;
6'b000000: begin
Max=C;Med=B;Min=A;
end //C>B>A
6'b000100: begin
Max=C;Med=C;Min=A;
end //C=B>A
6'b011010: begin
Max=A;Med=A;Min=C;
end //A=B>C
6'b010000: begin
Max=C;Med=A;Min=A;
end //C>A=B
6'b010101: begin
Max=A;Med=A;Min=A;
end //A=B=C
default: begin
Max=0;Med=0;Min=0;
end //$display("there is an error in the input data!");
endcase
end
endmodule 程序太繁琐了,用FUNCTION,在程序中调用应该好多了。。 可读性不是很好。。。。 有错吗?感觉代码没问题,modelsim仿了一下也没错啊。你应该把testbench和波形图贴上来。 出现什么问题也不帖出来?
页:
[1]