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.

Question about shift register (VHDL)

Status
Not open for further replies.

mjvm171

Newbie level 5
Joined
May 5, 2011
Messages
8
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,332
Hello

I just to ask if my shift register code below is correct because the output that we get lacks one more shift..
example:

we need a data that looks like this 11111111 but the output we get is 01111111

Code:
begin
if (clk'event and clk = '1') then
if (TDRE = '1') then
dr <=iempty; 
dr <= Din;
end if;

if (RDRF ='1') then
dr<=sr;
Dout <= dr;
end if;

if (load = '1') then
sr <= dr;
elsif (shift = '1') then
sr <= (sr(6 downto 0) & core_rcve); --last rcved bit :research

end if;
end if;

Assistance is really appreciated

Thank you:grin:
 

sr looks like a shift register to me, using dr to load.
 

sr looks like a shift register to me, using dr to load.

yeah.. it's supposed to be a loading and unloading signal. Is that wrong? Should i just turn it to a buffer or something?

umm but anyways i did try to unload the contents of sr directly to Dout (Dout<=sr) but we still got 01111111 instead of 11111111...


I am really confused as to why this is happening..
 

its difficult to understand what you're talking about out of context. Theres nothing wrong with your code, and the problems you are having could happen for all sorts of reasons to do with inputs. I suspect its the inputs thats wrong, not the code.
 

its difficult to understand what you're talking about out of context. Theres nothing wrong with your code, and the problems you are having could happen for all sorts of reasons to do with inputs. I suspect its the inputs thats wrong, not the code.

hmm i see.. well then i'll have to check that but my input here is actually a data read from another device..

Nevertheless, Thanks for your answer.
 

have you testbenched this code?

yeah unfortunately the part where we get the 01111111 (the read command) can't be tested on a test bench, i guess, because the one responsible on giving data is the other device. It's the one pulling down the signal (pulled-up signal) that would be received by the shift register. We did test the write command though and it did work in the test bench and on the fpga.
 

Without knowing the input and expected output signal waveforms, nothing can be said.

I wonder, why the output is delayed by an additional clock cycle?
Code:
if (RDRF ='1') then
dr<=sr;
Dout <= dr;
end if;
 

Without knowing the input and expected output signal waveforms, nothing can be said.

I wonder, why the output is delayed by an additional clock cycle?
Code:
if (RDRF ='1') then
dr<=sr;
Dout <= dr;
end if;

is the additional clock cycle dr<=sr; ?

its supposed to be the data register. Hmm.. I'm kind of new in VHDL so I get lost most of the times ending with me not knowing what to do.
 

Also this part

if (clk'event and clk = '1') then
if (TDRE = '1') then
dr <=iempty;
dr <= Din;

end if;

dr will be assigned the value you wrote last which means that dr <=iempty; will be ignored.
Was one of the lines supposed to be sr and not dr?

Alex
 

Also this part

if (clk'event and clk = '1') then
if (TDRE = '1') then
dr <=iempty;
dr <= Din;

end if;

dr will be assigned the value you wrote last which means that dr <=iempty; will be ignored.
Was one of the lines supposed to be sr and not dr?

Alex

no.. i forgot to remove dr<= iempty lol my mistake. its just something to test the dr signal.

so you mean to say that it's better if I just make it Dout <= sr.. hmm do you have any suggestions on how i could make the data register because it seems like its delaying the signal and it might be a reason why the output is not shifted properly.

thank you
 

I assume that this code is inside a process, note that dr, sr are signals so

Code VHDL - [expand]
1
2
3
dr<=sr;  -- the sr value will be assigned the next time that the process in entered, dr will keep the same value it had when the process was entered
Dout <= dr;     -- that means that in this line you assign the "old" dr 
end if;



Alex
 
I assume that this code is inside a process, note that dr, sr are signals so

Code VHDL - [expand]
1
2
3
dr<=sr;  -- the sr value will be assigned the next time that the process in entered, dr will keep the same value it had when the process was entered
Dout <= dr;     -- that means that in this line you assign the "old" dr 
end if;



Alex

oh I see, I could now understand better thank you very much..
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top