Forum Discussion

Altera_Forum's avatar
Altera_Forum
Icon for Honored Contributor rankHonored Contributor
10 years ago

74LS190 Verilog Code

Hi. I'm a newbie in Verilog Programming. I wish to code using Verilog the functions of the 74LS190 which is simply an Up/Down Counter. Anyone who knows any code on this? It's basically a counter that will count up from 0-9 then back to 0 or count down from 9-0 then back to 9. 74LS190 is a Synchronous Up/Down BCD Decade counter. The state changes of the counters are basically synchronous with the LOW-to-HIGH transition of the Clock Pulse Input. Help please. Thanks.

Can you check if the code below is almost the same on what I am trying to find.

module up_down_counter (count, D_in, load, count_up, cntr_on, clk, reset);

output [2:0] count;

input load, count_up, cntr_on, clk, reset;

input [2:0] D_in;

reg [2:0] count;

always @ (posedge reset or posedge clk)

if (reset==1'b1) count=3'b0; else

if (load==1'b1) count=D_in;

if (cntr_on==1)

begin

if (count_up==1'b1) count=count + 1;

else

count=count - 1;

end

endmodule

Thanks!

1 Reply