mirror of https://github.com/XS-MLVP/xcomm.git
add sed Replace XSPCOMM_VERSION as PROJECT_VERSION
add XClock comments, add XClock() structural function
This commit is contained in:
parent
b9f0b325e4
commit
e1f31d363d
|
@ -0,0 +1,73 @@
|
|||
Language: Cpp
|
||||
BasedOnStyle: LLVM
|
||||
AccessModifierOffset: -4
|
||||
AlignAfterOpenBracket: Align
|
||||
AlignConsecutiveAssignments: true
|
||||
AlignConsecutiveDeclarations: false
|
||||
AlignEscapedNewlines: Right
|
||||
AlignOperands: true
|
||||
AlignTrailingComments: true
|
||||
AllowAllParametersOfDeclarationOnNextLine: false
|
||||
AllowShortBlocksOnASingleLine: true
|
||||
AllowShortCaseLabelsOnASingleLine: true
|
||||
AllowShortFunctionsOnASingleLine: Inline
|
||||
AllowShortIfStatementsOnASingleLine: true
|
||||
AllowShortLoopsOnASingleLine: true
|
||||
AlwaysBreakAfterReturnType: None
|
||||
AlwaysBreakBeforeMultilineStrings: false
|
||||
AlwaysBreakTemplateDeclarations: true
|
||||
BinPackArguments: true
|
||||
BinPackParameters: true
|
||||
BreakBeforeBraces: Custom
|
||||
BraceWrapping:
|
||||
AfterClass: true
|
||||
AfterControlStatement: false
|
||||
AfterEnum: false
|
||||
AfterFunction: true
|
||||
AfterNamespace: false
|
||||
AfterStruct: false
|
||||
AfterUnion: false
|
||||
AfterExternBlock: false
|
||||
BeforeCatch: false
|
||||
BeforeElse: false
|
||||
IndentBraces: false
|
||||
SplitEmptyFunction: false
|
||||
SplitEmptyRecord: false
|
||||
SplitEmptyNamespace: false
|
||||
BreakBeforeBinaryOperators: NonAssignment
|
||||
BreakBeforeTernaryOperators: false
|
||||
BreakConstructorInitializers: AfterColon
|
||||
BreakStringLiterals: false
|
||||
ColumnLimit: 80
|
||||
CompactNamespaces: true
|
||||
ConstructorInitializerAllOnOneLineOrOnePerLine: true
|
||||
ConstructorInitializerIndentWidth: 4
|
||||
ContinuationIndentWidth: 4
|
||||
Cpp11BracedListStyle: true
|
||||
DerivePointerAlignment: false
|
||||
FixNamespaceComments: true
|
||||
IndentCaseLabels: false
|
||||
IndentPPDirectives: None
|
||||
IndentWidth: 4
|
||||
IndentWrappedFunctionNames: false
|
||||
KeepEmptyLinesAtTheStartOfBlocks: false
|
||||
MaxEmptyLinesToKeep: 1
|
||||
NamespaceIndentation: Inner
|
||||
PointerAlignment: Right
|
||||
ReflowComments: true
|
||||
SortIncludes: false
|
||||
SortUsingDeclarations: false
|
||||
SpaceAfterCStyleCast: false
|
||||
SpaceAfterTemplateKeyword: true
|
||||
SpaceBeforeAssignmentOperators: true
|
||||
SpaceBeforeParens: ControlStatements
|
||||
SpaceInEmptyParentheses: false
|
||||
SpacesBeforeTrailingComments: 1
|
||||
SpacesInAngles: false
|
||||
SpacesInCStyleCastParentheses: false
|
||||
SpacesInContainerLiterals: true
|
||||
SpacesInParentheses: false
|
||||
SpacesInSquareBrackets: false
|
||||
Standard: Auto
|
||||
TabWidth: 4
|
||||
UseTab: Never
|
|
@ -41,6 +41,7 @@ VERBATIM
|
|||
COMMAND ${CMAKE_COMMAND} -E copy_directory
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/include"
|
||||
"${CMAKE_ARCHIVE_OUTPUT_DIRECTORY}"
|
||||
COMMAND sed -i "s/XSPCOMM_VERSION/\"${PROJECT_VERSION}\"/g" ${CMAKE_ARCHIVE_OUTPUT_DIRECTORY}/xspcomm/xutil.h
|
||||
)
|
||||
|
||||
install( DIRECTORY ${CMAKE_ARCHIVE_OUTPUT_DIRECTORY}/ DESTINATION include )
|
||||
|
|
2
Makefile
2
Makefile
|
@ -4,7 +4,7 @@ build:
|
|||
cmake . -Bbuild
|
||||
cd build && make -j`nproc`
|
||||
|
||||
install: build
|
||||
install: clean build
|
||||
cd build && make install
|
||||
|
||||
clean:
|
||||
|
|
|
@ -55,15 +55,20 @@ class XClock
|
|||
std::string desc);
|
||||
|
||||
public:
|
||||
std::vector<xspcomm::XData *> pins;
|
||||
std::vector<xspcomm::XData *> clock_pins;
|
||||
std::vector<xspcomm::XPort *> ports;
|
||||
u_int64_t clk = 0;
|
||||
bool stop_on_rise = true;
|
||||
|
||||
void default_stop_on_rise(bool rise);
|
||||
XClock();
|
||||
XClock(xfunction<int, bool> stepfunc,
|
||||
std::initializer_list<xspcomm::XData *> pins = {},
|
||||
std::initializer_list<xspcomm::XData *> clock_pins = {},
|
||||
std::initializer_list<xspcomm::XPort *> ports = {});
|
||||
|
||||
void ReInit(xfunction<int, bool> stepfunc,
|
||||
std::initializer_list<xspcomm::XData *> clock_pins = {},
|
||||
std::initializer_list<xspcomm::XPort *> ports = {});
|
||||
void Add(xspcomm::XData *d);
|
||||
void Add(xspcomm::XData &d);
|
||||
void Add(xspcomm::XPort *d);
|
||||
|
|
|
@ -73,34 +73,54 @@ void XClock::default_stop_on_rise(bool rise)
|
|||
{
|
||||
this->stop_on_rise = rise;
|
||||
}
|
||||
|
||||
XClock::XClock() : XClock(nullptr, {}, {}){};
|
||||
|
||||
/// @brief set the step function, bind clock pins which need 0/1 and bind ports
|
||||
/// to write/read
|
||||
/// @param stepfunc
|
||||
/// @param clock_pins the clock pins which need set high/low
|
||||
/// @param ports
|
||||
XClock::XClock(xfunction<int, bool> stepfunc,
|
||||
std::initializer_list<xspcomm::XData *> pins,
|
||||
std::initializer_list<xspcomm::XData *> clock_pins,
|
||||
std::initializer_list<xspcomm::XPort *> ports)
|
||||
{
|
||||
this->ReInit(stepfunc, clock_pins, ports);
|
||||
}
|
||||
|
||||
void XClock::ReInit(xfunction<int, bool> stepfunc,
|
||||
std::initializer_list<xspcomm::XData *> clock_pins,
|
||||
std::initializer_list<xspcomm::XPort *> ports)
|
||||
{
|
||||
this->step_fc = stepfunc;
|
||||
for (auto &d : pins) { this->Add(d); }
|
||||
for (auto &d : clock_pins) { this->Add(d); }
|
||||
for (auto &d : ports) { this->Add(d); }
|
||||
}
|
||||
|
||||
/// @brief add a clock pin which need set high/low
|
||||
void XClock::Add(xspcomm::XData *d)
|
||||
{
|
||||
if (contians(this->pins, d)) {
|
||||
if (contians(this->clock_pins, d)) {
|
||||
Warn("pin(%s) is already added", d->mName.c_str());
|
||||
return;
|
||||
}
|
||||
d->SetWriteMode(d->Imme);
|
||||
this->pins.push_back(d);
|
||||
this->clock_pins.push_back(d);
|
||||
}
|
||||
|
||||
/// @brief add a clock pin which need set high/low
|
||||
void XClock::Add(xspcomm::XData &d)
|
||||
{
|
||||
if (contians(this->pins, &d)) {
|
||||
if (contians(this->clock_pins, &d)) {
|
||||
Warn("pin(%s) is already added", d.mName.c_str());
|
||||
return;
|
||||
}
|
||||
d.SetWriteMode(d.Imme);
|
||||
this->pins.push_back(&d);
|
||||
this->clock_pins.push_back(&d);
|
||||
}
|
||||
|
||||
|
||||
/// @brief add a port which need write/read on rise/fall
|
||||
void XClock::Add(xspcomm::XPort *d)
|
||||
{
|
||||
if (contians(this->ports, d)) {
|
||||
|
@ -110,6 +130,7 @@ void XClock::Add(xspcomm::XPort *d)
|
|||
this->ports.push_back(d);
|
||||
}
|
||||
|
||||
/// @brief add a port which need write/read on rise/fall
|
||||
void XClock::Add(xspcomm::XPort &d)
|
||||
{
|
||||
if (contians(this->ports, &d)) {
|
||||
|
@ -145,7 +166,7 @@ void XClock::RunStep(int s)
|
|||
|
||||
void XClock::_step_fal()
|
||||
{
|
||||
for (auto &v : this->pins) { *v = 0; }
|
||||
for (auto &v : this->clock_pins) { *v = 0; }
|
||||
this->_step(false);
|
||||
for (auto &p : this->ports) { p->WriteOnFall(); }
|
||||
this->_step(true);
|
||||
|
@ -155,7 +176,7 @@ void XClock::_step_fal()
|
|||
|
||||
void XClock::_step_ris()
|
||||
{
|
||||
for (auto &v : this->pins) { *v = 1; }
|
||||
for (auto &v : this->clock_pins) { *v = 1; }
|
||||
this->_step(false);
|
||||
for (auto &p : this->ports) { p->WriteOnRise(); }
|
||||
this->_step(true);
|
||||
|
@ -168,13 +189,13 @@ void XClock::Reset()
|
|||
this->clk = 0;
|
||||
}
|
||||
|
||||
void XClock::StepRis(xfunction<void, u_int64_t, void *> func,
|
||||
void *args, std::string desc)
|
||||
void XClock::StepRis(xfunction<void, u_int64_t, void *> func, void *args,
|
||||
std::string desc)
|
||||
{
|
||||
return this->_add_cb(this->list_call_back_ris, func, args, desc);
|
||||
}
|
||||
void XClock::StepFal(xfunction<void, u_int64_t, void *> func,
|
||||
void *args, std::string desc)
|
||||
void XClock::StepFal(xfunction<void, u_int64_t, void *> func, void *args,
|
||||
std::string desc)
|
||||
{
|
||||
return this->_add_cb(this->list_call_back_fal, func, args, desc);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue