V
valentin tihomirov
Guest
The following snippet of code is working only for widths > 2. Here is the
description of the process. The WIDTH specifies a fifo's input vector width.
A buffer of WIDTH-1 bits wide forestalls the input of fifo. Bits are coming
one-by-one from Rx and are shifted into buffer. When buffer is loaded, fifo
reads the vector, whereby upper bit is taken directly from Rx line.
SHIFT_IN: process(CLK, RESET, SHIFTING, Rx)
variable Buf: std_logic_vector(WIDTH-2 downto 0);
begin
FIFO_IN <= Rx & Buf(WIDTH-2 downto 0);
if Rising_Edge(CLK) and ENABLE = '1' then
if SHIFTING then
Buf := Rx & Buf(WIDTH-2 downto 1);
end if;
end if;
end process;
WIDTH = 1 is not allowed because we get vector(-1 downto 0). Buf should have
length 0 in this case. Compiler sumbles at Rx & Buf(0 downto 1) when
WIDTH=2. The situations like
for I := 0 downto 1 do
are handeled in any general-purpose programming language by not entering
into the loop. What is the proper way to describe the HW in VHDL? The
process must work for WIDTH > 0.
description of the process. The WIDTH specifies a fifo's input vector width.
A buffer of WIDTH-1 bits wide forestalls the input of fifo. Bits are coming
one-by-one from Rx and are shifted into buffer. When buffer is loaded, fifo
reads the vector, whereby upper bit is taken directly from Rx line.
SHIFT_IN: process(CLK, RESET, SHIFTING, Rx)
variable Buf: std_logic_vector(WIDTH-2 downto 0);
begin
FIFO_IN <= Rx & Buf(WIDTH-2 downto 0);
if Rising_Edge(CLK) and ENABLE = '1' then
if SHIFTING then
Buf := Rx & Buf(WIDTH-2 downto 1);
end if;
end if;
end process;
WIDTH = 1 is not allowed because we get vector(-1 downto 0). Buf should have
length 0 in this case. Compiler sumbles at Rx & Buf(0 downto 1) when
WIDTH=2. The situations like
for I := 0 downto 1 do
are handeled in any general-purpose programming language by not entering
into the loop. What is the proper way to describe the HW in VHDL? The
process must work for WIDTH > 0.