xiiregexbuilder

FPGA-Accelerated Regular Expression Matching Engine
commit 03a26fc143c8feacc365a73952f3201de6cfd8be
parent 1afac9076b61391997f852de92a74d1fb2e9e75b
Author: RahulSannapureddy <rahul.sannapureddy@gmail.com>
Date:   Fri,  3 Apr 2026 18:20:52 +0530

Week 3: Implement Top Testbench and start simulation logging (Part 2: Core logic)

Diffstat:
Mdump.vcd | 132+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Moutput-eg/tb_top.v | 122+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 254 insertions(+), 0 deletions(-)

diff --git a/dump.vcd b/dump.vcd @@ -97,3 +97,135 @@ $upscope $end $upscope $end $enddefinitions $end +#0 +$dumpvars +0! +1" +1# +0$ +0% +b0 & +bx ' +0( +1) +1* +0+ +0, +b0 - +x. +bx / +b0 0 +x1 +bx 2 +b0 3 +x4 +bx 5 +b0 6 +x7 +bx 8 +b0 9 +x: +bx ; +b0 < +x= +bx > +b0 ? +$end + +#5000 +1! +b0 ' +1( +0. +b1 / +01 +b1 2 +04 +b1 5 +07 +b1 8 +0: +b1 ; +0= +b1 > + +#10000 +0! +0( + +#15000 +1! +1( + +#20000 +0! +0# +0( +0* + +#25000 +1! +1( +b0 / +b0 2 +b0 5 +b0 8 +b0 ; +b0 > + +#30000 +0! +1$ +0( +1+ + +#35000 +1! +1( +b1 / +b1 2 +b1 5 +b1 8 +b1 ; +b1 > + +#40000 +0! +0$ +b1100001 & +0( +0+ +b1100001 - +b10 0 +b10 3 +b10 6 +b10 9 +b10 < +b10 ? + +#45000 +1! +1( +b10 / +b0 0 +b10 2 +b0 3 +b10 5 +b10 8 +b100 9 +b10 ; +b0 < +b10 > + +#50000 +0! +1% +0( +1, + +#55000 +1! +b101 ' +1( +1. +b0 / diff --git a/output-eg/tb_top.v b/output-eg/tb_top.v @@ -89,3 +89,125 @@ module tb_top; end_of_str = 1; #10; // Match output is valid on the cycle immediately following end_of_str assertion if (match_bus === 6'b000110) begin + $display("PASS: Test case 5 ('ac') matches expected mask 000110"); + end else begin + $display("FAIL: Test case 5 ('ac') expected 000110, got %b", match_bus); + end + end_of_str = 0; #10; + + // Test case 6: "abc" + start = 1; #10 start = 0; + char_in = 8'h61; #10; + char_in = 8'h62; #10; + char_in = 8'h63; #10; + end_of_str = 1; #10; + // Match output is valid on the cycle immediately following end_of_str assertion + if (match_bus === 6'b010110) begin + $display("PASS: Test case 6 ('abc') matches expected mask 010110"); + end else begin + $display("FAIL: Test case 6 ('abc') expected 010110, got %b", match_bus); + end + end_of_str = 0; #10; + + // Test case 7: "abbc" + start = 1; #10 start = 0; + char_in = 8'h61; #10; + char_in = 8'h62; #10; + char_in = 8'h62; #10; + char_in = 8'h63; #10; + end_of_str = 1; #10; + // Match output is valid on the cycle immediately following end_of_str assertion + if (match_bus === 6'b000110) begin + $display("PASS: Test case 7 ('abbc') matches expected mask 000110"); + end else begin + $display("FAIL: Test case 7 ('abbc') expected 000110, got %b", match_bus); + end + end_of_str = 0; #10; + + // Test case 8: "abbbc" + start = 1; #10 start = 0; + char_in = 8'h61; #10; + char_in = 8'h62; #10; + char_in = 8'h62; #10; + char_in = 8'h62; #10; + char_in = 8'h63; #10; + end_of_str = 1; #10; + // Match output is valid on the cycle immediately following end_of_str assertion + if (match_bus === 6'b000110) begin + $display("PASS: Test case 8 ('abbbc') matches expected mask 000110"); + end else begin + $display("FAIL: Test case 8 ('abbbc') expected 000110, got %b", match_bus); + end + end_of_str = 0; #10; + + // Test case 9: "aaaa" + start = 1; #10 start = 0; + char_in = 8'h61; #10; + char_in = 8'h61; #10; + char_in = 8'h61; #10; + char_in = 8'h61; #10; + end_of_str = 1; #10; + // Match output is valid on the cycle immediately following end_of_str assertion + if (match_bus === 6'b000100) begin + $display("PASS: Test case 9 ('aaaa') matches expected mask 000100"); + end else begin + $display("FAIL: Test case 9 ('aaaa') expected 000100, got %b", match_bus); + end + end_of_str = 0; #10; + + // Test case 10: "bbbb" + start = 1; #10 start = 0; + char_in = 8'h62; #10; + char_in = 8'h62; #10; + char_in = 8'h62; #10; + char_in = 8'h62; #10; + end_of_str = 1; #10; + // Match output is valid on the cycle immediately following end_of_str assertion + if (match_bus === 6'b000100) begin + $display("PASS: Test case 10 ('bbbb') matches expected mask 000100"); + end else begin + $display("FAIL: Test case 10 ('bbbb') expected 000100, got %b", match_bus); + end + end_of_str = 0; #10; + + // Test case 11: "x" + start = 1; #10 start = 0; + char_in = 8'h78; #10; + end_of_str = 1; #10; + // Match output is valid on the cycle immediately following end_of_str assertion + if (match_bus === 6'b000000) begin + $display("PASS: Test case 11 ('x') matches expected mask 000000"); + end else begin + $display("FAIL: Test case 11 ('x') expected 000000, got %b", match_bus); + end + end_of_str = 0; #10; + + // Test case 12: "axb" + start = 1; #10 start = 0; + char_in = 8'h61; #10; + char_in = 8'h78; #10; + char_in = 8'h62; #10; + end_of_str = 1; #10; + // Match output is valid on the cycle immediately following end_of_str assertion + if (match_bus === 6'b001000) begin + $display("PASS: Test case 12 ('axb') matches expected mask 001000"); + end else begin + $display("FAIL: Test case 12 ('axb') expected 001000, got %b", match_bus); + end + end_of_str = 0; #10; + + // Test case 13: "ayb" + start = 1; #10 start = 0; + char_in = 8'h61; #10; + char_in = 8'h79; #10; + char_in = 8'h62; #10; + end_of_str = 1; #10; + // Match output is valid on the cycle immediately following end_of_str assertion + if (match_bus === 6'b001000) begin + $display("PASS: Test case 13 ('ayb') matches expected mask 001000"); + end else begin + $display("FAIL: Test case 13 ('ayb') expected 001000, got %b", match_bus); + end + end_of_str = 0; #10; + + // Test case 14: "(a|b)"