概要
windowsでiverilogやってみた。
nslやってみた。
半加算器、書いてみた。
サンプルコード
declare ha {
input a;
input b;
output c;
output o;
}
module ha {
{
c = a & b;
o = a ^ b;
}
}
テストベンチ
module test;
reg clk,
rst;
reg a,
b;
ha u(.clk(clk), .rst(rst), .a(a), .b(b), .c(c), .o(o));
always #1 clk = ~clk;
integer i,
j;
initial
begin
clk = 0;
rst = 1;
#1
rst = 0;
#1
rst = 1;
$display("a b c o");
$monitor("%b %b %b %b", a, b, c, o);
for(i = 0; i < 2; i = i + 1) begin
for(j = 0; j < 2; j = j + 1) begin
a = i;
b = j;
#1;
end
end
$finish;
end
endmodule
実行結果
a b c o
0 0 0 0
0 1 0 1
1 0 0 1
1 1 1 0
以上