Skip to content

Commit 5e8f5b8

Browse files
authoredMay 4, 2024
Adds a test project for the verilator cmake bindings (#4)
1 parent deb06f2 commit 5e8f5b8

File tree

5 files changed

+82
-0
lines changed

5 files changed

+82
-0
lines changed
 

‎.github/workflows/tests.yml

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
name: Tests
2+
3+
on:
4+
push:
5+
branches: [ "main", "release/**" ]
6+
pull_request:
7+
branches: [ "main", "release/**" ]
8+
9+
jobs:
10+
tests:
11+
runs-on: self-hosted
12+
13+
steps:
14+
- uses: actions/checkout@v4.1.1
15+
16+
- name: Configure CMake
17+
run: cmake -S ${{github.workspace}}/tests -B ${{github.workspace}}/build -GNinja
18+
19+
- name: Run tests
20+
run: ninja -C ${{github.workspace}}/build tests

‎.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
build

‎tests/CMakeLists.txt

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
cmake_minimum_required(VERSION 3.12)
2+
3+
project(verilator-cmake-test VERSION 1.0)
4+
5+
include(${CMAKE_CURRENT_LIST_DIR}/../cmake/verilator-config.cmake)
6+
7+
add_executable(tests src/top.cpp)
8+
verilate(tests
9+
PREFIX Vtop
10+
SOURCES src/top.sv
11+
TRACE
12+
PUBLIC)

‎tests/src/top.cpp

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
/* __ _
2+
* ________/ / ___ _(_)__ ___
3+
* / __/ __/ _ \/ _ `/ / _ \/ -_)
4+
* \__/\__/_//_/\_,_/_/_//_/\__/
5+
*
6+
* Copyright (C) Clément Chaine
7+
* This file is part of verilator-cmake <https://github.com/ecap5/verilator-cmake>
8+
*
9+
* verilator-cmake is free software: you can redistribute it and/or modify
10+
* it under the terms of the GNU General Public License as published by
11+
* the Free Software Foundation, either version 3 of the License, or
12+
* (at your option) any later version.
13+
*
14+
* verilator-cmake is distributed in the hope that it will be useful,
15+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
16+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17+
* GNU General Public License for more details.
18+
*
19+
* You should have received a copy of the GNU General Public License
20+
* along with verilator-cmake. If not, see <http://www.gnu.org/licenses/>.
21+
*/
22+
23+
#include <stdio.h>
24+
#include <stdlib.h>
25+
#include <time.h>
26+
#include <verilated.h>
27+
#include <verilated_vcd_c.h>
28+
#include <svdpi.h>
29+
30+
#include "Vtop.h"
31+
32+
int main(int argc, char ** argv, char ** env) {
33+
srand(time(NULL));
34+
Verilated::traceEverOn(true);
35+
36+
/************************************************************/
37+
38+
/************************************************************/
39+
40+
exit(EXIT_SUCCESS);
41+
}

‎tests/src/top.sv

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
module top (
2+
input logic clk_i,
3+
output logic clk_o
4+
);
5+
6+
assign clk_o = clk_i;
7+
8+
endmodule

0 commit comments

Comments
 (0)