概要
windowsでiverilogやってみた。
練習問題やってみた。
練習問題
zundokoを書け。
サンプルコード
module test;
integer p;
integer stdin = 'h8000_0000;
integer a,
b;
integer ch;
reg [7:0] pc;
reg [7:0] str[0:9];
integer v;
initial
begin
pc <= 10;
v = 0;
a = 0;
b = 0;
end
always #1
begin
case(pc)
10:
begin
b = 234;
pc <= 20;
end
20:
begin
b = (b * 5 + 1) % 256;
pc <= 30;
end
30:
begin
if (b < 120)
begin
pc <= 60;
end
else
begin
pc <= 40;
end
end
40:
begin
$write("%s ", "zun");
a++;
pc <= 50;
end
50:
begin
if (a > 3)
begin
pc <= 70;
end
else
begin
pc <= 20;
end
end
60:
begin
$write("%s ", "doko");
a = 0;
pc <= 20;
end
70:
begin
$write("%s\n", "doko kiyosi!!");
pc <= 80;
end
80:
begin
$finish(0);
end
endcase
end
initial
begin
//$monitor(" %d", pc);
end
endmodule
実行結果
>vvp a.out
zun zun doko zun zun zun doko doko zun doko zun zun doko doko doko doko zun zun doko doko zun doko doko zun zun doko doko doko doko doko zun zun zun zun doko kiyosi!!
以上