Skip to content
DenseChip
Learn
PracticeCode labInterview

DenseChip

Navigate

Menu

LearnPracticeCode labInterview

Tools

All toolsSV editorCode repoResume
DenseChip

Practice, courses, and chip-design tools in one focused workspace.

LearnPracticeCode labInterviewToolsLearning paths

© 2026 DenseChip

AboutContactPrivacyTerms
Skip to lesson

Course contents

  • Logic Synthesis Glossary
  • Logic Synthesis Cheatsheet
  • Synthesis Foundations14
  • Logic Optimisation and Mapping20
  • Constraints and Timing15
  • Sequential, FSM and Memory19
    • Flops, Resets and Enables
    • FSM Synthesis
    • Memory and Macro Inference
      • Flop Arrays or RAM Macros
      • Read and Write Port Styles
      • Byte Enables and Bypass Wrappers
      • Compilers, Macros and Wrappers
    • Retiming and Pipelining
  • Datapath Synthesis14
  • Area, Power and Test14
  • Verification, ECO and Handoff15
  • Flows and Debugging15
  • Interview and Judgment11
Loading lesson

‹Memory and Macro Inference
  1. Topics
  2. Logic Synthesis
  3. Sequential, FSM and Memory
  4. Memory and Macro Inference
  5. Byte Enables and Bypass Wrappers

Part 4 · Sequential, FSM and Memory · Intermediate

Byte Enables and Bypass Wrappers

Byte enables, write masks, and bypass wrappers around sync-read RAM.

On this page

    Byte enables and write masks

    A byte enable masks the write lane by lane. Only the enabled bytes change; the rest keep their old values.

    That turns partial-word writes into one masked access. Without enables, a partial write needs a read-modify-write around it.

    Word

    Enables

    Effect

    32-bit, 4 enables

    All set

    Full-word write

    32-bit, 4 enables

    One set

    One byte written, three kept

    16-bit, 2 enables

    Low set only

    Low byte written, high byte kept

    Bypass for same-cycle access

    A sync read returns data one cycle late, so a read of the address just written gets stale data. A bypass path forwards the write data when the addresses match.

    design.sv
    1
    2
    3
    4
    5
    6
    7
    8
    9
    // not-run: illustrative excerpt, not a complete testbench
    always @(posedge clk) begin
      if (we)
        mem[waddr] <= wdata;
      if (we && (waddr == raddr))
        rdata <= wdata;
      else
        rdata <= mem[raddr];
    end

    The listing above is an illustrative excerpt, not a runnable testbench.

    The comparison costs little next to the memory itself. Skipping it corrupts every read-after-write to the same address.

    Mapping a masked memory in Yosys

    The script below collects an 8-entry memory with per-byte write enables into one memory cell, then maps it to 15 flop cells plus the read muxes. Masked writes still infer one cell.

    yosys
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    read_verilog <<EOV
    module top (
      input wire clk,
      input wire [1:0] we,
      input wire [2:0] waddr,
      input wire [2:0] raddr,
      input wire [15:0] wdata,
      output reg [15:0] rdata
    );
      reg [15:0] mem [0:7];
      always @(posedge clk) begin
        if (we[0])
          mem[waddr][7:0] <= wdata[7:0];
        if (we[1])
          mem[waddr][15:8] <= wdata[15:8];
        rdata <= mem[raddr];
      end
    endmodule
    EOV
    hierarchy -check -top top
    proc
    memory_collect
    select -assert-count 1 t:$mem*
    memory_map
    select -assert-none t:$mem*
    select -assert-count 15 t:$dff
    select -assert-count 269 t:$mux
    log PASS: 8x16 byte-enabled memory collects to one memory cell and maps to flops

    Common mistakes

    Common pitfall

    Gating the whole word write with a single enable while intending per-byte writes drops the unwritten bytes. Either the enable masks each lane, or the logic around the memory does the read-modify-write.

    Interview

    Likely probes: mask granularity and bypass need.

    • Byte enables write some lanes and keep the rest without a read-modify-write.

    • Bypass forwards write data to a same-cycle same-address read.

    • A masked 8x16 memory still collects to one memory cell and maps to 15 flop cells in Yosys.

    Check yourself A 32-bit word has 4 write enables and only enable 1 is set. Which bytes change?

    Byte 1 only. The other three bytes keep their old values.

    Check yourself A sync-read RAM has no bypass and software reads the address it just wrote. What arrives?

    Stale data from the previous contents. The new data is still one read latency away.

    Related topics

    • Next: Compilers, Macros and Wrappers

    • Register files

    • Retiming and Pipelining

    Previous

    64 / 139

    Next: Compilers, Macros and Wrappers

    Up next

    Up nextCompilers, Macros and Wrappers

    Sign in to save progress

    Practice this lessonReport an error

    See also

    • Flop Arrays or RAM Macros