Commit df166074 authored by Pascal Bos's avatar Pascal Bos

fixed the before-2000 <-> after-2000 bug.

parent 4871ea09
Pipeline #3921 failed with stage
in 2 minutes and 6 seconds
......@@ -282,6 +282,8 @@ date_register : process (clk_i, rst_n_i) is
variable remaining_days : unsigned(19 downto 0);
variable block_4_years : unsigned(39 downto 0);
variable all_rdy : std_logic_vector(4 downto 0);
variable before_2000 : boolean;
variable years_buffer : unsigned(39 downto 0);
begin
if rst_n_i = '0' then
seconds <= (others => '0');
......@@ -292,7 +294,8 @@ begin
sbs <= (others => '0');
enable_bcd_conv <= '0';
remaining_days := (others => '0');
block_4_years := (others => '0');
block_4_years := (others => '0');
before_2000 := false;
all_rdy := (others => '0');
elsif rising_edge(clk_i) then
if divider_output_valids(0) = '1' then --latch seconds
......@@ -311,18 +314,24 @@ begin
remaining_days := unsigned(remainders(3));
block_4_years := unsigned(quotients(3));
if remaining_days < 365 then
years <= std_logic_vector((block_4_years(37 downto 0) & "00") - 1 - 30);
years_buffer := (block_4_years(37 downto 0) & "00") - 1 ;
days <= std_logic_vector(remaining_days(8 downto 0)+1);
elsif remaining_days < 730 then
years <= std_logic_vector((block_4_years(37 downto 0) & "00") + 0 - 30 );
years_buffer := (block_4_years(37 downto 0) & "00") + 0;
days <= std_logic_vector(remaining_days(8 downto 0)-365+1);
elsif remaining_days < 1095 then
years <= std_logic_vector((block_4_years(37 downto 0) & "00") + 1 - 30);
years_buffer := (block_4_years(37 downto 0) & "00") + 1;
days <= std_logic_vector(remaining_days(8 downto 0)-730+1);
else
years <= std_logic_vector((block_4_years(37 downto 0) & "00") + 2 - 30);
years_buffer := (block_4_years(37 downto 0) & "00") + 2;
days <= std_logic_vector(remaining_days(8 downto 0)-1095+1);
end if;
if block_4_years <= 7 then
years_buffer := years_buffer + 70;
else
years_buffer := years_buffer - 30;
end if;
years <= std_logic_vector(years_buffer);
all_rdy(3) := '1';
end if;
if divider_output_valids(4) = '1' then --latch sbs
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment