T
Tomas
Guest
Hi,
I'm implementing a very simple memory with serial input in vhdl.
The serial bus I use is a simple SPI: I first receive the instruction
(read,write,erase) then the address then I send/receive data.
But I'm having some latches warning I would like to remove.
I'm using a FSM to model the memory, here is part of the code:
FSM: process (STATE)
variable TMP_RECV_INST:std_logic_vector(7 downto 0);
variable TMP_RECV_ADDR:std_logic_vector(15 downto 0);
variable TMP_RECV_DATA:std_logic_vector(7 downto 0);
begin
NEXTSTATE<=STATE;
case STATE is
when FS_RECV_INST => if curr_indx/=inst_length-1 then
TMP_RECV_INST(curr_indx):=SI; -- SI is the serial input
curr_indx:=curr_indx+1;
NEXTSTATE<=FS_RECV_INST;
else
curr_indx:=0;
NEXTSTATE<=FS_RECV_ADDR;
end if ;
SO<='Z';
when FS_RECV_ADDR => if curr_indx/=addr_length then
and so on
I'm getting a 1-bit latches warning on each tmp_recv_inst index
(because I'm probably changing only 1 bit at a time?). I even tried to
put TMP_RECV_INST(curr_indx):=SI; before the beginning of the if
clause just to test and see if the problem was that tmp_recv_inst
wasn't assigned in both if and else blocks. But the warning was still
there.
The only way I could think about to avoid this latches warning is
this:
change
variable TMP_RECV_INST:std_logic_vector(7 downto 0); to variable
tmp_recv_inst: integer range 0 to 2**7;
and instead of TMP_RECV_INST(curr_indx):=SI; use
tmp_recv_inst=tmp_recv_inst+2**curr_indx;
I'm a real VHDL beginner so I don't know if this *workaround* is
usable and what are the pros and cons.
Thanks for help,
Tomas
I'm implementing a very simple memory with serial input in vhdl.
The serial bus I use is a simple SPI: I first receive the instruction
(read,write,erase) then the address then I send/receive data.
But I'm having some latches warning I would like to remove.
I'm using a FSM to model the memory, here is part of the code:
FSM: process (STATE)
variable TMP_RECV_INST:std_logic_vector(7 downto 0);
variable TMP_RECV_ADDR:std_logic_vector(15 downto 0);
variable TMP_RECV_DATA:std_logic_vector(7 downto 0);
begin
NEXTSTATE<=STATE;
case STATE is
when FS_RECV_INST => if curr_indx/=inst_length-1 then
TMP_RECV_INST(curr_indx):=SI; -- SI is the serial input
curr_indx:=curr_indx+1;
NEXTSTATE<=FS_RECV_INST;
else
curr_indx:=0;
NEXTSTATE<=FS_RECV_ADDR;
end if ;
SO<='Z';
when FS_RECV_ADDR => if curr_indx/=addr_length then
and so on
I'm getting a 1-bit latches warning on each tmp_recv_inst index
(because I'm probably changing only 1 bit at a time?). I even tried to
put TMP_RECV_INST(curr_indx):=SI; before the beginning of the if
clause just to test and see if the problem was that tmp_recv_inst
wasn't assigned in both if and else blocks. But the warning was still
there.
The only way I could think about to avoid this latches warning is
this:
change
variable TMP_RECV_INST:std_logic_vector(7 downto 0); to variable
tmp_recv_inst: integer range 0 to 2**7;
and instead of TMP_RECV_INST(curr_indx):=SI; use
tmp_recv_inst=tmp_recv_inst+2**curr_indx;
I'm a real VHDL beginner so I don't know if this *workaround* is
usable and what are the pros and cons.
Thanks for help,
Tomas