內容經過我的仿真和測試,若有錯漏,請留言指出!
源碼:
module Com(a,b,out);
input [7:0] a,b;
output out;
assign out = (a > b)? 1:0;
endmodule
測試代碼:
`timescale 1ns/1ns
module com8;
reg [7:0]a,b;
wire out;
initial
begin
a = 8'h0;
b = 8'h0;
repeat(20)//總共仿真時間來200ns就夠了
begin
#10
a = ($random)%8'hff;
b = ($random)%8'hff;
end
end
Com Com0(
.a(a),
.b(b),
.out(out)
);
endmodule
仿真結果: