Skip to content

Commit 1f62c2a

Browse files
committed
[flash_ctrl,dv] Make some structures unpacked
For example, consider flash_mp_region_cfg_t. Structs of this type are randomised in several places (see flash_ctrl_error_mp_vseq, for example). This isn't going to do what we need if the struct is packed. For example (without further constraints), each of those seven mubi4_t elements is going to be have an invalid encoding with probability 14/16. This might be worked around. Indeed, I see that flash_ctrl_error_mp_vseq has explicit constraints for the regions, that will force the fields to take named enum values. But it's probably more sensible to default to more guessable behaviour. As well as flash_ctrl_error_mp_vseq, this commit makes the same change to: - flash_bank_mp_info_page_cfg_t (another 7 mubi values, with the same analysis). - flash_op_t (contains several enums and gets confusingly randomised in several places, which is why I noticed this in the first place) - rd_cache_t (contains an enum variable) It turns out that removing "packed" isn't quite enough. The biggest reason is that there were quite a few "solve before" lines that aren't actually allowed if you have something more interesting than a bit vector. Changes needed: - Make the fields of flash_op_t themselves be rand. This is needed because calling my_class.randomise(some_class_variable) doesn't work if some_class_variable is an unpacked struct whose fields aren't explicitly marked rand. (I'm not convinced that this part of the change should be needed, but it can't hurt, even if it's working around a VCS problem). - Rephrase lots of rules of the form "solve xyz before flash_op" to things like "solve xyz before flash_op.addr". This is because the SystemVerilog spec doesn't allow anything except an integer in as a thing to be solved before/after. I think the DV engineer just has to pretend to be a compiler. Sigh... - Remove some ordering constraints of the form "solve en_mp_regions before mp_regions". This is definitely not allowed (because mp_regions is an array of unpacked structs, so not a bit vector). I'm not completely convinced we care but, if we do, my proposal would be to randomise the items of the vector explicitly as we get to them ("late randomisation"). The code ends up simpler, I think. - Fix flat-out bogus syntax in flash_ctrl_invalid_op_vseq.sv. Antonio and I have fixed the same error in quite a few places in the past. In this case, it came from commit 9b01461 in 2022. Signed-off-by: Rupert Swarbrick <[email protected]>
1 parent e68ebfe commit 1f62c2a

File tree

45 files changed

+69
-114
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+69
-114
lines changed

hw/ip_templates/flash_ctrl/dv/env/flash_ctrl_env_pkg.sv

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ package flash_ctrl_env_pkg;
269269
NumReadTask = 2
270270
} read_task_e;
271271

