Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

store LSB after shift right - vhdl

Status
Not open for further replies.

fanwel

Full Member level 3
Full Member level 3
Joined
May 26, 2011
Messages
178
Helped
2
Reputation
4
Reaction score
2
Trophy points
1,298
Activity points
2,878
Hi,

In my project I need to right shift an input vector by one. For example I have A=0101. Then right shift by one I get Q=0010. Now, I want to store the LSB of the input vector in this case is bit '1'. How to do the operation for store the LSB value? There is no problem to write vhdl code for the right shift operation, but I don't know how to write for the store LSB operation :-(. Can anyone give idea or advice. Many thanks
 

You mean how to access individual bits of a vector?
You can use A(0) or A(1) or A(1 downto 0) etc
 

You mean how to access individual bits of a vector?
You can use A(0) or A(1) or A(1 downto 0) etc

Hi alexan_e,

Actually I want to store the LSB until reach 4 values (from different input vector). Then the output will be a vector of (3 downto 0). Is it possible? If yes, how can I do that? Thanks
 

The concatenation operator is & so you can use

Code:
Q<= A(0) & B(0) & C(0) & D(0);
 

The concatenation operator is & so you can use

Code:
Q<= A(0) & B(0) & C(0) & D(0);

Hi alexan,

I understand your above idea. But, the input is of std_logic data type, whilst the output is of std_logic_vector data type. Many thanks for your response
 

If the input (A,B,C,D) is std_logic then just use

Code:
Q<= A & B & C & D;

I assume Q is 4 bit wide, if not you can assign a sub range using
Code:
Q(3 downto 0)<= A & B & C & D;
 

If the input (A,B,C,D) is std_logic then just use

Code:
Q<= A & B & C & D;

I assume Q is 4 bit wide, if not you can assign a sub range using
Code:
Q(3 downto 0)<= A & B & C & D;

Hi alexan_e,

Yes, I understand that. How to wait the input to reach four value from one value before the output with four bit width is come out.I attach the figure for the component.Many thanks for response
 

Attachments

  • problm.JPG
    problm.JPG
    6.7 KB · Views: 125

You can use a state machine of some kind that assign the vector bits, one at a time each time there is a shift

something like
first step QLSB(3)<= Q(0)
second step QLSB(2)<= Q(0)
third step QLSB(1)<= Q(0)
fourth step QLSB(0)<= Q(0)

where QLSB will be the resulting vector
 

You can use a state machine of some kind that assign the vector bits, one at a time each time there is a shift

something like
first step QLSB(3)<= Q(0)
second step QLSB(2)<= Q(0)
third step QLSB(1)<= Q(0)
fourth step QLSB(0)<= Q(0)

where QLSB will be the resulting vector

Hi alexan_e,

Thanks for give an idea. I will try the code. Many thanks
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top