最初のページ 戻る 次へ 最後のページ

同期3進カウンタ

/*3進カウンタ (0→1→2→0)*/

module counter012(clk,clr,en,q);

input clk,clr,en;

output [1:0] q;

reg q;

always @(negedge clk or negedge clr ) begin

if(!clr) q<=2'b00;

else if (en) begin

if(q==2'b10) q<=2'b00;

else q<=q+2'b01;

end

end

endmodule

モジュール名は

counter012

moduleで始まり

endmoduleで終わる

enable=1のとき

カウントアップ

(入力Aに相当)