-
Notifications
You must be signed in to change notification settings - Fork 517
/
cl_vio.sv
105 lines (86 loc) · 3.46 KB
/
cl_vio.sv
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
// Amazon FPGA Hardware Development Kit
//
// Copyright 2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
//
// Licensed under the Amazon Software License (the "License"). You may not use
// this file except in compliance with the License. A copy of the License is
// located at
//
// http://aws.amazon.com/asl/
//
// or in the "license" file accompanying this file. This file is distributed on
// an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, express or
// implied. See the License for the specific language governing permissions and
// limitations under the License.
module cl_vio (
input clk_extra_a1
);
// Counter running at 125MHz
logic vo_cnt_enable;
logic vo_cnt_load;
logic vo_cnt_clear;
logic vo_cnt_oneshot;
logic [7:0] vo_tick_value;
logic [15:0] vo_cnt_load_value;
logic [15:0] vo_cnt_watermark;
logic vo_cnt_enable_q = 0;
logic vo_cnt_load_q = 0;
logic vo_cnt_clear_q = 0;
logic vo_cnt_oneshot_q = 0;
logic [7:0] vo_tick_value_q = 0;
logic [15:0] vo_cnt_load_value_q = 0;
logic [15:0] vo_cnt_watermark_q = 0;
logic vi_tick;
logic vi_cnt_ge_watermark;
logic [7:0] vi_tick_cnt = 0;
logic [15:0] vi_cnt = 0;
// Tick counter and main counter
always @(posedge clk_extra_a1) begin
vo_cnt_enable_q <= vo_cnt_enable ;
vo_cnt_load_q <= vo_cnt_load ;
vo_cnt_clear_q <= vo_cnt_clear ;
vo_cnt_oneshot_q <= vo_cnt_oneshot ;
vo_tick_value_q <= vo_tick_value ;
vo_cnt_load_value_q <= vo_cnt_load_value;
vo_cnt_watermark_q <= vo_cnt_watermark ;
vi_tick_cnt = vo_cnt_clear_q ? 0 :
~vo_cnt_enable_q ? vi_tick_cnt :
(vi_tick_cnt >= vo_tick_value_q) ? 0 :
vi_tick_cnt + 1;
vi_cnt = vo_cnt_clear_q ? 0 :
vo_cnt_load_q ? vo_cnt_load_value_q :
~vo_cnt_enable_q ? vi_cnt :
(vi_tick_cnt >= vo_tick_value_q) && (~vo_cnt_oneshot_q || (vi_cnt <= 16'hFFFF)) ? vi_cnt + 1 :
vi_cnt;
vi_tick = (vi_tick_cnt >= vo_tick_value_q);
vi_cnt_ge_watermark = (vi_cnt >= vo_cnt_watermark_q);
end // always @ (posedge clk_extra_a1)
vio_0 CL_VIO_0 (
.clk (clk_extra_a1),
.probe_in0 (vi_tick),
.probe_in1 (vi_cnt_ge_watermark),
.probe_in2 (vi_tick_cnt),
.probe_in3 (vi_cnt),
.probe_out0 (vo_cnt_enable),
.probe_out1 (vo_cnt_load),
.probe_out2 (vo_cnt_clear),
.probe_out3 (vo_cnt_oneshot),
.probe_out4 (vo_tick_value),
.probe_out5 (vo_cnt_load_value),
.probe_out6 (vo_cnt_watermark)
);
ila_vio_counter CL_VIO_ILA (
.clk (clk_extra_a1),
.probe0 (vi_tick),
.probe1 (vi_cnt_ge_watermark),
.probe2 (vi_tick_cnt),
.probe3 (vi_cnt),
.probe4 (vo_cnt_enable_q),
.probe5 (vo_cnt_load_q),
.probe6 (vo_cnt_clear_q),
.probe7 (vo_cnt_oneshot_q),
.probe8 (vo_tick_value_q),
.probe9 (vo_cnt_load_value_q),
.probe10 (vo_cnt_watermark_q)
);
endmodule