Jun 10, 2007 #1 E ec10404 Newbie level 3 Joined Jun 6, 2007 Messages 4 Helped 0 Reputation 0 Reaction score 0 Trophy points 1,281 Activity points 1,301 counter veriloga code hi friends can u give me verilog A code for divide by n counter for giver clock and duty cycle.
counter veriloga code hi friends can u give me verilog A code for divide by n counter for giver clock and duty cycle.
Jun 11, 2007 #2 lordsathish Full Member level 5 Joined Feb 11, 2006 Messages 246 Helped 33 Reputation 66 Reaction score 3 Trophy points 1,298 Location Asia Activity points 2,698 veriloga counter This is the code for mod 9 counter module counter(Q , clock, clear,op); output op; output [3:0] Q; input clock, clear; reg [3:0] Q; always @( posedge clock or negedge clear) begin if (!clear) Q = 4'd0; else if(Q==4'd9) Q = 4'd0; else Q = (Q + 1) ; end assign op = (Q==4'd9) ? 1:0; endmodule
veriloga counter This is the code for mod 9 counter module counter(Q , clock, clear,op); output op; output [3:0] Q; input clock, clear; reg [3:0] Q; always @( posedge clock or negedge clear) begin if (!clear) Q = 4'd0; else if(Q==4'd9) Q = 4'd0; else Q = (Q + 1) ; end assign op = (Q==4'd9) ? 1:0; endmodule