module hq2x_in #(parameter LENGTH, parameter DWIDTH)
(
    input            clk,

    input [AWIDTH:0] rdaddr,
    input            rdbuf0, rdbuf1,
    output[DWIDTH:0] q0,q1,

    input [AWIDTH:0] wraddr,
    input            wrbuf,
    input [DWIDTH:0] data,
    input            wren
);

    localparam AWIDTH = $clog2(LENGTH)-1;
    wire  [DWIDTH:0] out[2];
    assign q0 = out[rdbuf0];
    assign q1 = out[rdbuf1];

    hq2x_buf #(.NUMWORDS(LENGTH), .AWIDTH(AWIDTH), .DWIDTH(DWIDTH)) buf0(clk,data,rdaddr,wraddr,wren && (wrbuf == 0),out[0]);
    hq2x_buf #(.NUMWORDS(LENGTH), .AWIDTH(AWIDTH), .DWIDTH(DWIDTH)) buf1(clk,data,rdaddr,wraddr,wren && (wrbuf == 1),out[1]);
endmodule