3bit Counter |
FSM diagram |
Data Flow |
Truth Table |
Verilog Code:
module UpDown_Counter_loopFilter( up_dn, CLK, up_dn_counter );
input up_dn;
input CLK;
output reg [2:0] up_dn_counter;
initial
begin
up_dn_counter = 3'b000;
end
always @(posedge CLK)
begin
if (up_dn == 1'b1)
begin
up_dn_counter = up_dn_counter + 1'b1;
end
else if (up_dn == 1'b0)
begin
up_dn_counter = up_dn_counter - 1'b1;
end
end
endmodule
Waveform : (simulation)
0 comments:
Post a Comment