summaryrefslogtreecommitdiff
path: root/fpga/sim/image_padder_tb.cpp
diff options
context:
space:
mode:
authorEric Dao <eric@erickhangdao.com>2025-03-10 17:54:31 -0400
committerEric Dao <eric@erickhangdao.com>2025-03-10 17:54:31 -0400
commitab224e2e6ba65f5a369ec392f99cd8845ad06c98 (patch)
treea1e757e9341863ed52b8ad4c5a1c45933aab9da4 /fpga/sim/image_padder_tb.cpp
parent40da1752f2c8639186b72f6838aa415e854d0b1d (diff)
downloadthesis-master.tar.gz
thesis-master.tar.bz2
thesis-master.zip
completed thesisHEADmaster
Diffstat (limited to 'fpga/sim/image_padder_tb.cpp')
-rw-r--r--fpga/sim/image_padder_tb.cpp107
1 files changed, 0 insertions, 107 deletions
diff --git a/fpga/sim/image_padder_tb.cpp b/fpga/sim/image_padder_tb.cpp
deleted file mode 100644
index 6a9ef13..0000000
--- a/fpga/sim/image_padder_tb.cpp
+++ /dev/null
@@ -1,107 +0,0 @@
-#include <cstdio>
-#include <cstdlib>
-
-#include "Vimage_padder.h"
-#include "verilated_vcd_c.h"
-
-using namespace std;
-
-Vimage_padder* top;
-
-vluint64_t main_time = 0;
-
-double sc_time_stamp() {
- return main_time;
-}
-
-const int IMG_SIZE = 3; // Original image size (square)
-const int DATA_WIDTH = 8; // Pixel width in bits
-const int PADDED_SIZE = IMG_SIZE + 2; // Size after padding
-
-int main(int argc, char** argv) {
- Verilated::commandArgs(argc, argv);
-
- top = new Vimage_padder;
-
- // Enable waveform tracing
- Verilated::traceEverOn(true);
- VerilatedVcdC* tfp = new VerilatedVcdC;
- top->trace(tfp, 99);
- tfp->open("image_padder.vcd");
-
- // Initialize signals
- top->clk = 0;
- top->rst = 1;
- top->pixel_in = 0;
- top->pixel_valid_in = 0;
-
- // Apply reset
- printf("Applying Reset\n");
- for (int i = 0; i < 10; i++) {
- top->clk = !top->clk;
- top->eval();
- tfp->dump(main_time);
- main_time++;
- }
- top->rst = 0; // Deassert reset
-
- // Test image data (3x3)
- uint8_t test_data[IMG_SIZE][IMG_SIZE] = {
- {1, 2, 3},
- {4, 5, 6},
- {7, 8, 9}
- };
-
- printf("Feeding pixel data into the padder\n");
- top->pixel_valid_in = 1;
-
- // Feed data row by row
- for (int row = 0; row < IMG_SIZE; row++) {
- for (int col = 0; col < IMG_SIZE; col++) {
- // Load pixel into pixel_in
- top->pixel_in = test_data[row][col];
-
- // Toggle clock for one cycle
- for (int i = 0; i < 2; i++) {
- top->clk = !top->clk;
- top->eval();
- tfp->dump(main_time);
- main_time++;
- }
-
- // Print output if valid
- if (top->pixel_valid_out) {
- printf("Output pixel: %02x\n", top->pixel_out);
- }
- }
- }
-
- // Add additional simulation cycles to flush out remaining pixels
- printf("Running additional simulation cycles...\n");
- for (int i = 0; i < PADDED_SIZE * PADDED_SIZE; i++) {
- top->pixel_valid_in = 0;
- top->pixel_in = 0;
-
- // Toggle clock
- for (int j = 0; j < 2; j++) {
- top->clk = !top->clk;
- top->eval();
- tfp->dump(main_time);
- main_time++;
- }
-
- // Print output if valid
- if (top->pixel_valid_out) {
- printf("Extra cycle %d - Output pixel: %02x\n", i, top->pixel_out);
- }
- }
-
- printf("Simulation complete. Final time: %lu\n", main_time);
-
- // Close trace file and clean up
- tfp->close();
- top->final();
- delete top;
-
- return 0;
-} \ No newline at end of file