R
Rune Christensen
Guest
Hello
I'm looking for examples of extracting carry, borrow and overflow from an
adder in VHDL.
I have used this code to extract carry:
architecture Behavioral of freq_meas_and_pps_detection is
signal counterold : std_logic_vector(26 downto 0);
signal counternew : std_logic_vector(27 downto 0);
begin
counternew <= ('0' & counterold) + 1;
pps_detected <= not counternew(27);
p_freq_pps : process(rst, clk)
begin
if (rst = '1') then
freq <= X"FFFF_FF" & "111";
elsif (clk'event and clk = '1') then
if (pps_pulse = '1') then
freq <= counternew(26 downto 0);
end if;
end if;
if (clk'event and clk = '1') then
if (pps_pulse = '1') then
counterold <= X"0000_00" & "000";
-- counternew(27) is identical to carry out
elsif (counternew(27) = '0') then
counterold <= counternew(26 downto 0);
end if;
end if;
end process p_freq_pps;
end Behavioral;
Is there another way to extract the status flags from an adder? Maybe a more
easy way?
Thanks
Rune Christensen
I'm looking for examples of extracting carry, borrow and overflow from an
adder in VHDL.
I have used this code to extract carry:
architecture Behavioral of freq_meas_and_pps_detection is
signal counterold : std_logic_vector(26 downto 0);
signal counternew : std_logic_vector(27 downto 0);
begin
counternew <= ('0' & counterold) + 1;
pps_detected <= not counternew(27);
p_freq_pps : process(rst, clk)
begin
if (rst = '1') then
freq <= X"FFFF_FF" & "111";
elsif (clk'event and clk = '1') then
if (pps_pulse = '1') then
freq <= counternew(26 downto 0);
end if;
end if;
if (clk'event and clk = '1') then
if (pps_pulse = '1') then
counterold <= X"0000_00" & "000";
-- counternew(27) is identical to carry out
elsif (counternew(27) = '0') then
counterold <= counternew(26 downto 0);
end if;
end if;
end process p_freq_pps;
end Behavioral;
Is there another way to extract the status flags from an adder? Maybe a more
easy way?
Thanks
Rune Christensen