Lab 12 Task 01 Simulation For Up Down Counter Using Behaviour Modeling
Lab 12 Task 01 Simulation For Up Down Counter Using Behaviour Modeling
Lab 12 Task 01 Simulation For Up Down Counter Using Behaviour Modeling
Task 01
Simulation for up down counter using behaviour modeling
;module up_down_counter (out,up_down,clk,reset)
;output [7:0] out
;input up_down,clk, reset
;reg [7:0] out
always @(posedge clk)
if (reset) begin // active high reset
; out <= 8'b0
end
else if (up_down) begin
out <= out + 1;end else begin
out <= out - 1;end
endmodule
Test Bench
;module tb_counter
;reg Clk; reg reset; reg UpOrDown
;wire [3:0] Count
(
) upordown_counter uut
,Clk(Clk).
,reset(reset).
,UpOrDown(UpOrDown).
Count(Count).
;(
;initial Clk = 0
;always #5 Clk = ~Clk
initial begin
;reset = 0
;UpOrDown = 0
;#300
;UpOrDown = 1
;#300
;reset = 1
;UpOrDown = 0
;#100
;reset = 0
end
endmodule
Simulation Result