272-
typedef struct packed {
272+
typedef struct {
273273
mubi4_t en; // enable this region
274274
mubi4_t read_en; // enable reads
275275
mubi4_t program_en; // enable write
@@ -281,7 +281,7 @@ package flash_ctrl_env_pkg;
281281
uint start_page; // 0:NumPages-1
282282
} flash_mp_region_cfg_t;
283283

284-
typedef struct packed {
284+
typedef struct {
285285
mubi4_t en; // enable this page
286286
mubi4_t read_en; // enable reads
287287
mubi4_t program_en; // enable write
@@ -307,7 +307,7 @@ package flash_ctrl_env_pkg;
307307
// Otf address in a bank.
308308
typedef bit [flash_ctrl_top_specific_pkg::BusAddrByteW-FlashBankWidth-1 : 0] otf_addr_t;
309309

310-
typedef struct packed {
310+
typedef struct {
311311
flash_dv_part_e partition; // data or one of the info partitions
312312
flash_erase_e erase_type; // erase page or the whole bank
313313
flash_op_e op; // read / program or erase
@@ -320,7 +320,7 @@ package flash_ctrl_env_pkg;
320320

321321
// Address combined with region
322322
// Need for error injection.
323-
typedef struct packed {
323+
typedef struct {
324324
bit bank;
325325
addr_t addr;
326326
flash_dv_part_e part;

hw/ip_templates/flash_ctrl/dv/env/seq_lib/flash_ctrl_basic_rw_vseq.sv

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class flash_ctrl_basic_rw_vseq extends flash_ctrl_base_vseq;
3232

3333
// Constraint for controller address to be in relevant range for the selected partition.
3434
constraint addr_c {
35-
solve bank before flash_op;
35+
solve bank before flash_op.addr;
3636
flash_op.addr inside {[BytesPerBank * bank : BytesPerBank * (bank + 1)]};
3737
flash_op.addr[2:0] == '0;
3838
}
@@ -52,7 +52,7 @@ class flash_ctrl_basic_rw_vseq extends flash_ctrl_base_vseq;
5252

5353
// Flash ctrl operation data queue - used for programming or reading the flash.
5454
constraint flash_op_data_c {
55-
solve flash_op before flash_op_data;
55+
solve flash_op.num_words before flash_op_data;
5656

5757
flash_op_data.size() == flash_op.num_words;
5858
}

hw/ip_templates/flash_ctrl/dv/env/seq_lib/flash_ctrl_erase_suspend_vseq.sv

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,6 @@ class flash_ctrl_erase_suspend_vseq extends flash_ctrl_base_vseq;
7171
rand flash_mp_region_cfg_t mp_regions[flash_ctrl_top_specific_pkg::MpRegions];
7272

7373
constraint mp_regions_c {
74-
solve en_mp_regions before mp_regions;
75-
7674
foreach (mp_regions[i]) {
7775
mp_regions[i].en == mubi4_bool_to_mubi(en_mp_regions[i]);
7876

hw/ip_templates/flash_ctrl/dv/env/seq_lib/flash_ctrl_error_mp_vseq.sv

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ class flash_ctrl_error_mp_vseq extends flash_ctrl_base_vseq;
4545
// Constraint for controller address to be in the relevant range for
4646
// the selected partition.
4747
constraint addr_c {
48-
solve bank before flash_op;
48+
solve bank before flash_op.partition, flash_op.addr;
4949
flash_op.addr inside {[BytesPerBank * bank : BytesPerBank * (bank + 1)]};
5050
if (flash_op.partition != FlashPartData) {
5151
flash_op.addr inside
@@ -93,7 +93,7 @@ class flash_ctrl_error_mp_vseq extends flash_ctrl_base_vseq;
9393

9494
// Flash ctrl operation data queue - used for programming or reading the flash.
9595
constraint flash_op_data_c {
96-
solve flash_op before flash_op_data;
96+
solve flash_op.num_words before flash_op_data;
9797
if (flash_op.op inside {flash_ctrl_top_specific_pkg::FlashOpRead,
9898
flash_ctrl_top_specific_pkg::FlashOpProgram}) {
9999
flash_op_data.size() == flash_op.num_words;

hw/ip_templates/flash_ctrl/dv/env/seq_lib/flash_ctrl_error_prog_type_vseq.sv

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ class flash_ctrl_error_prog_type_vseq extends flash_ctrl_base_vseq;
4141

4242
// Constraint for controller address to be in relevant range the for the selected partition.
4343
constraint addr_c {
44-
solve bank before flash_op;
44+
solve bank before flash_op.addr;
4545
flash_op.addr inside {[BytesPerBank * bank : BytesPerBank * (bank + 1)]};
4646
}
4747

hw/ip_templates/flash_ctrl/dv/env/seq_lib/flash_ctrl_fetch_code_vseq.sv

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ class flash_ctrl_fetch_code_vseq extends flash_ctrl_base_vseq;
5252

5353
// Constraint for controller address to be in relevant range for the selected partition.
5454
constraint addr_c {
55-
solve bank before flash_op;
55+
solve bank before flash_op.partition;
5656
flash_op.addr inside {[BytesPerBank * bank : BytesPerBank * (bank + 1)]};
5757
if (flash_op.partition != FlashPartData) {
5858
flash_op.addr inside
@@ -97,7 +97,7 @@ class flash_ctrl_fetch_code_vseq extends flash_ctrl_base_vseq;
9797

9898
// Flash ctrl operation data queue - used for programming or reading the flash.
9999
constraint flash_op_data_c {
100-
solve flash_op before flash_op_data;
100+
solve flash_op.op, flash_op.num_words before flash_op_data;
101101
if (flash_op.op inside {
102102
flash_ctrl_top_specific_pkg::FlashOpRead, flash_ctrl_top_specific_pkg::FlashOpProgram}) {
103103
flash_op_data.size() == flash_op.num_words;
@@ -115,8 +115,6 @@ class flash_ctrl_fetch_code_vseq extends flash_ctrl_base_vseq;
115115
rand flash_mp_region_cfg_t mp_regions[flash_ctrl_top_specific_pkg::MpRegions];
116116

117117
constraint mp_regions_c {
118-
solve en_mp_regions before mp_regions;
119-
120118
foreach (mp_regions[i]) {
121119
mp_regions[i].en == mubi4_bool_to_mubi(en_mp_regions[i]);
122120
mp_regions[i].read_en == MuBi4True;

hw/ip_templates/flash_ctrl/dv/env/seq_lib/flash_ctrl_host_dir_rd_vseq.sv

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ class flash_ctrl_host_dir_rd_vseq extends flash_ctrl_fetch_code_vseq;
2929

3030
// Constraint address to be in relevant range for the selected partition.
3131
constraint addr_c {
32-
solve bank before flash_op;
32+
solve bank before flash_op.addr;
3333
flash_op.addr inside {[BytesPerBank * bank : BytesPerBank * (bank + 1) - BytesPerBank / 2]};
3434
}
3535

@@ -45,8 +45,6 @@ class flash_ctrl_host_dir_rd_vseq extends flash_ctrl_fetch_code_vseq;
4545
data_t flash_rd_one_data;
4646

4747
constraint mp_regions_c {
48-
solve en_mp_regions before mp_regions;
49-
5048
foreach (mp_regions[i]) {
5149
mp_regions[i].en == mubi4_bool_to_mubi(en_mp_regions[i]);
5250

hw/ip_templates/flash_ctrl/dv/env/seq_lib/flash_ctrl_invalid_op_vseq.sv

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ class flash_ctrl_invalid_op_vseq extends flash_ctrl_base_vseq;
2929
bit expect_alert;
3030

3131
constraint flash_op_data_c {
32-
solve flash_op before flash_op_data;
32+
solve flash_op.num_words before flash_op_data;
3333
flash_op_data.size() == flash_op.num_words;
3434
}
3535

@@ -74,7 +74,7 @@ class flash_ctrl_invalid_op_vseq extends flash_ctrl_base_vseq;
7474
constraint mp_info_pages_c {
7575
foreach (mp_info_pages[i, j]) {
7676
mp_info_pages[i][j].size() == flash_ctrl_top_specific_pkg::InfoTypeSize[j];
77-
foreach (mp_info_pages[i][j][k]) {
77+
foreach (mp_info_pages[i, j, k]) {
7878
mp_info_pages[i][j][k].en == MuBi4True;
7979
mp_info_pages[i][j][k].read_en == MuBi4True;
8080
mp_info_pages[i][j][k].program_en == MuBi4True;

hw/ip_templates/flash_ctrl/dv/env/seq_lib/flash_ctrl_legacy_base_vseq.sv

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ class flash_ctrl_legacy_base_vseq extends flash_ctrl_otf_base_vseq;
1111

1212
constraint rand_op_c {
1313
solve fractions before rand_op.addr;
14-
solve flash_program_data before rand_op;
14+
solve flash_program_data before rand_op.partition, rand_op.addr;
1515
solve rand_op.partition before rand_op.prog_sel, rand_op.addr;
1616
solve rand_op.addr before rand_op.otf_addr;
1717
solve rand_op.addr before rand_op.num_words;

hw/ip_templates/flash_ctrl/dv/env/seq_lib/flash_ctrl_mid_op_rst_vseq.sv

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ class flash_ctrl_mid_op_rst_vseq extends flash_ctrl_base_vseq;
5050
}
5151

5252
constraint flash_op_data_c {
53-
solve flash_op before flash_op_data;
53+
solve flash_op.num_words before flash_op_data;
5454
flash_op_data.size() == flash_op.num_words;
5555
}
5656

0 commit comments

Comments
 (0)