-
Notifications
You must be signed in to change notification settings - Fork 649
Expand file tree
/
Copy pathModuleChoiceIntf.scala
More file actions
36 lines (32 loc) · 1.09 KB
/
ModuleChoiceIntf.scala
File metadata and controls
36 lines (32 loc) · 1.09 KB
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
// SPDX-License-Identifier: Apache-2.0
package chisel3.choice
import chisel3.FixedIOBaseModule
import chisel3.experimental.SourceInfo
private[chisel3] trait ModuleChoiceObjIntf { self: ModuleChoice.type =>
/** A wrapper method for Module instantiation based on option choices.
* (necessary to help Chisel track internal state).
* @see [[chisel3.choice.Group]] on how to declare the options for the alternatives.
*
* Example:
* ```
* val module = ModuleChoice(new DefaultModule)(Seq(
* Platform.FPGA -> new FPGATarget,
* Platform.ASIC -> new ASICTarget
* ))
* ```
*
* @param default the Module to instantiate if no module is specified
* @param choices the mapping from cases to module generators
*
* @return the input module `m` with Chisel metadata properly set
*
* @throws java.lang.IllegalArgumentException if the cases do not belong to the same option.
*/
def apply[T](
default: => FixedIOBaseModule[T]
)(
choices: => Seq[(Case, () => FixedIOBaseModule[T])]
)(
using SourceInfo
): T = _applyImpl(default, choices)
}