File: armscnt.v

package info (click to toggle)
gplcver 2.12a-1
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 7,604 kB
  • ctags: 9,129
  • sloc: ansic: 126,201; sh: 1,539; makefile: 86; perl: 22
file content (158 lines) | stat: -rw-r--r-- 2,201 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
////////////////////////////////////////////////////////////////////////////////
// ARMS_COUNTER
// translated to Verilog from VHDL by Sari Coumeri 
// original VHDL obtained from the '92 High Level Synthesis Benchmarks
// January 1994
////////////////////////////////////////////////////////////////////////////////

// `timescale 1ns / 100ps
module ARMS_COUNTER(CLK,STRB,CON,DATA,COUT);
   input CLK;
   input STRB;
   input [1:0] CON;
   input [3:0] DATA;
   output [3:0] COUT;

//VSS: design_style behavioural

   reg ENIT, RENIT;
   reg EN;
   reg [3:0] CONSIG;
   reg [3:0] LIM;
   reg [3:0] CNT;

   reg [1:0] CONREG;

   reg CNTE;

   assign COUT=CNT;
////////////////  The decoder ////////////////////////////////////-
initial
begin
   CONREG = 2'b00;
   CNTE = 1'b0;
   
end

always @(posedge STRB)
begin

    CONREG = CON;

    case (CONREG)
         2'b00:
begin
 CONSIG = 4'b0001;
end
         2'b01:
begin
 CONSIG = 4'b0010;
end
         2'b10:
begin
 CONSIG = 4'b0100; ENIT = 1'b1;
end
         2'b11:
begin
 CONSIG = 4'b1000; ENIT = 1'b1;
end
         default: ;
    endcase

end // Rising edge of STRB

always @(posedge RENIT)
begin

    ENIT = 1'b0;
  end


////////////////  The limit loader ////////////////////////////////////-

always @(negedge STRB)
begin

  if( (CONSIG[1] == 1'b1)  )
begin

    LIM = DATA;
  end

end


////////////////  The counter ////////////////////////////////////-


always @(posedge CONSIG[0])
begin

    CNT = 4'b0000;
  end

always @(posedge EN)
begin

      CNTE = 1'b1;
    end
always @(negedge EN)
begin

      CNTE = 1'b0;
    end

always @(posedge CLK)
begin
  if( (CNTE == 1'b1) )
begin

    if( (CONSIG[2] == 1'b1) )

      CNT = CNT + 4'b0001;
    else if (CONSIG[3] == 1'b1) 
          CNT = CNT - 4'b0001;
  end
end


////////////////  The comparator ////////////////////////////////////-

always  @(ENIT)
begin
if (ENIT == 1'b1) 
begin
  EN = 1'b1; RENIT = 1'b1;
  if( (EN == 1'b1) && (CNT == LIM) )
begin

    EN = 1'b0;
  end
end
else
begin

  RENIT = 1'b0;
  if( (EN == 1'b1) && (CNT == LIM) )
begin

    EN = 1'b0;
  end
end
end


always @(CNT)
begin
  if( (EN == 1'b1) && (CNT == LIM) )
begin

    EN = 1'b0;
  end

end



endmodule