source: vis_dev/vis-2.1/examples/counter/counter.v @ 16

Last change on this file since 16 was 11, checked in by cecile, 13 years ago

Add vis

File size: 621 bytes
Line 
1/* translation of counter.smv to verilog
2
3   Sriram Krishnan 7/93.
4   
5
6
7*/ 
8
9
10
11module counter(clk);
12input clk;
13
14wire out0, out1, out2; 
15
16counter_cell bit0 (clk, 1, out0);
17counter_cell bit1 (clk, out0, out1);
18counter_cell bit2 (clk, out1, out2); 
19
20endmodule
21
22module counter_cell(clk, carry_in, carry_out); 
23input clk; 
24input carry_in; 
25output carry_out; 
26reg value; 
27
28assign carry_out = value & carry_in;
29
30initial value = 0;
31
32always @(posedge clk) begin
33// value = (value + carry_in) % 2; 
34        case(value)         
35                0: value = carry_in; 
36                1: if (carry_in ==0) 
37                        value = 1;
38                else value = 0;
39        endcase 
40end 
41endmodule
42
Note: See TracBrowser for help on using the repository browser.