Electrical Engineering Stack Exchange is a question and answer site for electronics and electrical engineering professionals, students, and enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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


share|improve this question
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
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

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]; 
share|improve this answer

Your Answer


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.