Go Back   Velocity Reviews > Newsgroups > VHDL
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply

VHDL - Shift Register Set and Feedback

 
Thread Tools Search this Thread
Old 07-06-2006, 12:34 PM   #1
Default Shift Register Set and Feedback


Hi, I'm new in VHDL. I' ve wriiten a code for a 41-stage pncode. My
question is how can i set an initial value on the output of some shift
registers before the process start, and then their values will change
sequentially as usual. I can do this by putting force values using
modelsim simulator but i want to make it using an input signal just as
reset. I would be grateful if anyone could help me.



Dimcliff
  Reply With Quote
Old 07-06-2006, 01:27 PM   #2
Srikanth
 
Posts: n/a
Default Re: Shift Register Set and Feedback

Dimcliff wrote:
> Hi, I'm new in VHDL. I' ve wriiten a code for a 41-stage pncode. My
> question is how can i set an initial value on the output of some shift
> registers before the process start, and then their values will change
> sequentially as usual. I can do this by putting force values using
> modelsim simulator but i want to make it using an input signal just as
> reset. I would be grateful if anyone could help me.


Initialize the shift register to a known value during reset.

  Reply With Quote
Old 07-06-2006, 01:28 PM   #3
D Stanford
 
Posts: n/a
Default Re: Shift Register Set and Feedback


Dimcliff wrote:
> Hi, I'm new in VHDL. I' ve wriiten a code for a 41-stage pncode. My
> question is how can i set an initial value on the output of some shift
> registers before the process start, and then their values will change
> sequentially as usual. I can do this by putting force values using
> modelsim simulator but i want to make it using an input signal just as
> reset. I would be grateful if anyone could help me.


your signal declarations can have an initial value, such as

signal my_signal : std_logic_vector(31 downto 0) := x"DEADBEEF";

  Reply With Quote
Old 07-06-2006, 02:09 PM   #4
Dimcliff
 
Posts: n/a
Default Re: Shift Register Set and Feedback


Ο/Η D Stanford *γραψε:
> your signal declarations can have an initial value, such as
>
> signal my_signal : std_logic_vector(31 downto 0) := x"DEADBEEF";



my registers output signal is reg. You mean that if i write

signal reg: std_logic_vector(40 downto 0) :=
"10000000000000000000000000000000000000000";

i can set the first flipflop on the left to '1'?
i tried something like that but i still had to force that value at the
beginning of simulation.
maybe i can't understand what you're telling me exactly.

  Reply With Quote
Old 07-06-2006, 03:05 PM   #5
Ricardo
 
Posts: n/a
Default Re: Shift Register Set and Feedback

Dimcliff escreveu:

>
> signal reg: std_logic_vector(40 downto 0) :=
> "10000000000000000000000000000000000000000";
>
> i can set the first flipflop on the left to '1'?


To 1, 0, Z and all others covered by std_logic, too. Read about signal
assignement.

> i tried something like that but i still had to force that value at the
> beginning of simulation.


For simulation and the very first time, yes, the signal will have that
value. But as soon your reset works, it will abandon the "declaration
start value" and get the "reset value" (or better: the first assignment
value). Avoid reset is a bad pratice, IMO.

> maybe i can't understand what you're telling me exactly.


Try http://tams-www.informatik.uni-hamburg.de/vhdl/ and google will
always be your friend.

  Reply With Quote
Old 07-07-2006, 08:52 AM   #6
Thomas Stanka
 
Posts: n/a
Default Re: Shift Register Set and Feedback


Dimcliff schrieb:

> Ο/Η D Stanford *γραψε:
> > your signal declarations can have an initial value, such as
> >
> > signal my_signal : std_logic_vector(31 downto 0) := x"DEADBEEF";

>
>
> my registers output signal is reg. You mean that if i write
>
> signal reg: std_logic_vector(40 downto 0) :=
> "10000000000000000000000000000000000000000";
> i can set the first flipflop on the left to '1'?
> i tried something like that but i still had to force that value at the
> beginning of simulation.


This should do (as long as the right side contains exactly 41 values).
A better way would be := (40 => '1', others => '0'); This safes you
from reg beiing uninitilised just because of a missing 0 (or one too
much).

But this is only for simulation purpose. It is always a good idea to
use a reset for setting the register in the desired state and apply
this reset at the beginning of your simulation.

Maybe you should also think about a sychron way to set the register
during normal operation with a load function

if rising_edge(clk) then
if load='1' then
reg <= (40 => '1', others => '0');
else
reg <= lfsr_shift(reg);
......

bye Thomas

  Reply With Quote
Old 07-09-2006, 09:32 AM   #7
Dimcliff
 
Posts: n/a
Default Re: Shift Register Set and Feedback

Thanks to everyone who answered my question.
Now everything works fine.

  Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump