shaiko
Advanced Member level 5
Thanks Kevin,
My own code has evolved into something very similar:
Would you agree that it basically does the same thing?
My own code has evolved into something very similar:
Code:
library ieee ;
use ieee.std_logic_1164.all ;
use ieee.numeric_std.all ;
use ieee.math_real.all ;
entity frame_assembler is
generic
(
messages_per_frame : positive := 3 ;
bits_per_symbol : positive := 2 ;
symbols_per_message : positive := 2
) ;
port
(
IN_CLOCK : in std_logic ;
IN_RESET : in std_logic ;
IN_VALID : in std_logic ;
IN_EMPTY : in unsigned ( positive ( ceil ( log2 ( real ( symbols_per_message + 1 ) ) ) ) - 1 downto 0 ) ;
IN_DATA : in std_logic_vector ( bits_per_symbol * symbols_per_message - 1 downto 0 ) ;
OUT_DATA : out std_logic_vector ( bits_per_symbol * symbols_per_message * messages_per_frame - 1 downto 0 )
) ;
end entity frame_assembler ;
architecture synthesizable_frame_assembler of frame_assembler is
constant bits_per_message : positive := bits_per_symbol * symbols_per_message ;
constant bits_per_frame : positive := bits_per_message * messages_per_frame ;
signal number_of_valid_symbols : unsigned ( positive ( ceil ( log2 ( real ( symbols_per_message + 1 + 1 ) ) ) ) - 1 downto 0 ) ;
signal number_of_valid_bits : unsigned ( positive ( ceil ( log2 ( real ( IN_DATA ' length + 1 ) ) ) ) - 1 downto 0 ) ;
signal current_bit : unsigned ( positive ( ceil ( log2 ( real ( OUT_DATA ' length + 1 ) ) ) ) - 1 downto 0 ) ;
signal next_bit : unsigned ( positive ( ceil ( log2 ( real ( OUT_DATA ' length + 1 ) ) ) ) - 1 downto 0 ) ;
signal long_data : std_logic_vector ( OUT_DATA ' range ) ;
begin
number_of_valid_symbols <= symbols_per_message - resize ( IN_EMPTY , number_of_valid_symbols ' length ) ;
number_of_valid_bits <= resize ( bits_per_symbol * number_of_valid_symbols , number_of_valid_bits ' length) ;
next_bit <= current_bit + resize ( number_of_valid_bits , current_bit ' length ) ;
process ( IN_CLOCK , IN_RESET ) is
begin
if IN_RESET = '1' then
current_bit <= ( others => '0' ) ;
OUT_DATA <= ( others => '0' ) ;
elsif rising_edge ( IN_CLOCK ) then
if IN_VALID = '1' then
current_bit <= next_bit ;
for i in 0 to ( bits_per_message - 1 ) loop
for j in 0 to ( bits_per_frame - 1 ) loop
if j >= current_bit then
OUT_DATA ( i + j ) <= IN_DATA ( i ) ;
end if ;
end loop ;
end loop ;
end if ;
end if ;
end process ;
end architecture synthesizable_frame_assembler ;
Would you agree that it basically does the same thing?