2013年11月30日 星期六

Counter


  • Design of 2 Bit Binary Counter.
  • Design of 4 Bit Binary Counter.
  • Design of MOD-6 Counter.
  • Design of Integer Counter.
  • Design of BCD Counter or (MOD-10) Counter.


// File  : Design of 2 Bit Counter using Behavior Modeling style.v

module counter_2bit ( clk ,reset ,dout );

output [1:0] dout ;
reg [1:0] dout ;

input clk ;
wire clk ;
input reset ;
wire reset ;

initial dout = 0;

always @ (posedge (clk)) begin
if (reset)
dout <= 0;
else
dout <= dout + 1;
end

endmodule



// File   : Design of 4 Bit Counter using Behavior Modeling Style.v


module Counter_4Bit ( clk ,reset ,dout );

output [3:0] dout ;
reg [3:0] dout ;

input clk ;
wire clk ;
input reset ;
wire reset ;

initial dout = 0;

always @ (posedge (clk)) begin
if (reset)
dout <= 0;
else
dout <= dout + 1;
end


endmodule


// File : Design of MOD-6 counter using behavior Modeling Style.v


module counter_mod6 ( clk ,reset ,dout );

output [2:0] dout ;
reg [2:0] dout ;

input clk ;
wire clk ;
input reset ;
wire reset ;

initial dout = 0;

always @ (posedge (clk)) begin
if (reset)
dout <= 0;
else if (dout<5)
dout <= dout + 1;
else
dout <= 0;
end
  
endmodule



// File   : Design of integer counter using Behavior Modeling Style.v


module counter_integer ( clk ,reset ,dout );

output [9:0] dout ;
reg [9:0] dout ;

input clk ;
wire clk ;
input reset ;
wire reset ;

initial dout = 0;

always @ (posedge (clk)) begin
if (reset)
dout <= 0;
else if (dout < 1023)
dout <= dout + 1;
else if (dout==1023)
dout <= 0;
end


endmodule


// File   : Design of BCD Counter using Behavior Modeling Style.v


module BCD_Counter ( clk ,reset ,dout );

output [3:0] dout ;
reg [3:0] dout ;

input clk ;
wire clk ;
input reset ;
wire reset ;

initial dout = 0 ;

always @ (posedge (clk)) begin
if (reset)
dout <= 0;
else if (dout<=9) begin
dout <= dout + 1;
end else if (dout==9) begin
dout <= 0;
end
end


endmodule






沒有留言:

張貼留言

2024產專班 作業2 (純模擬)

2024產專班 作業2  (純模擬) 1) LED ON,OFF,TIMER,FLASH 模擬 (switch 控制) 2)RFID卡號模擬 (buttom  模擬RFID UID(不從ESP32) 3) 使用database需先create建立資料庫 Node-Red 程式 [...