C
Carlos Barberis
Guest
As you can see I am fairly new to the verilog hdl, I have been trying to
create a small functional module using an altera Max7000 series CPLD to take
in a 16 bit serial stream and convert it to a 16 bit parallel out. I have
checked my input serial stream with a logic analyzer and my data reads
correctly and all control signals are in their proper place, however my
parallel conversion in the CPLD always comes out incorrect; I am sending out
a 16 bit serial data word MSB first, when I send in a 0b0000000000000001 (1)
I see a 0b0000000000000011 (3) when I send a: 0b0000000000000010 (2) I see a
0b0000000000001100 (12) when I send a: 0b0000000000000011 (3)
I see a: 0b0000000000001111 (15)....and so on.
***************************** This is my verilog code
*****************************************************
module serial_to_parallel ( parallel_out, serial_in, shift_enable, clock,
reset_n);
parameter SIZE = 16;
output[SIZE-1:0] parallel_out;
input serial_in;
input shift_enable;
input clock;
input reset_n;
reg[SIZE-1:0] tempdata;
reg[SIZE-1:0] parallel_out;
always @(posedge clock or negedge reset_n) begin
if (~reset_n)
tempdata <= 0;
else if(~shift_enable)
tempdata <= {tempdata[SIZE-2:0],serial_in};
parallel_out = tempdata;
end
endmodule
******************************************************************************************************
I tried changing; tempdata <= {tempdata[SIZE-1:1],serial_in}; but when I
do this the only thing I see in parallel_out is just the lsb turning on and
off for odd values
Any help or hints would be greatly appreciated.......Thank you!
create a small functional module using an altera Max7000 series CPLD to take
in a 16 bit serial stream and convert it to a 16 bit parallel out. I have
checked my input serial stream with a logic analyzer and my data reads
correctly and all control signals are in their proper place, however my
parallel conversion in the CPLD always comes out incorrect; I am sending out
a 16 bit serial data word MSB first, when I send in a 0b0000000000000001 (1)
I see a 0b0000000000000011 (3) when I send a: 0b0000000000000010 (2) I see a
0b0000000000001100 (12) when I send a: 0b0000000000000011 (3)
I see a: 0b0000000000001111 (15)....and so on.
***************************** This is my verilog code
*****************************************************
module serial_to_parallel ( parallel_out, serial_in, shift_enable, clock,
reset_n);
parameter SIZE = 16;
output[SIZE-1:0] parallel_out;
input serial_in;
input shift_enable;
input clock;
input reset_n;
reg[SIZE-1:0] tempdata;
reg[SIZE-1:0] parallel_out;
always @(posedge clock or negedge reset_n) begin
if (~reset_n)
tempdata <= 0;
else if(~shift_enable)
tempdata <= {tempdata[SIZE-2:0],serial_in};
parallel_out = tempdata;
end
endmodule
******************************************************************************************************
I tried changing; tempdata <= {tempdata[SIZE-1:1],serial_in}; but when I
do this the only thing I see in parallel_out is just the lsb turning on and
off for odd values
Any help or hints would be greatly appreciated.......Thank you!