E
Eli Bendersky
Guest
Hello all,
In high level programming languages it's possible to shorten common
programming idioms by encapsulating them into functions / modules /
classes. It is similarly possible in simulation-aimed VHDL, but is much
more difficult in synthesis-aimed VHDL.
Here is one:
some_bus(31 downto 27) <= (others => '0');
some_bus(26) <= my_sig_3;
some_bus(25) <= my_sig_4;
some_bus(24 downto 20) <= (others => '0');
some_bus(19) <= my_sig_11;
some_bus(18 downto 2) <= (others => '0');
some_bus(1 downto 0) <= another_bus(1 downto 0);
I wish there sould be a way to just assign 'all zeros' to some_bus and
then the signals to relevant bits:
some_bus(31 downto 0) <= (others => '0');
some_bus(26) <= my_sig_3;
some_bus(25) <= my_sig_4;
some_bus(19) <= my_sig_11;
some_bus(1 downto 0) <= another_bus(1 downto 0);
This, unfortunately, doesn't work. Setting some_bus to 'L' also doesn't
work for synthesis (only simulation).
Another common idiom is seeing when a signal changed:
signal my_sig, my_sig_prev: std_logic;
....
....
process (clk, reset_n)
begin
if reset_n = '0' then
my_sig_prev <= '0';
elsif rising_edge(clk) then
my_sig_prev <= my_sig;
end if;
end process;
And then:
some process:
....
if rising_edge(clk) then
if my_sig_prev /= my_sig then
...
....
How can this be shortened, in synthesis ? I find myself writing this or
similar code (checking for a rise, or fall, of my_sig, for instance, by
(my_sig = '0' and my_sig_prev = '1') for fall) too many times !
Eli
....
In high level programming languages it's possible to shorten common
programming idioms by encapsulating them into functions / modules /
classes. It is similarly possible in simulation-aimed VHDL, but is much
more difficult in synthesis-aimed VHDL.
Here is one:
some_bus(31 downto 27) <= (others => '0');
some_bus(26) <= my_sig_3;
some_bus(25) <= my_sig_4;
some_bus(24 downto 20) <= (others => '0');
some_bus(19) <= my_sig_11;
some_bus(18 downto 2) <= (others => '0');
some_bus(1 downto 0) <= another_bus(1 downto 0);
I wish there sould be a way to just assign 'all zeros' to some_bus and
then the signals to relevant bits:
some_bus(31 downto 0) <= (others => '0');
some_bus(26) <= my_sig_3;
some_bus(25) <= my_sig_4;
some_bus(19) <= my_sig_11;
some_bus(1 downto 0) <= another_bus(1 downto 0);
This, unfortunately, doesn't work. Setting some_bus to 'L' also doesn't
work for synthesis (only simulation).
Another common idiom is seeing when a signal changed:
signal my_sig, my_sig_prev: std_logic;
....
....
process (clk, reset_n)
begin
if reset_n = '0' then
my_sig_prev <= '0';
elsif rising_edge(clk) then
my_sig_prev <= my_sig;
end if;
end process;
And then:
some process:
....
if rising_edge(clk) then
if my_sig_prev /= my_sig then
...
....
How can this be shortened, in synthesis ? I find myself writing this or
similar code (checking for a rise, or fall, of my_sig, for instance, by
(my_sig = '0' and my_sig_prev = '1') for fall) too many times !
Eli
....