Skip to content

Commit f18409a

Browse files
committed
[hw,clkmgr,rtl] Gate calibration input together with ext clock bypass
Signed-off-by: Robert Schilling <[email protected]>
1 parent 640c594 commit f18409a

File tree

25 files changed

+50
-164
lines changed

25 files changed

+50
-164
lines changed

hw/ip_templates/clkmgr/data/clkmgr.hjson.tpl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ rg_srcs = get_rg_srcs(typed_clocks)
252252
package: "prim_mubi_pkg",
253253
width: "${len(hint_names)}"
254254
},
255-
255+
% if ext_clk_bypass:
256256
{ struct: "mubi4",
257257
desc: "Indicates clocks are calibrated and frequencies accurate",
258258
type: "uni",
@@ -261,6 +261,7 @@ rg_srcs = get_rg_srcs(typed_clocks)
261261
package: "prim_mubi_pkg",
262262
default: "prim_mubi_pkg::MuBi4True"
263263
},
264+
% endif
264265
],
265266

266267
countermeasures: [

hw/ip_templates/clkmgr/dv/env/clkmgr_if.sv.tpl

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -53,16 +53,13 @@ interface clkmgr_if (
5353
prim_mubi_pkg::mubi4_t all_clk_byp_ack;
5454

5555
prim_mubi_pkg::mubi4_t div_step_down_req;
56+
prim_mubi_pkg::mubi4_t calib_rdy;
57+
prim_mubi_pkg::mubi4_t hi_speed_sel;
5658

5759
% endif
5860
prim_mubi_pkg::mubi4_t jitter_en_o;
5961
clkmgr_pkg::clkmgr_out_t clocks_o;
6062

61-
prim_mubi_pkg::mubi4_t calib_rdy;
62-
% if ext_clk_bypass:
63-
prim_mubi_pkg::mubi4_t hi_speed_sel;
64-
% endif
65-
6663
// Internal DUT signals.
6764
// ICEBOX(lowrisc/opentitan#18379): This is a core env component (i.e. reusable entity) that
6865
// makes hierarchical references into the DUT. A better strategy would be to bind this interface
@@ -137,9 +134,6 @@ ${spc}fast: `CLKMGR_HIER.u_${src}_meas.u_meas.fast_o};
137134
always_comb ${src}_timeout_err = `CLKMGR_HIER.u_${src}_meas.timeout_err_o;
138135

139136
% endfor
140-
function automatic void update_calib_rdy(prim_mubi_pkg::mubi4_t value);
141-
calib_rdy = value;
142-
endfunction
143137

144138
function automatic void update_idle(mubi_hintables_t value);
145139
idle_i = value;
@@ -158,6 +152,10 @@ ${spc}fast: `CLKMGR_HIER.u_${src}_meas.u_meas.fast_o};
158152
endfunction
159153

160154
% if ext_clk_bypass:
155+
function automatic void update_calib_rdy(prim_mubi_pkg::mubi4_t value);
156+
calib_rdy = value;
157+
endfunction
158+
161159
function automatic void update_lc_debug_en(lc_ctrl_pkg::lc_tx_t value);
162160
lc_hw_debug_en_i = value;
163161
endfunction
@@ -200,7 +198,9 @@ ${spc}fast: `CLKMGR_HIER.u_${src}_meas.u_meas.fast_o};
200198
% endif
201199
prim_mubi_pkg::mubi4_t calib_rdy = prim_mubi_pkg::MuBi4True);
202200
`uvm_info("clkmgr_if", "In clkmgr_if init", UVM_MEDIUM)
201+
% if ext_clk_bypass:
203202
update_calib_rdy(calib_rdy);
203+
% endif
204204
update_idle(idle);
205205
% if ext_clk_bypass:
206206
update_lc_clk_byp_req(lc_clk_byp_req);
@@ -280,8 +280,8 @@ ${spc}fast: `CLKMGR_HIER.u_${src}_meas.u_meas.fast_o};
280280

281281
% endif
282282
clocking clk_cb @(posedge clk);
283-
input calib_rdy;
284283
% if ext_clk_bypass:
284+
input calib_rdy;
285285
input extclk_ctrl_csr_sel;
286286
input extclk_ctrl_csr_step_down;
287287
input lc_hw_debug_en_i;

hw/ip_templates/clkmgr/dv/env/seq_lib/clkmgr_frequency_vseq.sv.tpl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ class clkmgr_frequency_vseq extends clkmgr_base_vseq;
109109
// Wait for the result to propagate to the recov_err_code CSR.
110110
cfg.clk_rst_vif.wait_clks(CyclesForErrUpdate);
111111
endtask
112+
% if ext_clk_bypass:
112113

113114
// If clocks become uncalibrated measure_ctrl_regwen is re-enabled.
114115
task check_measure_ctrl_regwen_for_calib_rdy();
@@ -118,6 +119,7 @@ class clkmgr_frequency_vseq extends clkmgr_base_vseq;
118119
cfg.clk_rst_vif.wait_clks(20);
119120
calibration_lost_checks();
120121
endtask
122+
% endif
121123

