Skip to content

Commit 4060fb8

Browse files
committed
addr_decode: Arbitrary idx_t types
1 parent ddd6931 commit 4060fb8

2 files changed

Lines changed: 18 additions & 34 deletions

File tree

src/addr_decode.sv

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,13 @@ module addr_decode #(
4343
/// The address decoder expects three fields in `rule_t`:
4444
///
4545
/// typedef struct packed {
46-
/// int unsigned idx;
47-
/// addr_t start_addr;
48-
/// addr_t end_addr;
46+
/// idx_t idx;
47+
/// addr_t start_addr;
48+
/// addr_t end_addr;
4949
/// } rule_t;
5050
///
51-
/// - `idx`: index of the rule, has to be < `NoIndices`
51+
/// - `idx`: The index to be returned for a matching rule. Usually an integer but can
52+
/// be any type of data.
5253
/// - `start_addr`: start address of the range the rule describes, value is included in range
5354
/// - `end_addr`: end address of the range the rule describes, value is NOT included in range
5455
/// if `end_addr == '0` end of address space is assumed
@@ -59,13 +60,10 @@ module addr_decode #(
5960
parameter type rule_t = logic,
6061
// Whether this is a NAPOT (base and mask) or regular range decoder
6162
parameter bit Napot = 0,
62-
/// Dependent parameter, do **not** overwite!
63-
///
64-
/// Width of the `idx_o` output port.
63+
/// The output index type `idx_t` can be specified either with the width `IdxWidth`
64+
/// or directly with the type `idx_t`. By default, it will use the maximum index
65+
/// `NoIndices` to calculate the required width.
6566
parameter int unsigned IdxWidth = cf_math_pkg::idx_width(NoIndices),
66-
/// Dependent parameter, do **not** overwite!
67-
///
68-
/// Type of the `idx_o` output port.
6967
parameter type idx_t = logic [IdxWidth-1:0]
7068
) (
7169
/// Address to decode.
@@ -92,11 +90,11 @@ module addr_decode #(
9290

9391
// wraps the dynamic configuration version of the address decoder
9492
addr_decode_dync #(
95-
.NoIndices ( NoIndices ),
9693
.NoRules ( NoRules ),
9794
.addr_t ( addr_t ),
9895
.rule_t ( rule_t ),
99-
.Napot ( Napot )
96+
.Napot ( Napot ),
97+
.idx_t ( idx_t )
10098
) i_addr_decode_dync (
10199
.addr_i,
102100
.addr_map_i,

src/addr_decode_dync.sv

Lines changed: 8 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,13 @@ module addr_decode_dync #(
4848
/// The address decoder expects three fields in `rule_t`:
4949
///
5050
/// typedef struct packed {
51-
/// int unsigned idx;
52-
/// addr_t start_addr;
53-
/// addr_t end_addr;
51+
/// idx_t idx;
52+
/// addr_t start_addr;
53+
/// addr_t end_addr;
5454
/// } rule_t;
5555
///
56-
/// - `idx`: index of the rule, has to be < `NoIndices`
56+
/// - `idx`: The index to be returned for a matching rule. Usually an integer but can
57+
/// be any type of data.
5758
/// - `start_addr`: start address of the range the rule describes, value is included in range
5859
/// - `end_addr`: end address of the range the rule describes, value is NOT included in range
5960
/// if `end_addr == '0` end of address space is assumed
@@ -64,15 +65,10 @@ module addr_decode_dync #(
6465
parameter type rule_t = logic,
6566
/// Whether this is a NAPOT (base and mask) or regular range decoder
6667
parameter bit Napot = 0,
67-
/// Whether to assert maximum indices.
68-
parameter bit AssertIndices = 1'b1,
69-
/// Dependent parameter, do **not** overwite!
70-
///
71-
/// Width of the `idx_o` output port.
68+
/// The output index type `idx_t` can be specified either with the width `IdxWidth`
69+
/// or directly with the type `idx_t`. By default, it will use the maximum index
70+
/// `NoIndices` to calculate the required width.
7271
parameter int unsigned IdxWidth = cf_math_pkg::idx_width(NoIndices),
73-
/// Dependent parameter, do **not** overwite!
74-
///
75-
/// Type of the `idx_o` output port.
7672
parameter type idx_t = logic [IdxWidth-1:0]
7773
) (
7874
/// Address to decode.
@@ -132,7 +128,6 @@ module addr_decode_dync #(
132128
$sformatf("Input address has %d bits and address map has %d bits.",
133129
$bits(addr_i), $bits(addr_map_i[0].start_addr)))
134130
`ASSUME_I(norules_0, NoRules > 0, $sformatf("At least one rule needed"))
135-
`ASSUME_I(noindices_0, NoIndices > 0 || !AssertIndices, $sformatf("At least one index needed"))
136131
end
137132

138133
`ASSERT_FINAL(more_than_1_bit_set, $onehot0(matched_rules) || config_ongoing_i,
@@ -157,15 +152,6 @@ module addr_decode_dync #(
157152
Rule> IDX: %h START: %h END: %h\n\
158153
#####################################################",
159154
i ,addr_map_i[i].idx, addr_map_i[i].start_addr, addr_map_i[i].end_addr))
160-
// check the SLV ids
161-
`ASSUME_I(check_idx, addr_map_i[i].idx < NoIndices|| !AssertIndices,
162-
$sformatf("This rule has a IDX that is not allowed!!!\n\
163-
Violating rule %d.\n\
164-
Rule> IDX: %h START: %h END: %h\n\
165-
Rule> MAX_IDX: %h\n\
166-
#####################################################",
167-
i, addr_map_i[i].idx, addr_map_i[i].start_addr, addr_map_i[i].end_addr,
168-
(NoIndices-1)))
169155
for (int unsigned j = i + 1; j < NoRules; j++) begin
170156
// overlap check
171157
`ASSUME_I(check_overlap, Napot ||

0 commit comments

Comments
 (0)