SILICON
Loading...
Searching...
No Matches
fstlib.cpp
Go to the documentation of this file.
1/*
2 Copyright (c) 2026. Giulio Cocconi
3
4 This program is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation, either version 3 of the License, or
7 (at your option) any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18#include "tests.hpp"
19#include <fstapi.h>
20
21using namespace SILICON::core;
22
23TEST(FstLibTest, IO)
24{
25 fstWriterContext* writer = fstWriterCreate("out.fst", 1);
26 ASSERT_TRUE(writer);
27
28 const fstHandle var =
29 fstWriterCreateVar(writer, FST_VT_VCD_WIRE, FST_VD_IMPLICIT, 1, "var", 0);
30
31 fstWriterEmitTimeChange(writer, 0);
32 fstWriterEmitValueChange(writer, var, "0");
33 fstWriterEmitTimeChange(writer, 1);
34 fstWriterEmitValueChange(writer, var, "1");
35 fstWriterEmitTimeChange(writer, 2);
36
37 fstWriterClose(writer);
38
39 // Read generated FST file
40
41 fstReaderContext* reader = fstReaderOpen("out.fst");
42 ASSERT_TRUE(reader);
43
44 EXPECT_EQ(fstReaderGetStartTime(reader), 0);
45 EXPECT_EQ(fstReaderGetEndTime(reader), 2);
46 EXPECT_EQ(fstReaderGetVarCount(reader), 1);
47 EXPECT_EQ(fstReaderGetScopeCount(reader), 0);
48 EXPECT_EQ(fstReaderGetAliasCount(reader), 0);
49
50 fstHier* iter = fstReaderIterateHier(reader);
51 ASSERT_TRUE(iter);
52
53 EXPECT_EQ(iter->htyp, FST_HT_VAR);
54 EXPECT_STREQ(iter->u.var.name, "var");
55 EXPECT_EQ(iter->u.var.length, 1);
56
57 iter = fstReaderIterateHier(reader);
58 EXPECT_FALSE(iter);
59 fstReaderClose(reader);
60}
TEST(FstLibTest, IO)
Definition fstlib.cpp:23