Коммит 2449c24b создал по автору Чернявских Илья Игоревич's avatar Чернявских Илья Игоревич
Просмотр файлов

Слияние ветки 'add_sequential' с 'main'

Add sequential vertices support

Посмотреть запрос на слияние !19
владельцы 7e87943b 2057a2aa
HeaderFilterRegex: ((include|src|test)/*)
ExcludeHeaderFilterRegex: (*/build/*)
Checks: >
-*,
llvm-*,
......
......@@ -26,6 +26,11 @@ set(SOURCES
${CMAKE_CURRENT_SOURCE_DIR}/src/OrientedGraph.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/GraphUtils.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/DefaultAuxiliaryMethods.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/GraphVertexSequential.cpp
)
set(LIBS
${CMAKE_CURRENT_SOURCE_DIR}/lib/fmt/format.cc
)
set(PUBLIC_HEADERS
......@@ -44,15 +49,18 @@ if (ENABLE_LOGGING)
endif()
if(BUILD_SHARED_LIBS)
add_library(${PROJECT_NAME} SHARED ${SOURCES})
add_library(${PROJECT_NAME} SHARED ${SOURCES} ${LIBS})
else()
add_library(${PROJECT_NAME} STATIC ${SOURCES})
add_library(${PROJECT_NAME} STATIC ${SOURCES} ${LIBS})
endif()
add_library(
CircuitGenGraph::CircuitGenGraph ALIAS
${PROJECT_NAME})
include_directories(lib)
link_directories(lib)
if(ENABLE_LOGGING)
add_library(
easylogging++ STATIC
......@@ -61,6 +69,15 @@ if(ENABLE_LOGGING)
)
endif()
# DOES NOT WORK IN FetchContent
# add_library(
# fmt STATIC
# ${CMAKE_CURRENT_SOURCE_DIR}/lib/fmt/core.h
# ${CMAKE_CURRENT_SOURCE_DIR}/lib/fmt/format-inl.h
# ${CMAKE_CURRENT_SOURCE_DIR}/lib/fmt/format.h
# ${CMAKE_CURRENT_SOURCE_DIR}/lib/fmt/format.cc
# )
target_compile_features(${PROJECT_NAME} PUBLIC cxx_std_17)
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -g")
......
#!/bin/bash
cmake --preset=dev
cmake --build --preset=dev -t format-fix -j $(nproc)
# cmake --build --preset=dev -t format-fix -j $(nproc)
cmake --build --preset=dev -j $(nproc)
ctest --preset=dev -j $(nproc)
\ Нет новой строки в конце файла
......@@ -102,7 +102,7 @@ target_link_libraries(
#include <DefaultAuxilaryMethods.hpp>
```
Где они все находятся в namespace `AuxMethods`. Также есть экспортный хедер:
Где они все находятся в namespace `AuxMethodsGraph`. Также есть экспортный хедер:
```
#include <CircuitGenGraph/GraphUtils.hpp>
......
......@@ -152,10 +152,10 @@ int main()
```
- 5: Для описание классов, пространств имён указывается тег class, namespace
```hpp
/// namespace AuxMethods
/// namespace AuxMethodsGraph
/// <описание пространства имён>
namespace AuxMethods
namespace AuxMethodsGraph
{
...
}
......
......@@ -7,12 +7,14 @@
#include <CircuitGenGraph/GraphUtils.hpp>
#include "../../lib/fmt/core.h"
/// @file AuxiliaryMethods.hpp
/// TODO: ToEnum
/// TODO: if need LineReader
/// TODO: if need CopyDirectory
/// namespace AuxMethods It was created to organize a set of auxiliary
/// namespace AuxMethodsGraph It was created to organize a set of auxiliary
/// functions and methods that can be used in various parts of a
/// software project
/// Functions: Random number generation, Reading files,
......@@ -21,7 +23,7 @@
/// TO DO: list the other functions
/// </summary>
namespace AuxMethods {
namespace CG_Graph::AuxMethodsGraph {
std::string replacer(const std::string &i_s, const std::string &i_r);
std::string dotReturnToString(DotReturn dot);
......@@ -45,14 +47,10 @@ struct TuplePrinter<Tuple, 1> {
}
};
template<class... Args>
std::string format(const std::string &fmt, Args &&...args) {
std::stringstream ss;
const auto t = std::make_tuple(std::forward<Args>(args)...);
TuplePrinter<decltype(t), sizeof...(Args)>::print(fmt, ss, t);
return ss.str();
template<typename... Args>
auto format(Args &&...args)
-> decltype(fmt::format(std::forward<Args>(args)...)) {
return fmt::format(std::forward<Args>(args)...);
}
} // namespace AuxMethods
} // namespace CG_Graph::AuxMethodsGraph
......@@ -4,28 +4,28 @@
#include <CircuitGenGraph/GraphUtils.hpp>
namespace ClassicGraphML {
namespace CG_Graph::ClassicGraphML {
const char *mainTemplate = R"(<?xml version="1.0" encoding="UTF-8"?>
<graphml xmlns="http://graphml.graphdrawing.org/xmlns" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://graphml.graphdrawing.org/xmlns http://graphml.graphdrawing.org/xmlns/1.0/graphml.xsd">
<key id="t" for="node" attr.name="type" attr.type="string"/>
%
{}
</graphml>
)";
const char *rawGraphTemplate = R"(% <graph id="%" edgedefault="directed">
%% </graph>)";
const char *rawGraphTemplate = R"({} <graph id="{}" edgedefault="directed">
{}{} </graph>)";
const char *rawNodeTemplate = R"(% <node id="%">
% <data key="t">%</data>%
% </node>
const char *rawNodeTemplate = R"({} <node id="{}">
{} <data key="t">{}</data>{}
{} </node>
)";
const char *rawEdgeTemplate = R"(% <edge source="%" target="%"/>
const char *rawEdgeTemplate = R"({} <edge source="{}" target="{}"/>
)";
} // namespace ClassicGraphML
} // namespace CG_Graph::ClassicGraphML
namespace OpenABCD {
namespace CG_Graph::OpenABCD {
const char *mainTemplate = R"(<?xml version='1.0' encoding='utf-8'?>
<graphml xmlns="http://graphml.graphdrawing.org/xmlns" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://graphml.graphdrawing.org/xmlns http://graphml.graphdrawing.org/xmlns/1.0/graphml.xsd">
<key id="d3" for="edge" attr.name="edge_type" attr.type="long" />
......@@ -33,46 +33,50 @@ const char *mainTemplate = R"(<?xml version='1.0' encoding='utf-8'?>
<key id="d1" for="node" attr.name="node_type" attr.type="long" />
<key id="d0" for="node" attr.name="node_id" attr.type="string" />
<graph edgedefault="directed">
% </graph>
{} </graph>
</graphml>
)";
const char *nodeTemplate = R"( <node id="%">
<data key="d0">%</data>
<data key="d1">%</data>
<data key="d2">%</data>
const char *nodeTemplate = R"( <node id="{}">
<data key="d0">{}</data>
<data key="d1">{}</data>
<data key="d2">{}</data>
</node>
)";
const char *edgeTemplate = R"( <edge source="%" target="%">
<data key="d3">%</data>
const char *edgeTemplate = R"( <edge source="{}" target="{}">
<data key="d3">{}</data>
</edge>
)";
} // namespace OpenABCD
} // namespace CG_Graph::OpenABCD
namespace PseudoABCD {
namespace CG_Graph::PseudoABCD {
const char *mainTemplate = R"(<?xml version='1.0' encoding='utf-8'?>
<graphml xmlns="http://graphml.graphdrawing.org/xmlns" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://graphml.graphdrawing.org/xmlns http://graphml.graphdrawing.org/xmlns/1.0/graphml.xsd">
<key id="d1" for="node" attr.name="node_type" attr.type="long" />
<key id="d0" for="node" attr.name="node_id" attr.type="string" />
<graph edgedefault="directed">
% </graph>
{} </graph>
</graphml>
)";
const char *nodeTemplate = R"( <node id="%">
<data key="d0">%</data>
<data key="d1">%</data>
const char *nodeTemplate = R"( <node id="{}">
<data key="d0">{}</data>
<data key="d1">{}</data>
</node>
)";
const char *edgeTemplate = R"( <edge source="%" target="%"/>
const char *edgeTemplate = R"( <edge source="{}" target="{}"/>
)";
} // namespace PseudoABCD
} // namespace CG_Graph::PseudoABCD
namespace CG_Graph {
std::map<Gates, std::string> gateToABCDType = {
{Gates::GateAnd, "2"}, {Gates::GateNand, "10"},
{Gates::GateOr, "13"}, {Gates::GateNor, "14"},
{Gates::GateNot, "12"}, {Gates::GateBuf, "11"},
{Gates::GateXor, "15"}, {Gates::GateXnor, "16"},
{Gates::GateDefault, "ERROR"}};
\ Нет новой строки в конце файла
{Gates::GateDefault, "ERROR"}};
} // namespace CG_Graph
......@@ -6,6 +6,8 @@
#include <string>
#include <string_view>
namespace CG_Graph {
constexpr int DEFAULT_BUF = 114688;
constexpr int CHUNK_SIZE = 14336;
......@@ -41,7 +43,7 @@ struct MultiLinearAllocator {
MultiLinearAllocator(const MultiLinearAllocator &other) = delete;
~MultiLinearAllocator() {
for (auto block: blocks) {
for (auto *block: blocks) {
delete[] block;
}
}
......@@ -156,3 +158,5 @@ private:
/// @brief set with all vertices names
std::pmr::set<std::string> d_strings;
};
} // namespace CG_Graph
#pragma once
#include <array>
#include <algorithm>
#include <array>
#include <map>
#include <memory>
#include <mutex>
......@@ -11,20 +11,65 @@
/// @file GraphUtils.hpp
/// @brief VertexTypes
/// Enumeration of vertex types
namespace CG_Graph {
#ifndef DotReturn
#define DotReturn \
std::vector<std::pair<DotTypes, std::map<std::string, std::string>>>
#endif
/// @brief VertexTypes
/// Enumeration of vertex types
enum VertexTypes : uint8_t {
input = 0, /// input vertex
output = 4, /// output vertex
output = 6, /// output vertex
constant = 1, /// constant vertex
gate = 2, /// vertex representing a logical element
subGraph = 3 /// subgraph that makes up the vertex
subGraph = 3, /// subgraph that makes up the vertex
dataBus = 4,
seuqential = 5
};
// CGG - CiruitGenGraph
#define CGG_FF_TYPE(S, V) S = V, n##S = NEGEDGE | V
/// @brief Types of all sequential cells being supported
enum SequentialTypes : uint8_t {
EN = 1 << 0,
latch = EN,
SET = 1 << 1,
CLR = 1 << 2,
RST = 1 << 3,
ASYNC = 1 << 5,
NEGEDGE = 1 << 6,
// DEFAULT TYPES
CGG_FF_TYPE(ff, 1 << 4),
// ASYNC
CGG_FF_TYPE(affr, ASYNC | ff | RST),
CGG_FF_TYPE(affre, ASYNC | EN | RST),
// LATCHES
latchr = latch | RST,
latchc = latch | CLR,
latchs = latch | SET,
// COMBINED
latchrs = latch | RST | SET,
latchcs = latch | CLR | SET,
// FF
CGG_FF_TYPE(ffe, ff | EN),
CGG_FF_TYPE(ffr, ff | RST),
CGG_FF_TYPE(ffc, ff | CLR),
CGG_FF_TYPE(ffs, ff | SET),
// COMBINED
CGG_FF_TYPE(ffre, ff | EN | RST),
CGG_FF_TYPE(ffce, ff | EN | CLR),
CGG_FF_TYPE(ffse, ff | EN | SET),
CGG_FF_TYPE(ffrse, ff | EN | RST | SET),
CGG_FF_TYPE(ffcse, ff | EN | CLR | SET)
};
/// @brief Gates
......@@ -293,3 +338,5 @@ static std::pair<Gates, std::string_view> gateToString[] = {
static constexpr size_t d_hierarchySize = 11;
} // namespace GraphUtils
} // namespace CG_Graph
......@@ -28,6 +28,8 @@
/// a string of type std::string that identifies a vertex
/// */
namespace CG_Graph {
class GraphVertexInput : public GraphVertexBase {
public:
/// @brief GraphVertexInput
......@@ -304,3 +306,92 @@ private:
// Определяем тип вершины: подграф, вход, выход, константа или одна из базовых
// логических операций.
};
class GraphVertexSequential : public GraphVertexBase {
public:
// clang-format off
GraphVertexSequential(SequentialTypes i_type,
VertexPtr i_clk,
VertexPtr i_data,
GraphPtr i_baseGraph,
std::string_view i_name);
GraphVertexSequential(SequentialTypes i_type,
VertexPtr i_clk,
VertexPtr i_data,
VertexPtr wire,
GraphPtr i_baseGraph,
std::string_view i_name);
GraphVertexSequential(SequentialTypes i_type,
VertexPtr i_clk,
VertexPtr i_data,
VertexPtr wire1,
VertexPtr wire2,
GraphPtr i_baseGraph,
std::string_view i_name);
GraphVertexSequential(SequentialTypes i_type,
VertexPtr i_clk,
VertexPtr i_data,
VertexPtr wire1,
VertexPtr wire2,
VertexPtr wire3,
GraphPtr i_baseGraph,
std::string_view i_name);
// clang-format on
~GraphVertexSequential() override{};
/// @brief calculateHash
/// Calculates the hash value of the vertex
/// @param i_recalculate Flag indicating whether to i_recalculate the hash
/// value (default false)
/// @throws None.
/// @code
/// TO DO:
/// @endcode
/// @return The calculated hash value as a string
size_t calculateHash(bool i_recalculate = false) override;
/// @brief toVerilog
/// generates a string in Verilog format for the current vertex,
/// representing the valve according to its type and input connections.
/// If a vertex has no input connections, an empty string is returned.
/// If any input connection is invalid, an exception is thrown.
/// @return A Verilog format string for the current vertex
/// @throws std::invalid_argument if any input connection is invalid
std::string toVerilog() const override;
DotReturn toDOT() override;
char updateValue() override { return '0'; };
bool isFF() const;
bool isAsync() const;
bool isNegedge() const;
SequentialTypes getSeqType() const;
VertexPtr getClk() const;
VertexPtr getData() const;
VertexPtr getEn() const;
VertexPtr getRst() const;
VertexPtr getSet() const;
private:
void setSignalByType(VertexPtr i_wire, SequentialTypes i_type,
unsigned &factType);
void formatAlwaysBegin(std::string &verilog) const;
private:
SequentialTypes d_seqType;
VertexPtr d_clk;
VertexPtr d_data;
VertexPtr d_en;
VertexPtr d_rst;
VertexPtr d_set;
};
} // namespace CG_Graph
......@@ -7,21 +7,25 @@
#include <string>
#include <vector>
#include <CircuitGenGraph/GraphUtils.hpp>
#include <CircuitGenGraph/enums.hpp>
#include <CircuitGenGraph/GraphMemory.hpp>
#include <CircuitGenGraph/GraphUtils.hpp>
#include <CircuitGenGraph/OrientedGraph.hpp>
#ifdef LOGFLAG
#include "easyloggingpp/easylogging++.h"
#endif
class OrientedGraph;
#define GraphPtr std::shared_ptr<CG_Graph::OrientedGraph>
#define GraphPtrWeak std::weak_ptr<CG_Graph::OrientedGraph>
#define GraphPtr std::shared_ptr<OrientedGraph>
#define GraphPtrWeak std::weak_ptr<OrientedGraph>
#define VertexPtr CG_Graph::GraphVertexBase *
#define VertexPtr GraphVertexBase *
namespace CG_Graph {
class OrientedGraph;
class GraphVertexSequential;
/// @brief VertexUtils
/// Namespace containing utility functions for working with vertices
......@@ -71,6 +75,9 @@ std::string vertexTypeToVerilog(VertexTypes i_type);
/// std::cout << "Comment for input vertex type: " << comment << std::endl;
/// @endcode
std::string vertexTypeToComment(VertexTypes i_type);
std::string getSequentialComment(const GraphVertexSequential *i_seq);
} // namespace VertexUtils
/// class GraphVertexBase
......@@ -496,3 +503,5 @@ private:
};
std::ostream &operator<<(std::ostream &stream, const GraphVertexBase &vertex);
} // namespace CG_Graph
......@@ -12,9 +12,10 @@
#include <unordered_set>
#include <vector>
#include <CircuitGenGraph/GraphUtils.hpp>
#include <CircuitGenGraph/enums.hpp>
#include <CircuitGenGraph/GraphMemory.hpp>
#include <CircuitGenGraph/GraphUtils.hpp>
#include <CircuitGenGraph/GraphVertexBase.hpp>
#ifdef LOGFLAG
......@@ -23,12 +24,14 @@
// TODO: Добавить проверку на имена файлов при доблении новых вершин
class GraphVertexBase; // Проблема циклического определения
#define GraphPtr std::shared_ptr<CG_Graph::OrientedGraph>
#define GraphPtrWeak std::weak_ptr<CG_Graph::OrientedGraph>
#define GraphPtr std::shared_ptr<OrientedGraph>
#define GraphPtrWeak std::weak_ptr<OrientedGraph>
#define VertexPtr CG_Graph::GraphVertexBase *
#define VertexPtr GraphVertexBase *
namespace CG_Graph {
class GraphVertexBase;
/// class OrientedGraph
///
......@@ -282,6 +285,21 @@ public:
VertexPtr addGate(const Gates &i_gate, const std::string &i_name = "");
VertexPtr addSequential(const SequentialTypes &i_type, VertexPtr i_clk,
VertexPtr i_data, const std::string &i_name = "");
VertexPtr addSequential(const SequentialTypes &i_type, VertexPtr i_clk,
VertexPtr i_data, VertexPtr i_wire,
const std::string &i_name = "");
VertexPtr addSequential(const SequentialTypes &i_type, VertexPtr i_clk,
VertexPtr i_data, VertexPtr i_wire1,
VertexPtr i_wire2, const std::string &i_name = "");
VertexPtr addSequential(const SequentialTypes &i_type, VertexPtr i_clk,
VertexPtr i_data, VertexPtr i_rst, VertexPtr i_set,
VertexPtr i_en, const std::string &i_name = "");
/// @brief addSubGraph
/// Adds a subgraph to the current graph
/// @param i_subGraph A shared pointer to the subgraph to be added
......@@ -382,7 +400,8 @@ public:
std::set<GraphPtr> getSubGraphs() const;
std::set<GraphPtr> getSetSubGraphs() const;
std::array<std::vector<VertexPtr>, 5> getBaseVertexes() const;
std::array<std::vector<VertexPtr>, VertexTypes::output + 1>
getBaseVertexes() const;
VertexPtr getVerticeByIndex(size_t idx) const;
std::string getGraphVerilogInstance();
......@@ -526,7 +545,7 @@ private:
std::map<size_t, std::vector<std::vector<VertexPtr>>> d_subGraphsInputsPtr;
std::set<GraphPtr> d_subGraphs;
std::array<std::vector<VertexPtr>, 5> d_vertexes;
std::array<std::vector<VertexPtr>, VertexTypes::output + 1> d_vertexes;
static std::atomic_size_t d_countGraph;
......@@ -537,4 +556,6 @@ private:
{Gates::GateXor, 0}, {Gates::GateXnor, 0}};
// used for quick edges of gate type count;
std::map<Gates, std::map<Gates, size_t>> d_edgesGatesCount;
};
\ Нет новой строки в конце файла
};
} // namespace CG_Graph
......@@ -2,6 +2,8 @@
#include <map>
namespace CG_Graph {
const std::map<char, std::map<char, char>> tableAnd{
{'0', {{'0', '0'}, {'1', '0'}, {'x', '0'}, {'z', '0'}}},
{'1', {{'0', '0'}, {'1', '1'}, {'x', 'x'}, {'z', 'x'}}},
......@@ -48,3 +50,5 @@ const std::map<char, char> tableBuf{
{'0', '0'}, {'1', '1'}, {'x', 'x'}, {'z', 'x'}};
const std::map<char, char> tableNot{
{'0', '1'}, {'1', '0'}, {'x', 'x'}, {'z', 'x'}};
} // namespace CG_Graph
Это отличие свёрнуто
Это отличие свёрнуто
// Formatting library for C++
//
// Copyright (c) 2012 - 2016, Victor Zverovich
// All rights reserved.
//
// For the license information refer to format.h.
#include "format-inl.h"
FMT_BEGIN_NAMESPACE
namespace detail {
template FMT_API auto dragonbox::to_decimal(float x) noexcept
-> dragonbox::decimal_fp<float>;
template FMT_API auto dragonbox::to_decimal(double x) noexcept
-> dragonbox::decimal_fp<double>;
#ifndef FMT_STATIC_THOUSANDS_SEPARATOR
template FMT_API locale_ref::locale_ref(const std::locale& loc);
template FMT_API auto locale_ref::get<std::locale>() const -> std::locale;
#endif
// Explicit instantiations for char.
template FMT_API auto thousands_sep_impl(locale_ref)
-> thousands_sep_result<char>;
template FMT_API auto decimal_point_impl(locale_ref) -> char;
template FMT_API void buffer<char>::append(const char*, const char*);
template FMT_API void vformat_to(buffer<char>&, string_view,
typename vformat_args<>::type, locale_ref);
// Explicit instantiations for wchar_t.
template FMT_API auto thousands_sep_impl(locale_ref)
-> thousands_sep_result<wchar_t>;
template FMT_API auto decimal_point_impl(locale_ref) -> wchar_t;
template FMT_API void buffer<wchar_t>::append(const wchar_t*, const wchar_t*);
} // namespace detail
FMT_END_NAMESPACE
Это отличие свёрнуто
......@@ -4,6 +4,8 @@
#include "easyloggingpp/easylogging++.h"
#endif
namespace CG_Graph {
std::string operator*(std::string a, unsigned int b) {
std::string output = "";
while (b--) {
......@@ -12,8 +14,8 @@ std::string operator*(std::string a, unsigned int b) {
return output;
}
std::string AuxMethods::replacer(const std::string &i_fmt,
const std::string &i_val) {
std::string AuxMethodsGraph::replacer(const std::string &i_fmt,
const std::string &i_val) {
std::string res;
std::string::size_type pos = 0, prev_pos = 0;
......@@ -30,7 +32,7 @@ std::string AuxMethods::replacer(const std::string &i_fmt,
return res;
}
std::string AuxMethods::dotReturnToString(DotReturn dot) {
std::string AuxMethodsGraph::dotReturnToString(DotReturn dot) {
unsigned int tab = 0;
std::string dotTab = " ";
std::string s = "";
......@@ -83,4 +85,6 @@ std::string AuxMethods::dotReturnToString(DotReturn dot) {
s += "}";
return s;
}
\ Нет новой строки в конце файла
}
} // namespace CG_Graph
......@@ -7,7 +7,7 @@
/* start of static variable values declaration */
namespace GraphUtils {
namespace CG_Graph::GraphUtils {
/* end of static variable values declaration */
......@@ -78,4 +78,4 @@ std::string parseVertexToString(VertexTypes vertex) {
return std::string(findPairByKey(vertexToString, vertex)->second);
};
} // namespace GraphUtils
} // namespace CG_Graph::GraphUtils
......@@ -2,11 +2,15 @@
#include <iostream>
#include <string>
#include <CircuitGenGraph/GraphVertex.hpp>
#include <CircuitGenGraph/GraphVertexBase.hpp>
#ifdef LOGFLAG
#include "easyloggingpp/easylogging++.h"
#endif
#include "../lib/fmt/core.h"
namespace CG_Graph {
std::string VertexUtils::gateToString(Gates i_type) {
switch (i_type) {
......@@ -39,6 +43,8 @@ std::string VertexUtils::vertexTypeToVerilog(VertexTypes i_type) {
return "localparam";
case VertexTypes::gate:
return "wire";
case VertexTypes::seuqential:
return "reg";
default:
return "Not callable";
}
......@@ -55,12 +61,59 @@ std::string VertexUtils::vertexTypeToComment(VertexTypes i_type) {
return "// Writing consts";
case VertexTypes::gate:
return "// Writing gates";
case VertexTypes::seuqential:
return "// Writing registers";
default:
return "// Not writable vertex type";
}
return "// Unknown vertex";
}
inline void format_comment(std::string &res, std::string_view to_format,
std::string_view name) {
std::string copied = fmt::format(to_format, name);
res.reserve(copied.size() + res.size());
res += copied;
}
std::string
VertexUtils::getSequentialComment(const GraphVertexSequential *i_seq) {
constexpr std::string_view en_comment =
"\t// EN signal \"{}\" - when it is in a logical one "
"state, trigger writes data to the output\n";
constexpr std::string_view rst_comment =
"\t// RST signal \"{}\" - when it is in a logical zero "
"state, trigger writes logical zero to the output\n";
constexpr std::string_view async_comment =
"\t// RST signal \"{}\" is async - always "
"block enables on negedge of RST\n";
constexpr std::string_view clr_comment =
"\t// CLR signal \"{}\" - when it is in a logical one "
"state, trigger writes logical zero to the output\n";
constexpr std::string_view set_comment =
"\t// SET signal \"{}\" - when it is in a logical one "
"state, trigger writes logical one to the output\n";
std::string res;
auto type = i_seq->getSeqType();
if (type & RST) {
format_comment(res, rst_comment, i_seq->getRst()->getRawName());
} else if (type & CLR) {
format_comment(res, clr_comment, i_seq->getRst()->getRawName());
}
if (type & ASYNC) {
format_comment(res, async_comment, i_seq->getRst()->getRawName());
}
if (type & SET) {
format_comment(res, set_comment, i_seq->getSet()->getRawName());
}
if (type & EN) {
format_comment(res, en_comment, i_seq->getEn()->getRawName());
}
return res;
}
GraphVertexBase::GraphVertexBase(const VertexTypes i_type, GraphPtr i_graph) {
d_baseGraph = i_graph;
d_type = i_type;
......@@ -283,3 +336,5 @@ std::ostream &operator<<(std::ostream &stream, const GraphVertexBase &vertex) {
stream << vertex.toVerilog();
return stream;
}
} // namespace CG_Graph
Поддерживает Markdown
0% или .
You are about to add 0 people to the discussion. Proceed with caution.
Сначала завершите редактирование этого сообщения!
Пожалуйста, зарегистрируйтесь или чтобы прокомментировать