0

i have 130 bit data vector blocks where 2 bits are header bits and 128 bits are data bits ,header bits can be anywhere in the 130 bit vector, i have to process 128 bits which come after the header bits ,if header is detected somewhere middle in the 130 bit vector, suppose at 60th position then i have to process 60 bits of current vector block and 68 bits of next vector block . i was trying to fix the initial offset after which header comes in the data vector but for that there will be 128 cases for worst case scenario where header comes at the end of data vector,i want to ask is there any other better approach than using cases?

1 Answer 1

2

Keep a vector of 130 bits, and use it as a shift register. As you have to load at least 130 bits until you begin to process header and data, keep searching for the header at positions 128 and 129 of that vector (the two leftmost bit positions). When the header is detected, the next 128 bits already loaded in your 130 bit register, is data.

Something like:

parameter HEADER = 2'b11;  // just a guess
reg [129:0] shreg = 130'b0;

always @(posedge clk) begin
  if (rst == 1'b1)
    shreg <= 130'b0;
  else if (shreg[129:128] == HEADER) begin
    // process data
    // ...
    // after processing, remove it from the shift register
    shreg <= {129'b0,datain};
  end
  else
    shreg <= {shreg[128:0], datain};
end
Sign up to request clarification or add additional context in comments.

3 Comments

what if i have to output 128 bits after header (either 01 or 10) is detected and check for next header because it is fixed that next header will come 128 bits after its previous header , every time when a header is found the data should be processed according to header and go to output port accordingly, this logic will not work in that case because for that i have to fixed the number after which the first header is detected.
Next header will begin exactly 128 bits after last detected header, or at least 128 bits after the last detected header?
I've added code to remove processed data from the shift register, so new header will enter from the right, and 128 bits (or more) later, it will be detected again

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.