Enter into Zilicon Zone


RocketTheme Joomla Templates


Read more...
VLSI WORLD FORUM
Welcome, Guest
Please Login or Register.
Lost Password?
Coding style – Verilog counter (1 viewing)
_GEN_GOTOBOTTOM Post Reply

TOPIC: Coding style – Verilog counter

#20
Chola (User)
Expert Boarder
Posts: 50
graph
Coding style – Verilog counter 2007/05/15 20:42 Karma: 1  
Here I would like to mention 2 different ways to design a counter. Second one is the normal one and the First one is the convenient way. This technique would be useful for some other logics as well.

counter1
Code:

 module counter1(clk1,rst_n1,en1,count1);    input clk1;    input rst_n1;    input en1;    output [2:0count1;    reg [2:0]     count1;    always @ (posedge clk1 or negedge rst_n1)      begin     if (!rst_n1)       count1 <= 3b0;     else       count1 <= count1 en1;      end endmodule


counter2
Code:

 module counter2(clk2,rst_n2,en2,count2);    input clk2;    input rst_n2;    input en2;    output [2:0count2;    reg [2:0]     count2;      always @ (posedge clk2 or negedge rst_n2)      begin     if (!rst_n2)       count2 <= 3b0;     else           if (en2)              count2 <= count2 1;           else             count2 <= count2;      end endmodule

With great power there must also come - great responsibility
+Stan Lee
  The administrator has disabled public write access.
#125
swaminathavijayaraj (User)
Fresh Boarder
Posts: 1
graphgraph
Re:Coding style – Verilog counter 2008/06/25 17:00 Karma: 0  
Hi Karma,

Good logic idea. Is it only a style change, or hardware minimization ?
  The administrator has disabled public write access.
#126
Chola (User)
Expert Boarder
Posts: 50
graph
Re:Coding style – Verilog counter 2008/06/25 17:42 Karma: 1  
Hi....
It looks..it may have less hardware....But synthesis tool will understand both codes almost in same manner...

just for better readability..
+Chola
With great power there must also come - great responsibility
+Stan Lee
  The administrator has disabled public write access.
_GEN_GOTOTOP Post Reply
VLSI-world.com