Skip to content

Commit 03c1191

Browse files
author
Rafal Kapuscik
committed
Add separate-compilation test
Signed-off-by: Rafal Kapuscik <[email protected]>
1 parent f7857fc commit 03c1191

File tree

5 files changed

+91
-1
lines changed

5 files changed

+91
-1
lines changed

systemverilog-plugin/tests/Makefile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,12 @@
1414
#
1515
# SPDX-License-Identifier: Apache-2.0
1616

17-
TESTS = counter break_continue
17+
TESTS = counter \
18+
break_continue \
19+
separate-compilation
1820

1921
include $(shell pwd)/../../Makefile_test.common
2022

2123
counter_verify = true
2224
break_continue_verify = $(call diff_test,break_continue,out)
25+
separate-compilation_verify = true
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// Copyright 2020-2022 F4PGA Authors
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
//
15+
// SPDX-License-Identifier: Apache-2.0
16+
module BUF (
17+
input I,
18+
output O
19+
);
20+
assign O = I;
21+
endmodule;
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// Copyright 2020-2022 F4PGA Authors
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
//
15+
// SPDX-License-Identifier: Apache-2.0
16+
package pkg;
17+
parameter BITS = 4;
18+
parameter LOG2DELAY = 22;
19+
endpackage
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
yosys -import
2+
if { [info procs read_uhdm] == {} } { plugin -i systemverilog }
3+
yosys -import ;# ingest plugin commands
4+
5+
set TMP_DIR /tmp
6+
if { [info exists ::env(TMPDIR) ] } {
7+
set TMP_DIR $::env(TMPDIR)
8+
}
9+
10+
# Testing simple round-trip
11+
read_systemverilog -odir $TMP_DIR/separate-compilation-test -defer $::env(DESIGN_TOP)-pkg.sv
12+
read_systemverilog -odir $TMP_DIR/separate-compilation-test -defer $::env(DESIGN_TOP)-buf.sv
13+
read_systemverilog -odir $TMP_DIR/separate-compilation-test -defer $::env(DESIGN_TOP).v
14+
read_systemverilog -odir $TMP_DIR/separate-compilation-test -link
15+
hierarchy
16+
write_verilog
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
// Copyright 2020-2022 F4PGA Authors
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
//
15+
// SPDX-License-Identifier: Apache-2.0
16+
module top (
17+
input clk,
18+
output [3:0] led
19+
);
20+
21+
wire bufg;
22+
BUF bufgctrl (
23+
.I(clk),
24+
.O(bufg)
25+
);
26+
reg [pkg::BITS + pkg::LOG2DELAY-1 : 0] counter = 0;
27+
always @(posedge bufg) begin
28+
counter <= counter + 1;
29+
end
30+
assign led[3:0] = counter >> pkg::LOG2DELAY;
31+
endmodule

0 commit comments

Comments
 (0)