2012年10月12日 星期五

8-Bit Up-Down Counter

8-Bit Up-Down Counter
1 //----------------------------------------------------- 2 // Design Name : up_down_counter 3 // File Name : up_down_counter.v 4 // Function : Up down counter 5 // Coder : Deepak Kumar Tala 6 //----------------------------------------------------- 7 module up_down_counter ( 8 out , // Output of the counter 9 up_down , // up_down control for counter 10 clk , // clock input 11 data , // Data to load 12 reset // reset input 13 ); 14 //----------Output Ports-------------- 15 output [7:0] out; 16 //------------Input Ports-------------- 17 input [7:0] data; 18 input up_down, clk, reset; 19 //------------Internal Variables-------- 20 reg [7:0] out; 21 //-------------Code Starts Here------- 22 always @(posedge clk) 23 if (reset) begin // active high reset 24 out <= 8'b0 ; 25 end else if (up_down) begin 26 out <= out + 1; 27 end else begin 28 out <= out - 1; 29 end 30 31 endmodule

沒有留言:

張貼留言

Node-Red Dashboard UI Template + AngularJS 參考 AngularJS教學 --3

  Node-Red Dashboard UI Template + AngularJS 參考 AngularJS教學 --3 AngularJS 實例 <!DOCTYPE html> <html> <head> <meta charse...