[SOLVED] Shift register implementation and use of its value

Status
Not open for further replies.

This is how I have written:
Code:
parameter input_width = 8;
parameter bit_width = 1; //in this case to shift 1 bit at a time

input [input_width-1:0] input_data;
reg    [input_width-1:0] shift_reg;

always @(posedge CLK or negedge RST)
begin 
if (!RST) shift_reg <= input_data;
else       shift_reg <= {bit_width{1'b0}}, shift_reg[input_width-1:bit_width]};
end
I am running this code with different input_data values and it works. Even with different widths of "bit_width" it works by shifting. How could that be possible?
This is all the code thats related to this operation.
 



Notice there is a difference in the RHS of the two code snippets you posted (highlighted in red). The top one is not a shift register no matter how much you claimed it was.

The second is a shift register. You should proof read your code more carefully to avoid misunderstandings like this, or at a minimum READ others posts carefully so you can correct the mistake sooner.
 
Hello,

Sorry about that. I i will mark this question solved. Thanks for your help.
 

Status
Not open for further replies.

Similar threads

Cookies are required to use this site. You must accept them to continue using the site. Learn more…