-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #368 from phanrahan/fix-bit-vector
Fix bit vector
- Loading branch information
Showing
10 changed files
with
266 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
#include "VTestBasic.h" | ||
#include "verilated.h" | ||
#include <iostream> | ||
#include <verilated_vcd_c.h> | ||
#include <sys/types.h> | ||
#include <sys/stat.h> | ||
|
||
// Based on https://www.veripool.org/projects/verilator/wiki/Manual-verilator#CONNECTING-TO-C | ||
vluint64_t main_time = 0; // Current simulation time | ||
// This is a 64-bit integer to reduce wrap over issues and | ||
// allow modulus. You can also use a double, if you wish. | ||
|
||
double sc_time_stamp () { // Called by $time in Verilog | ||
return main_time; // converts to double, to match | ||
// what SystemC does | ||
} | ||
|
||
#if VM_TRACE | ||
VerilatedVcdC* tracer; | ||
#endif | ||
|
||
void my_assert( | ||
unsigned int got, | ||
unsigned int expected, | ||
int i, | ||
const char* port) { | ||
if (got != expected) { | ||
std::cerr << std::endl; // end the current line | ||
std::cerr << "Got : 0x" << std::hex << got << std::endl; | ||
std::cerr << "Expected : 0x" << std::hex << expected << std::endl; | ||
std::cerr << "i : " << std::dec << i << std::endl; | ||
std::cerr << "Port : " << port << std::endl; | ||
#if VM_TRACE | ||
tracer->close(); | ||
#endif | ||
exit(1); | ||
} | ||
} | ||
|
||
int main(int argc, char **argv) { | ||
Verilated::commandArgs(argc, argv); | ||
VTestBasic* top = new VTestBasic; | ||
|
||
#if VM_TRACE | ||
Verilated::traceEverOn(true); | ||
tracer = new VerilatedVcdC; | ||
top->trace(tracer, 99); | ||
mkdir("logs", S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH); | ||
tracer->open("logs/TestBasic.vcd"); | ||
#endif | ||
|
||
top->I = 1; | ||
top->eval(); | ||
main_time++; | ||
#if VM_TRACE | ||
tracer->dump(main_time); | ||
#endif | ||
top->CLK ^= 1; | ||
top->eval(); | ||
main_time++; | ||
#if VM_TRACE | ||
tracer->dump(main_time); | ||
#endif | ||
top->CLK ^= 1; | ||
top->I = 2; | ||
top->eval(); | ||
main_time++; | ||
#if VM_TRACE | ||
tracer->dump(main_time); | ||
#endif | ||
top->CLK ^= 1; | ||
top->eval(); | ||
main_time++; | ||
#if VM_TRACE | ||
tracer->dump(main_time); | ||
#endif | ||
top->CLK ^= 1; | ||
my_assert(top->O, 1, 4, "TestBasic.O"); | ||
top->I = 3; | ||
top->eval(); | ||
main_time++; | ||
#if VM_TRACE | ||
tracer->dump(main_time); | ||
#endif | ||
top->CLK ^= 1; | ||
top->eval(); | ||
main_time++; | ||
#if VM_TRACE | ||
tracer->dump(main_time); | ||
#endif | ||
top->CLK ^= 1; | ||
my_assert(top->O, 2, 7, "TestBasic.O"); | ||
top->I = 0; | ||
top->eval(); | ||
main_time++; | ||
#if VM_TRACE | ||
tracer->dump(main_time); | ||
#endif | ||
top->CLK ^= 1; | ||
top->eval(); | ||
main_time++; | ||
#if VM_TRACE | ||
tracer->dump(main_time); | ||
#endif | ||
top->CLK ^= 1; | ||
my_assert(top->O, 3, 10, "TestBasic.O"); | ||
|
||
|
||
#if VM_TRACE | ||
tracer->close(); | ||
#endif | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
#include "VTestShiftRegister.h" | ||
#include "verilated.h" | ||
#include <iostream> | ||
#include <verilated_vcd_c.h> | ||
#include <sys/types.h> | ||
#include <sys/stat.h> | ||
|
||
// Based on https://www.veripool.org/projects/verilator/wiki/Manual-verilator#CONNECTING-TO-C | ||
vluint64_t main_time = 0; // Current simulation time | ||
// This is a 64-bit integer to reduce wrap over issues and | ||
// allow modulus. You can also use a double, if you wish. | ||
|
||
double sc_time_stamp () { // Called by $time in Verilog | ||
return main_time; // converts to double, to match | ||
// what SystemC does | ||
} | ||
|
||
#if VM_TRACE | ||
VerilatedVcdC* tracer; | ||
#endif | ||
|
||
void my_assert( | ||
unsigned int got, | ||
unsigned int expected, | ||
int i, | ||
const char* port) { | ||
if (got != expected) { | ||
std::cerr << std::endl; // end the current line | ||
std::cerr << "Got : 0x" << std::hex << got << std::endl; | ||
std::cerr << "Expected : 0x" << std::hex << expected << std::endl; | ||
std::cerr << "i : " << std::dec << i << std::endl; | ||
std::cerr << "Port : " << port << std::endl; | ||
#if VM_TRACE | ||
tracer->close(); | ||
#endif | ||
exit(1); | ||
} | ||
} | ||
|
||
int main(int argc, char **argv) { | ||
Verilated::commandArgs(argc, argv); | ||
VTestShiftRegister* top = new VTestShiftRegister; | ||
|
||
#if VM_TRACE | ||
Verilated::traceEverOn(true); | ||
tracer = new VerilatedVcdC; | ||
top->trace(tracer, 99); | ||
mkdir("logs", S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH); | ||
tracer->open("logs/TestShiftRegister.vcd"); | ||
#endif | ||
|
||
top->I = 1; | ||
top->eval(); | ||
main_time++; | ||
#if VM_TRACE | ||
tracer->dump(main_time); | ||
#endif | ||
top->CLK ^= 1; | ||
top->eval(); | ||
main_time++; | ||
#if VM_TRACE | ||
tracer->dump(main_time); | ||
#endif | ||
top->CLK ^= 1; | ||
top->I = 2; | ||
top->eval(); | ||
main_time++; | ||
#if VM_TRACE | ||
tracer->dump(main_time); | ||
#endif | ||
top->CLK ^= 1; | ||
top->eval(); | ||
main_time++; | ||
#if VM_TRACE | ||
tracer->dump(main_time); | ||
#endif | ||
top->CLK ^= 1; | ||
my_assert(top->O, 1, 4, "TestShiftRegister.O"); | ||
top->I = 3; | ||
top->eval(); | ||
main_time++; | ||
#if VM_TRACE | ||
tracer->dump(main_time); | ||
#endif | ||
top->CLK ^= 1; | ||
top->eval(); | ||
main_time++; | ||
#if VM_TRACE | ||
tracer->dump(main_time); | ||
#endif | ||
top->CLK ^= 1; | ||
my_assert(top->O, 2, 7, "TestShiftRegister.O"); | ||
top->I = 0; | ||
top->eval(); | ||
main_time++; | ||
#if VM_TRACE | ||
tracer->dump(main_time); | ||
#endif | ||
top->CLK ^= 1; | ||
top->eval(); | ||
main_time++; | ||
#if VM_TRACE | ||
tracer->dump(main_time); | ||
#endif | ||
top->CLK ^= 1; | ||
my_assert(top->O, 3, 10, "TestShiftRegister.O"); | ||
|
||
|
||
#if VM_TRACE | ||
tracer->close(); | ||
#endif | ||
} |
Oops, something went wrong.