Hi! I am writing a code for a serializer. The problem is that I have
only 1s as output but I want to see the input bitstream, obviously. Do
you have any suggestion? Thanks.
The code is the following:
Have a look what a for loop does in Verilog: it produces parallel
hardware. It looks like you expect something entirely different.
BTW:
I assume this here:
1
for(i=0;i<12;i=i+1)
2
temp_data_out[i]<=data_in[i];
Could be cut down to one line:
1
temp_data_out<=data_in;
But I may be completely wrong because I'm doing VHDL usually... ;-)
you toggle "load" at #13 and #15, but your clock toggles with #5 (and
rising edges with 10). I think you will miss easily signals in that
style
improve your testbench with:
1
@(posedgeclk)
2
load=1;
3
@(posedgeclk)
4
load=0;
furthermore:
1
for(j=0;j<12;j=j+1)
2
data_out<=temp_data_out[j];
3
4
// is the same like
5
data_out<=temp_data_out[11];
In a N-serializer you have to use a 1-bit clock and your inputs stays at
the correct time every N cycles or for N cycles.
Hi! For what concern the tesbench, in the simulation result I can see
that when load is high, it returns to 0 after 15 ns. So, it is high for
at least 1 clock cycle.
If I write
1
data_out <= temp_data_out[11];
how I can see as output the whole bit stream? In this way I can see only
temp_data_out[11] and not all the bits in that array
This is basically what the serializer should do, shifting out the bits.
Also, in hardware the for loops are unrolled and so all happens in one
clock cycle and the last assignment wins. In your case, the second for
loop always results to 'data_out <= temp_data_out[11]'. Discard the for
loops and try like this:
1
always @ (posedge clk)
2
begin
3
if (rst) begin
4
data_out <= 1'b0;
5
temp_data_out <= 12'b0;
6
end
7
else if (load)
8
temp_data_out <= data_in; //take over the vector
9
else if (send)
10
data_out <= temp_data_out[11]; //assert the MSBit of the vector at output
11
temp_data_out <= {temp_data_out[10:0], 1'b0}; //shift the vector by one bit per cycle
Yes you are absolutely righ, I commented that line because I was not
sure (I am new in programming so maybe it is easier for me think with
for loop..!) but I was thinking again about it and you confirmed my
thought. Thank you very much!
Atalin wrote:> I am new in programming
Don't think you are "programming" like a software programmer writes a
program for a computing device. What you are doing is "describing"
hardware using a HDL (Hardware Description Language). So at first you
must have a "picture" of that hardware on a sheet of paper or at least
in your brain. Then you can describe it with Verilog (or VHDL or
whatsoever).
By doing this don't let you betray by "false friends" like that
"for-loop" in the posts above.
VHDL hotline wrote:> This is basically what the serializer should do, shifting out the bits
But of course this serializer also could be done with a 12:1
multiplexer. So with each clock a counter must count up and then this
counter can be used for indexing the desired bit.
Hi guys! I am here again for asking some help. Here I have the testbench
of the serializer (I slightly modify it in order to have random bits as
input). I would like to add a kind of receiver (like a serial-in
parallel-out register) in order to check automatically if the input
parallel data are equal to the output. How can I do this? Thanks