Skip to content

Commit

Permalink
Test all files in verilog dir
Browse files Browse the repository at this point in the history
  • Loading branch information
RCoeurjoly committed May 25, 2024
1 parent 24f6c07 commit c6dddac
Show file tree
Hide file tree
Showing 26 changed files with 233 additions and 25 deletions.
4 changes: 2 additions & 2 deletions tests/functional/.gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
and_cxxrtl.cc
and_functional_cxx.cc
my_module_cxxrtl.cc
my_module_functional_cxx.cc
vcd_harness
cxxrtl.vcd
functional_cxx.vcd
40 changes: 25 additions & 15 deletions tests/functional/run-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,29 @@

set -ex

../../yosys -p "read_verilog verilog/and.v; write_cxxrtl and_cxxrtl.cc; write_functional_cxx and_functional_cxx.cc"
${CXX:-g++} -g -fprofile-arcs -ftest-coverage vcd_harness.cpp -I ../../backends/functional/cxx_runtime/ -I ../../backends/cxxrtl/runtime/ -o vcd_harness
# Generate VCD files cxxrtl.vcd and functional_cxx.vcd
./vcd_harness
# Run vcdiff and capture the output
output=$(vcdiff cxxrtl.vcd functional_cxx.vcd)
# Loop through all Verilog files in the verilog directory
for verilog_file in verilog/*.v; do
# Run yosys to process each Verilog file
../../yosys -p "read_verilog $verilog_file; write_cxxrtl my_module_cxxrtl.cc; write_functional_cxx my_module_functional_cxx.cc"

# Check if there is any output
if [ -n "$output" ]; then
echo "Differences detected:"
echo "$output"
exit 1
else
echo "No differences detected."
exit 0
fi
# Compile the generated C++ files with vcd_harness.cpp
${CXX:-g++} -g -fprofile-arcs -ftest-coverage vcd_harness.cpp -I ../../backends/functional/cxx_runtime/ -I ../../backends/cxxrtl/runtime/ -o vcd_harness

# Generate VCD files cxxrtl.vcd and functional_cxx.vcd
./vcd_harness

# Run vcdiff and capture the output
output=$(vcdiff cxxrtl.vcd functional_cxx.vcd)

# Check if there is any output
if [ -n "$output" ]; then
echo "Differences detected in $verilog_file:"
echo "$output"
exit 1
else
echo "No differences detected in $verilog_file."
fi
done

# If all files are processed without differences
exit 0
4 changes: 2 additions & 2 deletions tests/functional/vcd_harness.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@

#include <cxxrtl/cxxrtl_vcd.h>

#include "and_cxxrtl.cc"
#include "and_functional_cxx.cc"
#include "my_module_cxxrtl.cc"
#include "my_module_functional_cxx.cc"

struct DumpHeader {
std::ofstream &ofs;
Expand Down
9 changes: 9 additions & 0 deletions tests/functional/verilog/add.v
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
module my_module(
input a,
input b,
output sum
);
// Perform addition
assign sum = a + b;

endmodule
12 changes: 6 additions & 6 deletions tests/functional/verilog/and.v
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
module my_module(
input a,
input b,
output sum
);
// Perform addition
assign sum = a + b;
input a,
input b,
output y
);
// Perform AND
assign y = a & b;

endmodule
9 changes: 9 additions & 0 deletions tests/functional/verilog/my_module_div.v
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
module my_module(
input a,
input b,
output y
);
// Perform operation
assign y = a / b;

endmodule
9 changes: 9 additions & 0 deletions tests/functional/verilog/my_module_eqx.v
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
module my_module(
input a,
input b,
output y
);
// Perform operation
assign y = a === b;

endmodule
9 changes: 9 additions & 0 deletions tests/functional/verilog/my_module_ge.v
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
module my_module(
input a,
input b,
output y
);
// Perform operation
assign y = a >= b;

endmodule
9 changes: 9 additions & 0 deletions tests/functional/verilog/my_module_gt.v
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
module my_module(
input a,
input b,
output y
);
// Perform operation
assign y = a > b;

endmodule
9 changes: 9 additions & 0 deletions tests/functional/verilog/my_module_le.v
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
module my_module(
input a,
input b,
output y
);
// Perform operation
assign y = a <= b;

endmodule
9 changes: 9 additions & 0 deletions tests/functional/verilog/my_module_logic_and.v
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
module my_module(
input a,
input b,
output y
);
// Perform operation
assign y = a && b;

endmodule
9 changes: 9 additions & 0 deletions tests/functional/verilog/my_module_logic_or.v
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
module my_module(
input a,
input b,
output y
);
// Perform operation
assign y = a || b;

endmodule
9 changes: 9 additions & 0 deletions tests/functional/verilog/my_module_lt.v
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
module my_module(
input a,
input b,
output y
);
// Perform operation
assign y = a < b;

endmodule
9 changes: 9 additions & 0 deletions tests/functional/verilog/my_module_mod.v
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
module my_module(
input a,
input b,
output y
);
// Perform operation
assign y = a % b;

endmodule
9 changes: 9 additions & 0 deletions tests/functional/verilog/my_module_mul.v
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
module my_module(
input a,
input b,
output y
);
// Perform operation
assign y = a * b;

endmodule
9 changes: 9 additions & 0 deletions tests/functional/verilog/my_module_ne.v
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
module my_module(
input a,
input b,
output y
);
// Perform operation
assign y = a != b;

endmodule
9 changes: 9 additions & 0 deletions tests/functional/verilog/my_module_nex.v
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
module my_module(
input a,
input b,
output y
);
// Perform operation
assign y = a !== b;

endmodule
9 changes: 9 additions & 0 deletions tests/functional/verilog/my_module_or.v
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
module my_module(
input a,
input b,
output y
);
// Perform operation
assign y = a | b;

endmodule
9 changes: 9 additions & 0 deletions tests/functional/verilog/my_module_pow.v
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
module my_module(
input a,
input b,
output y
);
// Perform operation
assign y = a ** b;

endmodule
9 changes: 9 additions & 0 deletions tests/functional/verilog/my_module_shl.v
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
module my_module(
input a,
input b,
output y
);
// Perform operation
assign y = a << b;

endmodule
9 changes: 9 additions & 0 deletions tests/functional/verilog/my_module_shr.v
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
module my_module(
input a,
input b,
output y
);
// Perform operation
assign y = a >> b;

endmodule
9 changes: 9 additions & 0 deletions tests/functional/verilog/my_module_sshl.v
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
module my_module(
input a,
input b,
output y
);
// Perform operation
assign y = a <<< b;

endmodule
9 changes: 9 additions & 0 deletions tests/functional/verilog/my_module_sshr.v
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
module my_module(
input a,
input b,
output y
);
// Perform operation
assign y = a >>> b;

endmodule
9 changes: 9 additions & 0 deletions tests/functional/verilog/my_module_sub.v
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
module my_module(
input a,
input b,
output y
);
// Perform operation
assign y = a - b;

endmodule
9 changes: 9 additions & 0 deletions tests/functional/verilog/my_module_xnor.v
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
module my_module(
input a,
input b,
output y
);
// Perform operation
assign y = a ~^ b;

endmodule
9 changes: 9 additions & 0 deletions tests/functional/verilog/my_module_xor.v
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
module my_module(
input a,
input b,
output y
);
// Perform operation
assign y = a ^ b;

endmodule

0 comments on commit c6dddac

Please sign in to comment.