Line | |
---|
1 | /* translation of counter.smv to verilog |
---|
2 | |
---|
3 | Sriram Krishnan 7/93. |
---|
4 | |
---|
5 | |
---|
6 | |
---|
7 | */ |
---|
8 | |
---|
9 | |
---|
10 | |
---|
11 | module counter(clk); |
---|
12 | input clk; |
---|
13 | |
---|
14 | wire out0, out1, out2; |
---|
15 | |
---|
16 | counter_cell bit0 (clk, 1, out0); |
---|
17 | counter_cell bit1 (clk, out0, out1); |
---|
18 | counter_cell bit2 (clk, out1, out2); |
---|
19 | |
---|
20 | endmodule |
---|
21 | |
---|
22 | module counter_cell(clk, carry_in, carry_out); |
---|
23 | input clk; |
---|
24 | input carry_in; |
---|
25 | output carry_out; |
---|
26 | reg value; |
---|
27 | |
---|
28 | assign carry_out = value & carry_in; |
---|
29 | |
---|
30 | initial value = 0; |
---|
31 | |
---|
32 | always @(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 |
---|
40 | end |
---|
41 | endmodule |
---|
42 | |
---|
Note: See
TracBrowser
for help on using the repository browser.