addmod.v
1.32 KB
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
// This confidential and propriety software may be used
// only as authorized by a licensing agreement from
// Ocean Logic Pty Ltd http:/www.ocean-logic.com
//
// In the event of publication, the following notice is
// applicable
//
// (C) COPYRIGHT 2001 Ocean Logic Pty Ltd
// ALL RIGHTS RESERVED
//
// the entire notice must be reproduced on all
// authorized copies
//
// File : addmod.vhd
// Author : Vincenzo Liguori
// Date : 01-03-02
// Version 1.0
// Abstract :
// This module implements a counter
//
// addmodification history :
// Date by Version Change description
// -------------------------------------------------
// 01-03-02 VL 1.0 Original
module addmod(
clk,
rstn,
en,
clrn,
endround,
inc,
raddr
);
// Inputs
input clk, rstn;
input en, clrn, endround;
input[1:0] inc;
// Outputs
output[1:0] raddr;
wire clk;
wire rstn;
wire en;
wire clrn;
wire endround;
wire [1:0] inc;
reg [1:0] raddr;
// Intermediate signals
wire [1:0] plus;
assign plus = endround == 1'b 0 ? 2'b 01 : inc;
always @(posedge clk or negedge rstn) begin
if(rstn == 1'b 0) begin
raddr <= {2{1'b0}};
end else begin
if(en == 1'b 1) begin
if(clrn == 1'b 0) begin
raddr <= {2{1'b0}};
end
else begin
raddr <= raddr + plus;
end
end
end
end
endmodule