Take the 2-minute tour ×
Electrical Engineering Stack Exchange is a question and answer site for electronics and electrical engineering professionals, students, and enthusiasts. It's 100% free, no registration required.

i am designing a basic AES algorithm on verilog, and i need to split a 1828 bits array into 16 parts each one of 8 bits, for example (basic no 128 length example), if i receive in my 8 to 2 splitter module 10111011 i need to generate 4 outputs 10 11 10 11

Thanks

share|improve this question
1  
You will likely get better answers if you capitalize and have better grammar. Also check you numbers, I don't think you meant 1828 bits. –  Brian Carlton Nov 28 '12 at 0:01
add comment

2 Answers 2

up vote 2 down vote accepted

The easiest way, if you don't need to parameterize stuff, would be to use binding, i.e. { }.

For your example using an 8-bit input_sig, you could do this in the following way:

reg [1:0] part0, part1, part2, part3;
always @(input_sig)
   {part3, part2, part1, part0} = input_sig;

That last line essentailly makes one big wire out of each part and assigns input_sig to the new wire bitwise (just like if the new wire was any other 8-bit wire). So if input_sig was 10111011: part3 = 10, part2 = 11, part1 = 10, and part0 = 11.

You can then you can manipulate the parts as you wish. If you do care about parameters, you could use a for loop, but the logic might get a tad complex (at least for my tastes). This solution won't be too cumbersome even for splitting a signal into 16 parts.

share|improve this answer
add comment

You should be able to get away without a for loop if parameterization is the need of the hour.

Something like,

reg [`param1:0] part0, part1, part2, part3;

always @(input_sig) begin
  part0 <= input_signal [`param1:0];
  part1 <= input_signal [2*param1:param1+1]; 
  part2 <= input_signal [3*param1:2*param1+1]; 
  part3 <= input_signal [4*param1:3*param1+1]; 
end
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.