Skip to content

Commit 30d19fc

Browse files
Support inverted inputs in the config.
1 parent e868fe2 commit 30d19fc

File tree

2 files changed

+19
-3
lines changed

2 files changed

+19
-3
lines changed

src/Hardware/Read.cpp

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2562,6 +2562,16 @@ void Hardware::Read::SettingsFile(char *InputSettingsFileName, Hardware::Circuit
25622562

25632563
Hardware::Read::NonCommentFromFile(SettingsFile, Str1, "%");
25642564

2565+
int InvertedInput = 0;
2566+
if (Str1[0] == '~')
2567+
{
2568+
strncpy(Str2, &Str1[1], Max_Name_Length - 2);
2569+
Str2[Max_Name_Length - 1] = '\0';
2570+
strncpy(Str1, Str2, Max_Name_Length - 1);
2571+
Str1[Max_Name_Length - 1] = '\0';
2572+
InvertedInput = 1;
2573+
}
2574+
25652575
if (strstr(Str1, "group_in") != Str1)
25662576
{
25672577
strncpy(Str2, Str1, Max_Name_Length - 1);
@@ -2871,7 +2881,7 @@ void Hardware::Read::SettingsFile(char *InputSettingsFileName, Hardware::Circuit
28712881
else
28722882
TempIndex = InitialInputList[NumberOfBuffer_char];
28732883

2874-
Settings->InitialSim_Values[ClockCycle][TempIndex] = ShareIndex;
2884+
Settings->InitialSim_Values[ClockCycle][TempIndex] = (ShareIndex << 1) | InvertedInput;
28752885
Settings->InitialSim_Values[ClockCycle][TempIndex] <<= 32;
28762886
Settings->InitialSim_Values[ClockCycle][TempIndex] |= IndexL2 + (j - IndexL);
28772887
Settings->InitialSim_Values[ClockCycle][TempIndex] |= GroupInput;

src/Hardware/Simulate.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ void Hardware::Simulate::All(Hardware::LibraryStruct &Library, Hardware::Circuit
5151
int GroupIndex;
5252
int ValueIndex;
5353
int ShareIndex;
54+
uint64_t InvertedInput;
5455
uint64_t Select[100];
5556
int ProbeIndex;
5657
std::string ErrorMessage;
@@ -143,9 +144,14 @@ void Hardware::Simulate::All(Hardware::LibraryStruct &Library, Hardware::Circuit
143144
if ((Settings.InitialSim_Values[ClockCycle][InputIndex] & GroupInMask) == GroupInput)
144145
{
145146
ValueIndex = Settings.InitialSim_Values[ClockCycle][InputIndex] & 0xffffffff;
146-
ShareIndex = (Settings.InitialSim_Values[ClockCycle][InputIndex] >> 32) & 0xff;
147+
InvertedInput = (Settings.InitialSim_Values[ClockCycle][InputIndex] >> 32) & 1;
148+
ShareIndex = (Settings.InitialSim_Values[ClockCycle][InputIndex] >> 33) & 0xff;
147149

148-
SharedData->SignalValues[Settings.InitialSim_Inputs[ClockCycle][InputIndex]] = SharedData->SelectedGroupValues[ValueIndex][ShareIndex];
150+
if (InvertedInput){
151+
InvertedInput = FullOne;
152+
}
153+
154+
SharedData->SignalValues[Settings.InitialSim_Inputs[ClockCycle][InputIndex]] = InvertedInput ^ SharedData->SelectedGroupValues[ValueIndex][ShareIndex];
149155
}
150156
else if ((Settings.InitialSim_Values[ClockCycle][InputIndex] & GroupInMask) == SameInput)
151157
SharedData->SignalValues[Settings.InitialSim_Inputs[ClockCycle][InputIndex]] = SharedData->LastInitialSimValues[InputIndex];

0 commit comments

Comments
 (0)