I am trying to write the VHDL code for a synchronous 16 bit register
(SIPO, asynchronous reset) to use it as a component in another Serial
Multiplier code.
I have been struggling with 'U' output on my signal:
code:
Omar Rashad wrote:> but I still get 'U'
Now the question arises: What is 'U'?
'U'ndefined, 'U'seless, 'U'ncertain, 'U'ninitilized?
1
reset<='1';load<='1';A<="1010101010101010";
2
waitfor320ns;
Shouldn't you do anything with load and reset afterwards?
After having managed that you will encounter serious problems with this
here:
1
architecturebehaviorofShiftRegisteris
2
signaltmp:std_logic_vector(15downto0);
3
begin
4
tmp<=(others=>'0');-- tmp is ALWAYS reset to all zero!
5
6
process(reset,clk)
7
begin
8
if(reset='1')then
9
Y<='0';
10
endif;
11
endprocess;
12
13
process(load,A)
14
begin
15
if(load='1')then
16
tmp<=A;-- ADDITIONALLY sometimes tmp gets the value of A
17
else
18
tmp<=(others=>'0');-- if not is is reset to zero ONCE MORE
19
endif;
20
endprocess;
21
22
process(clk)
23
begin
24
if(clk='1'andclk'EVENT)then
25
Y<=tmp(0);
26
tmp<='0'&tmp(15downto1);-- ADDITIONALLY sometimes its shifted with a clock
27
endif;
28
endprocess;
29
30
endbehavior;
All in all: you drive tmp from three sources. That will not work! it
will result in a collision. And
BTW: the very same is for Y! It is driven from two sources...
In fact you cannot reset Y because its the very same signal as tmp(0)!
Why should you need here a reset signal at all?
Try it that way and think hard about it:
Aren't all processes treated as concurrent statements within
architecure? So only when one of the elements in the sensitivity list
changes do they run again, correct? That means only processes with
changes in their SL will get re-evaluated. Do I understand this
correctly?
And the code that you provided (theoretically, I cannot simulate it now)
does not work as intended. This is because tmp is reset to A everytime
the process runs so we won't truly get the serial output of A, just
continuous A(0)'s.
Omar Rashad wrote:> So only when one of the elements in the sensitivity list> changes do they run again, correct? That means only processes with> changes in their SL will get re-evaluated. Do I understand this> correctly?
From the point of view how the Simulator calculates the result of each
process this is correct, but: The other processes that are not
re-evaluated still drive the signals (with the same not re-evaluated
values as before).
In fact, it is only the simulator that makes use of sensitivity lists
(to know when it needs to calculate new values). The hardware that
results from synthesis just permanently "is there".
Omar Rashad wrote:> Do I understand this correctly?
Just for the simulation this is (nearly) correct. But in hardware each
process is realized in parallel to each other process and "it" will
drive its value all the time...
> And the code that you provided (theoretically, I cannot simulate it now)> does not work as intended.
It works as far as my intention was: I load a value int the shift
register by assigning a value to A and setting load to '1'. AFTERWARDS
i set load to '0' and start clocking the data out. Got the trick?
And do you remeber my question:
Lothar Miller wrote:> reset <= '1'; load <= '1'; A <= "1010101010101010";> wait for 320 ns;> Shouldn't you do anything with load and reset afterwards?
Omar Rashad wrote:> But the assignment requires
Which one?
> that Load remains 1 when we are clocking out> an output and 0 if we want to clear the register.
And how do you LOAD data to the shift register? And if load also
clears the register: what is the reset for?
By assignment I was referring to my assignment
Reset clears the output to zero regardless of load. When reset is zero,
content is zero if load is zero and is filled with Din when load is one.
That is why load and A are in a separate process that is sensitive to
both but not reset or clock.
Omar Rashad wrote:> When reset is zero, content is zero if load is zero and is filled with> Din when load is one.
A very unusual behavior. For a pity there is no hardware inside a FPGA
able to handle such behavior...
> That is why load and A are in a separate process> that is sensitive to both but not reset or clock.
You think the wrong way! You cannot control hardware stucture with the
sensitivity list. The sensitivity lust is only relevant for the
simulator.
Omar Rashad wrote:> Can you show me a code you would write to describe a PISO 16 bit> register (clocked) ?
I did already. Tomorrow I will provide a simple testbench for it...
Ok, here we go.
My spec is:
1. when load is '1' then load the vector A to the shift register
2. when load is '0' then shift out the data bit LSB first through Y
And this is the result:
The PISO is synthesizeable and results in 16 D-Flipflops with
asynchronous clrear and preset inputs, which are controlled from A with
a little glue logic. See the RTL schematic for this result...