STEP 7 - COMPLETE FRONT END (guide architecture), ONE TOP LEVEL
================================================================
   Input ROM --I,Q--> S2P1/S2P2 --patch--> ROM-W' + multiplier --e-->
   Token ROM + MUX -> RAM-E -> (+ ROM-P') -> write back --> tok_out (9 x 128)

   raw QPSK (2,128) stored in the Input ROM  ->  Encoder-0 input (9,128)
   Functions: extract_patches -> patch_embedding -> add_token_and_positions
   (x - mean)/std removed: folded into ROM-W' and ROM-P'

What is new
   The four blocks are the SAME code as the verified Steps 1, 2, 4, 5+6.
   They are connected inside one function by FIFOs (hls::stream) and run as a
   DATAFLOW pipeline (#pragma HLS DATAFLOW): every block starts as soon as its
   first input arrives, so they overlap in time instead of waiting for each other.
      FIFO I_out, Q_out : Input ROM -> S2P            (depth 4)
      FIFO patch        : S2P -> multiplier           (depth 2, built from registers, no BRAM)
      FIFO embedding    : multiplier -> RAM-E          (depth 4)

Folder
   S7_front_end_src\
      hls_config.cfg             top = mrt_front
      src\mrt_front.h / .cpp      4 blocks + dataflow top
      tb\mrt_front_tb.cpp         starts the front end, checks 1152 outputs
      data\i_rom.dat, q_rom.dat   raw QPSK input (Input ROM)
      data\rom_w.dat              ROM-W' (32 x 128)
      data\token_rom.dat          Token ROM (128)
      data\rom_p.dat              ROM-P' (9 x 128)
      data\token_position_ref.dat Token_position_output_calculated.csv (9 x 128)

Check
   vs Token_position_output_calculated.csv   expect 1.88e-05 (tol 1e-04)  [3-encoder ROMs: predicted 1.877e-05; 6-encoder ROMs gave 1.79e-05]

How to run
   1. Extract to ...\MRT_Blocks\MRT_Blocks\S7_front_end_src\  (no double folder)
   2. Vitis: New Component -> HLS
        Name: s7_front_end   Location: ...\MRT_Blocks\MRT_Blocks (no workspace switch)
        Config: Existing -> S7_front_end_src\hls_config.cfg
        Top: mrt_front       Part: xc7s50csga324-1  -> Finish
   3. C SIMULATION        expect "*** STEP 7 FRONT END TEST PASSED ***"
   4. C SYNTHESIS         expect: 4 processes under mrt_front (input_rom, s2p,
                          patch_embed, token_pos), dataflow; latency about 2,300-2,450
                          clocks (instead of 3,634 one after another);
                          DSP 32, BRAM about 40 (+ the patch FIFO), estimated clock < 10 ns
   5. C/RTL COSIMULATION  expect PASS
   6. Optional: C SYNTHESIS -> REPORTS -> Dataflow Viewer shows the 4 blocks and FIFOs
      (if it asks for a license, skip it)

Waveform (xsim --gui in ...\s7_front_end\mrt_front\hls\sim\verilog, Tcl console):
   set g [add_wave_group "S7"]; set p /apatb_mrt_front_top/AESL_inst_mrt_front; add_wave -into $g $p/ap_clk; add_wave -into $g $p/ap_start; add_wave -into $g $p/tok_out_write; add_wave -into $g -radix hex $p/tok_out_din; add_wave -into $g $p/ap_done
   (the internal FIFOs are under AESL_inst_mrt_front in the Scope panel)
