nizdom
Member level 2
Hi All,
I am a newbie in Verilog and I wanted to make a code to display the functions of the 74LS190 which is an Up/Down Counter. 74LS190 is a synchronous Up/Down BCD Counter in which the state changes of the counter are synchronous with the LOW-to-HIGH transition of the Clock Pulse Input. I wanted to code something like it will count up from 0 to 9 then back to 0 and count down from 9 to 0 then back to 9. Any help? Can you check the code below if it answers my question and if not, any way I can modify the code?
I am a newbie in Verilog and I wanted to make a code to display the functions of the 74LS190 which is an Up/Down Counter. 74LS190 is a synchronous Up/Down BCD Counter in which the state changes of the counter are synchronous with the LOW-to-HIGH transition of the Clock Pulse Input. I wanted to code something like it will count up from 0 to 9 then back to 0 and count down from 9 to 0 then back to 9. Any help? Can you check the code below if it answers my question and if not, any way I can modify the code?
Code Verilog - [expand] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 module up_down_counter ( out , // Output of the counter up_down , // up_down control for counter clk , // clock input data , // Data to load reset // reset input ); //----------Output Ports-------------- output [9:0] out; //------------Input Ports-------------- input [9:0] data; input up_down, clk, reset; //------------Internal Variables-------- reg [9:0] out; //-------------Code Starts Here------- always @(posedge clk) if (reset) begin // active high reset out <= 10'b0 ; end else if (up_down) begin out <= out + 1; end else begin out <= out - 1; end endmodule
Last edited by a moderator: