Skip to content

Commit 6b51f83

Browse files
wkkunakgugala
authored andcommitted
tools/i3c_config: Handle booleans in configs
Define if set to 'True'. Signed-off-by: Wiktoria Kuna <[email protected]>
1 parent 75c54b5 commit 6b51f83

File tree

3 files changed

+30
-24
lines changed

3 files changed

+30
-24
lines changed

src/i3c.sv

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,11 @@ module i3c
4444
parameter int unsigned HciCmdFifoDepth = `CMD_FIFO_DEPTH,
4545
parameter int unsigned HciRxFifoDepth = `RX_FIFO_DEPTH,
4646
parameter int unsigned HciTxFifoDepth = `TX_FIFO_DEPTH,
47-
parameter int unsigned HciIbiFifoDepth = (`IBI_FIFO_EXT_SIZE)
48-
? (8 * `IBI_FIFO_DEPTH)
49-
: (`IBI_FIFO_DEPTH),
47+
`ifdef IBI_FIFO_EXT_SIZE
48+
parameter int unsigned HciIbiFifoDepth = 8 * `IBI_FIFO_DEPTH,
49+
`else
50+
parameter int unsigned HciIbiFifoDepth = `IBI_FIFO_DEPTH,
51+
`endif
5052

5153
localparam int unsigned HciRespFifoDepthWidth = $clog2(HciRespFifoDepth + 1),
5254
localparam int unsigned HciCmdFifoDepthWidth = $clog2(HciCmdFifoDepth + 1),
@@ -70,9 +72,11 @@ module i3c
7072
parameter int unsigned TtiTxDescFifoDepth = `CMD_FIFO_DEPTH,
7173
parameter int unsigned TtiRxFifoDepth = `RX_FIFO_DEPTH,
7274
parameter int unsigned TtiTxFifoDepth = `TX_FIFO_DEPTH,
73-
parameter int unsigned TtiIbiFifoDepth = (`IBI_FIFO_EXT_SIZE)
74-
? (8 * `IBI_FIFO_DEPTH)
75-
: (`IBI_FIFO_DEPTH),
75+
`ifdef IBI_FIFO_EXT_SIZE
76+
parameter int unsigned TtiIbiFifoDepth = 8 * `IBI_FIFO_DEPTH,
77+
`else
78+
parameter int unsigned TtiIbiFifoDepth = `IBI_FIFO_DEPTH,
79+
`endif
7680
localparam int unsigned TtiTxDescFifoDepthWidth = $clog2(TtiTxDescFifoDepth + 1),
7781
localparam int unsigned TtiRxDescFifoDepthWidth = $clog2(TtiRxDescFifoDepth + 1),
7882
localparam int unsigned TtiTxFifoDepthWidth = $clog2(TtiTxFifoDepth + 1),

src/i3c_defines.svh

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,18 @@
55
`ifndef I3C_CONFIG
66
`define I3C_CONFIG
77

8-
`define CMD_FIFO_DEPTH 64
9-
`define RX_FIFO_DEPTH 64
10-
`define TX_FIFO_DEPTH 64
11-
`define RESP_FIFO_DEPTH 64
12-
`define IBI_FIFO_DEPTH 64
13-
`define IBI_FIFO_EXT_SIZE 0
14-
`define DAT_DEPTH 128
15-
`define DCT_DEPTH 128
16-
`define I3C_USE_AXI 1
17-
`define AXI_ADDR_WIDTH 12
18-
`define AXI_DATA_WIDTH 32
19-
`define AXI_USER_WIDTH 32
20-
`define AXI_ID_WIDTH 8
21-
`define DISABLE_INPUT_FF 1
8+
`define CMD_FIFO_DEPTH 64
9+
`define RX_FIFO_DEPTH 64
10+
`define TX_FIFO_DEPTH 64
11+
`define RESP_FIFO_DEPTH 64
12+
`define IBI_FIFO_DEPTH 64
13+
`define DAT_DEPTH 128
14+
`define DCT_DEPTH 128
15+
`define I3C_USE_AXI 1
16+
`define AXI_ADDR_WIDTH 12
17+
`define AXI_DATA_WIDTH 32
18+
`define AXI_USER_WIDTH 32
19+
`define AXI_ID_WIDTH 8
20+
`define DISABLE_INPUT_FF 1
2221

2322
`endif // I3C_CONFIG

tools/i3c_config/common.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,17 +82,20 @@ def __init__(self, cfg: I3CGenericConfig) -> None:
8282
# PascalCase -> UPPER_SNAKE_CASE
8383
new_name = self._format_name(name).replace("FRONTEND_BUS", bus)
8484

85-
# Resolve the parameter type (i.e. booleans)
86-
self._defines[new_name] = self._py_to_sv_type(value, name)
85+
# Resolve the parameter type
86+
value = self._py_to_sv_type(value, name)
87+
# Skips boolean parameters that are set to 'False'
88+
if value is not None:
89+
self._defines[new_name] = value
8790

8891
# Change camel case name format to upper snake case
8992
def _format_name(self, name: str) -> str:
9093
return re.sub(r"(?<!^)(?=[A-Z])", "_", name).upper()
9194

9295
def _py_to_sv_type(self, element: any, name: str) -> int | str:
9396
match element:
94-
case bool(): # Bool is not supported, use 0 or 1
95-
return int(element)
97+
case bool():
98+
return 1 if element else None
9699
case str(): # Ensure the resulting definition contains ""
97100
return f'"{element}"'
98101
case list(): # Run recursively on each element & return a string

0 commit comments

Comments
 (0)