Skip to content

Commit 2490c10

Browse files
committed
Add a test case
1 parent 97c68a7 commit 2490c10

File tree

2 files changed

+50
-2
lines changed

2 files changed

+50
-2
lines changed

lib/Conversion/FIRRTLToHW/LowerToHW.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1092,8 +1092,8 @@ void FIRRTLModuleLowering::emitInstanceChoiceIncludeFile(
10921092
SmallString<256> headerComment;
10931093
llvm::raw_svector_ostream os(headerComment);
10941094
os << "// Specialization file for public module: "
1095-
<< publicModuleName.getValue() << "\n";
1096-
os << "// Option: " << optionName.getValue()
1095+
<< publicModuleName.getValue() << "\n"
1096+
<< "// Option: " << optionName.getValue()
10971097
<< ", Case: " << caseName.getValue() << "\n";
10981098
emit::VerbatimOp::create(builder, circuit.getLoc(),
10991099
builder.getStringAttr(headerComment));

test/firtool/instance-choice.fir

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
; RUN: firtool %s | FileCheck %s
2+
3+
FIRRTL version 5.1.0
4+
circuit top:
5+
option Platform:
6+
FPGA
7+
8+
module DefaultTarget:
9+
output result: UInt<32>
10+
11+
connect result, UInt<32>(0)
12+
13+
module FPGATarget:
14+
output result: UInt<32>
15+
16+
connect result, UInt<32>(20)
17+
18+
public module top:
19+
input clk: Clock
20+
input rst: UInt<1>
21+
; CHECK: wire [31:0] proc_result;
22+
; CHECK-NEXT: `ifdef [[OPTION_NAME:.+]]
23+
; CHECK-NEXT: FPGATarget proc_FPGA (
24+
; CHECK-NEXT: .result (proc_result)
25+
; CHECK-NEXT: );
26+
; CHECK-NEXT: `else
27+
; CHECK-NEXT: DefaultTarget proc_default (
28+
; CHECK-NEXT: .result (proc_result)
29+
; CHECK-NEXT: );
30+
; CHECK-NEXT: `ifndef [[TARGET_NAME:.+]]
31+
; CHECK-NEXT: `define [[TARGET_NAME]] proc_default
32+
; CHECK-NEXT: `endif
33+
; CHECK-NEXT: `endif
34+
instchoice proc of DefaultTarget, Platform:
35+
FPGA => FPGATarget
36+
37+
printf(clk, UInt<1>(1), "resul: %d\n", proc.result)
38+
; CHECK-LABEL: // ----- 8< ----- FILE "targets_top_Platform_FPGA.svh" ----- 8< -----
39+
; CHECK: `ifndef [[OPTION_NAME]]
40+
; CHECK-NEXT: `define [[OPTION_NAME]]
41+
; CHECK-NEXT: `endif
42+
; CHECK-NEXT: `ifdef [[TARGET_NAME]]
43+
; CHECK-NEXT: `_ERROR_[[TARGET_NAME]]_must_not_be_set
44+
; CHECK-NEXT: `else
45+
; CHECK-NEXT: `define [[TARGET_NAME]] proc_FPGA
46+
; CHECK-NEXT: `endif
47+
48+

0 commit comments

Comments
 (0)