122124
task body();
123125
logic [TL_DW-1:0] value;
@@ -159,6 +161,7 @@ class clkmgr_frequency_vseq extends clkmgr_base_vseq;
159161
logic [ClkMesrSize-1:0] expected_recov_meas_err = '0;
160162
bit expect_alert = 0;
161163
`DV_CHECK_RANDOMIZE_FATAL(this)
164+
% if ext_clk_bypass:
162165
// Update calib_rdy input: if calibration is not ready the measurements
163166
// don't happen, so we should not get faults.
164167
cfg.clkmgr_vif.update_calib_rdy(calib_rdy);
@@ -171,6 +174,7 @@ class clkmgr_frequency_vseq extends clkmgr_base_vseq;
171174
// Allow calib_rdy to generate side-effects.
172175
cfg.clk_rst_vif.wait_clks(3);
173176
if (calib_rdy == MuBi4False) calibration_lost_checks();
177+
% endif
174178
prior_alert_count = cfg.scoreboard.get_alert_count("recov_fault");
175179
if (cause_saturation) begin
176180
`uvm_info(`gfn, $sformatf(
@@ -254,8 +258,10 @@ class clkmgr_frequency_vseq extends clkmgr_base_vseq;
254258
csr_wr(.ptr(ral.recov_err_code), .value('1));
255259
cfg.aon_clk_rst_vif.wait_clks(12);
256260
end
261+
% if ext_clk_bypass:
257262
// And finally, check that unsetting calib_rdy causes measure_ctrl_regwen to be set to 1.
258263
check_measure_ctrl_regwen_for_calib_rdy();
264+
% endif
259265
endtask
260266
261267
endclass

hw/ip_templates/clkmgr/dv/sva/clkmgr_bind.sv.tpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@ module clkmgr_bind;
133133
);
134134

135135
% endfor
136+
% if ext_clk_bypass:
136137
// Calibration assertions.
137138
bind clkmgr clkmgr_lost_calib_regwen_sva_if clkmgr_lost_calib_regwen_sva_if (
138139
.clk(clk_i),
@@ -150,7 +151,6 @@ module clkmgr_bind;
150151
);
151152

152153
% endfor
153-
% if ext_clk_bypass:
154154
bind clkmgr clkmgr_sec_cm_checker_assert clkmgr_sec_cm_checker_assert (
155155
.clk_i,
156156
.rst_ni,

hw/ip_templates/clkmgr/dv/tb.sv.tpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,9 +163,9 @@ module tb;
163163
.lc_clk_byp_ack_o(clkmgr_if.lc_clk_byp_ack),
164164
.div_step_down_req_i(clkmgr_if.div_step_down_req),
165165
.hi_speed_sel_o(clkmgr_if.hi_speed_sel),
166+
.calib_rdy_i(clkmgr_if.calib_rdy),
166167

167168
% endif
168-
.calib_rdy_i(clkmgr_if.calib_rdy),
169169
.cg_en_o(),
170170

171171
.jitter_en_o(clkmgr_if.jitter_en_o),

hw/ip_templates/clkmgr/rtl/clkmgr.sv.tpl

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,11 +94,11 @@ rg_srcs = get_rg_srcs(typed_clocks)
9494
// SEC_CM: DIV.INTERSIG.MUBI
9595
input mubi4_t div_step_down_req_i,
9696
97-
% endif
9897
// clock calibration has been done.
9998
// If this is signal is 0, assume clock frequencies to be
10099
// uncalibrated.
101100
input prim_mubi_pkg::mubi4_t calib_rdy_i,
101+
% endif
102102
103103
// jittery enable to ast
104104
output mubi4_t jitter_en_o,
@@ -390,7 +390,11 @@ rg_srcs = get_rg_srcs(typed_clocks)
390390
) u_calib_rdy_sync (
391391
.clk_i,
392392
.rst_ni,
393+
% if ext_clk_bypass:
393394
.mubi_i(calib_rdy_i),
395+
% else:
396+
.mubi_i(MuBi4False),
397+
% endif
394398
.mubi_o({calib_rdy})
395399
);
396400

hw/top_darjeeling/data/autogen/top_darjeeling.gen.hjson

Lines changed: 0 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -3284,21 +3284,6 @@
32843284
top_signame: clkmgr_aon_idle
32853285
index: -1
32863286
}
3287-
{
3288-
name: calib_rdy
3289-
desc: Indicates clocks are calibrated and frequencies accurate
3290-
struct: mubi4
3291-
package: prim_mubi_pkg
3292-
type: uni
3293-
act: rcv
3294-
width: 1
3295-
default: prim_mubi_pkg::MuBi4True
3296-
inst_name: clkmgr_aon
3297-
external: true
3298-
top_signame: calib_rdy
3299-
conn_type: false
3300-
index: -1
3301-
}
33023287
{
33033288
name: tl
33043289
struct: tl
@@ -11764,7 +11749,6 @@
1176411749
spi_device.ram_cfg_spi2sys: spi_device_ram_2p_cfg_spi2sys
1176511750
pwrmgr_aon.boot_status: pwrmgr_boot_status
1176611751
clkmgr_aon.jitter_en: clk_main_jitter_en
11767-
clkmgr_aon.calib_rdy: calib_rdy
1176811752
dma.sys: dma_sys
1176911753
entropy_src.entropy_src_rng_enable: es_rng_enable
1177011754
entropy_src.entropy_src_rng_valid: es_rng_valid
@@ -23000,21 +22984,6 @@
2300022984
top_signame: clkmgr_aon_idle
2300122985
index: -1
2300222986
}
23003-
{
23004-
name: calib_rdy
23005-
desc: Indicates clocks are calibrated and frequencies accurate
23006-
struct: mubi4
23007-
package: prim_mubi_pkg
23008-
type: uni
23009-
act: rcv
23010-
width: 1
23011-
default: prim_mubi_pkg::MuBi4True
23012-
inst_name: clkmgr_aon
23013-
external: true
23014-
top_signame: calib_rdy
23015-
conn_type: false
23016-
index: -1
23017-
}
2301822987
{
2301922988
name: tl
2302022989
struct: tl
@@ -29002,18 +28971,6 @@
2900228971
index: -1
2900328972
netname: clk_main_jitter_en
2900428973
}
29005-
{
29006-
package: prim_mubi_pkg
29007-
struct: mubi4
29008-
signame: calib_rdy_i
29009-
width: 1
29010-
type: uni
29011-
default: prim_mubi_pkg::MuBi4True
29012-
direction: in
29013-
conn_type: false
29014-
index: -1
29015-
netname: calib_rdy
29016-
}
2901728974
{
2901828975
package: dma_pkg
2901928976
struct: sys_req

hw/top_darjeeling/data/top_darjeeling.hjson

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1410,7 +1410,6 @@
14101410
'spi_device.ram_cfg_spi2sys' : 'spi_device_ram_2p_cfg_spi2sys',
14111411
'pwrmgr_aon.boot_status' : 'pwrmgr_boot_status',
14121412
'clkmgr_aon.jitter_en' : 'clk_main_jitter_en',
1413-
'clkmgr_aon.calib_rdy' : 'calib_rdy',
14141413
'dma.sys' : 'dma_sys',
14151414
'entropy_src.entropy_src_rng_enable' : 'es_rng_enable',
14161415
'entropy_src.entropy_src_rng_valid' : 'es_rng_valid',

hw/top_darjeeling/ip_autogen/clkmgr/data/clkmgr.hjson

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -155,15 +155,6 @@
155155
package: "prim_mubi_pkg",
156156
width: "4"
157157
},
158-
159-
{ struct: "mubi4",
160-
desc: "Indicates clocks are calibrated and frequencies accurate",
161-
type: "uni",
162-
name: "calib_rdy",
163-
act: "rcv",
164-
package: "prim_mubi_pkg",
165-
default: "prim_mubi_pkg::MuBi4True"
166-
},
167158
],
168159

169160
countermeasures: [

hw/top_darjeeling/ip_autogen/clkmgr/doc/interfaces.md

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,14 @@ Referring to the [Comportable guideline for peripheral device functionality](htt
1111

1212
## [Inter-Module Signals](https://opentitan.org/book/doc/contributing/hw/comportability/index.html#inter-signal-handling)
1313

14-
| Port Name | Package::Struct | Type | Act | Width | Description |
15-
|:------------|:-------------------------|:--------|:------|--------:|:---------------------------------------------------------|
16-
| clocks | clkmgr_pkg::clkmgr_out | uni | req | 1 | |
17-
| cg_en | clkmgr_pkg::clkmgr_cg_en | uni | req | 1 | |
18-
| jitter_en | prim_mubi_pkg::mubi4 | uni | req | 1 | |
19-
| pwr | pwr_clk | req_rsp | rsp | 1 | |
20-
| idle | prim_mubi_pkg::mubi4 | uni | rcv | 4 | |
21-
| calib_rdy | prim_mubi_pkg::mubi4 | uni | rcv | 1 | Indicates clocks are calibrated and frequencies accurate |
22-
| tl | tlul_pkg::tl | req_rsp | rsp | 1 | |
14+
| Port Name | Package::Struct | Type | Act | Width | Description |
15+
|:------------|:-------------------------|:--------|:------|--------:|:--------------|
16+
| clocks | clkmgr_pkg::clkmgr_out | uni | req | 1 | |
17+
| cg_en | clkmgr_pkg::clkmgr_cg_en | uni | req | 1 | |
18+
| jitter_en | prim_mubi_pkg::mubi4 | uni | req | 1 | |
19+
| pwr | pwr_clk | req_rsp | rsp | 1 | |
20+
| idle | prim_mubi_pkg::mubi4 | uni | rcv | 4 | |
21+
| tl | tlul_pkg::tl | req_rsp | rsp | 1 | |
2322

2423
## Security Alerts
2524

0 commit comments

Comments
 (0)