library IEEE; use IEEE.STD_LOGIC_1164.all; use IEEE.NUMERIC_STD.all; use WORK.OSSS_PKG.all; entity gcd is port ( clk : in BOOLEAN ; reset : in BOOLEAN ; go_i : in BOOLEAN ; x_i : in UNSIGNED ( 31 downto 0 ) ; y_i : in UNSIGNED ( 31 downto 0 ) ; done_o : out BOOLEAN ; r_o : out UNSIGNED ( 31 downto 0 ) ) ; end entity gcd ; architecture BEHAVIOUR of gcd is signal run_state : UNSIGNED ( 2 downto 0 ) ; begin run : process ( clk ) constant FOSSY_const_0_150137 : UNSIGNED ( 2 downto 0 ) := UNSIGNED' ( "000" ) ; constant FOSSY_const_1_150147 : UNSIGNED ( 2 downto 0 ) := UNSIGNED' ( "001" ) ; constant FOSSY_const_2_150138 : UNSIGNED ( 2 downto 0 ) := UNSIGNED' ( "010" ) ; constant FOSSY_const_3_150139 : UNSIGNED ( 2 downto 0 ) := UNSIGNED' ( "011" ) ; constant FOSSY_const_4_150140 : UNSIGNED ( 2 downto 0 ) := UNSIGNED' ( "100" ) ; constant FOSSY_const_5_150141 : UNSIGNED ( 2 downto 0 ) := UNSIGNED' ( "101" ) ; variable x_150111 : UNSIGNED ( 31 downto 0 ) ; variable y_150125 : UNSIGNED ( 31 downto 0 ) ; variable FOSSY_temp_tmpForSwitch_150128 : UNSIGNED ( 2 downto 0 ) ; variable FOSSY_temp_flatten_expr_150129 : SIGNED ( 33 downto 0 ) ; variable FOSSY_temp_flatten_expr_150130 : STD_LOGIC_VECTOR ( 31 downto 0 ) ; variable FOSSY_temp_flatten_expr_150131 : SIGNED ( 33 downto 0 ) ; variable FOSSY_temp_flatten_expr_150132 : STD_LOGIC_VECTOR ( 31 downto 0 ) ; variable FOSSY_temp_flatten_expr_150133 : SIGNED ( 33 downto 0 ) ; variable FOSSY_temp_flatten_expr_150134 : STD_LOGIC_VECTOR ( 31 downto 0 ) ; variable FOSSY_temp_flatten_expr_150135 : SIGNED ( 33 downto 0 ) ; variable FOSSY_temp_flatten_expr_150136 : STD_LOGIC_VECTOR ( 31 downto 0 ) ; begin if ( clk ' event AND clk = TRUE ) then if FOSSY_EQ_B1_B1 ( reset , TRUE ) then run_state <= FOSSY_const_0_150137 ; run_state <= FOSSY_const_2_150138 ; else FOSSY_temp_tmpForSwitch_150128 := ( run_state ) ; case TO_INTEGER ( FOSSY_temp_tmpForSwitch_150128 ) is when 1 => if FOSSY_LOG_AND_B1_B1 ( go_i , FOSSY_NEQ_U32_U32 ( x_150111 , y_150125 ) ) then if FOSSY_GT_U32_U32 ( x_150111 , y_150125 ) then FOSSY_temp_flatten_expr_150129 := ( FOSSY_SUB_U32_U32 ( x_150111 , y_150125 ) ) ; FOSSY_temp_flatten_expr_150130 := ( FOSSY_RANGE_S34_32 ( FOSSY_temp_flatten_expr_150129 , 31 ) ) ; x_150111 := ( UNSIGNED ( ( SIGNED ( FOSSY_temp_flatten_expr_150130 ) ) ) ) ; else FOSSY_temp_flatten_expr_150131 := ( FOSSY_SUB_U32_U32 ( y_150125 , x_150111 ) ) ; FOSSY_temp_flatten_expr_150132 := ( FOSSY_RANGE_S34_32 ( FOSSY_temp_flatten_expr_150131 , 31 ) ) ; y_150125 := ( UNSIGNED ( ( SIGNED ( FOSSY_temp_flatten_expr_150132 ) ) ) ) ; end if; run_state <= FOSSY_const_3_150139 ; else if go_i then r_o <= x_150111 ; done_o <= TRUE ; else end if; run_state <= FOSSY_const_4_150140 ; end if; when 2 => run_state <= FOSSY_const_5_150141 ; when 3 => if FOSSY_LOG_AND_B1_B1 ( go_i , FOSSY_NEQ_U32_U32 ( x_150111 , y_150125 ) ) then if FOSSY_GT_U32_U32 ( x_150111 , y_150125 ) then FOSSY_temp_flatten_expr_150133 := ( FOSSY_SUB_U32_U32 ( x_150111 , y_150125 ) ) ; FOSSY_temp_flatten_expr_150134 := ( FOSSY_RANGE_S34_32 ( FOSSY_temp_flatten_expr_150133 , 31 ) ) ; x_150111 := ( UNSIGNED ( ( SIGNED ( FOSSY_temp_flatten_expr_150134 ) ) ) ) ; else FOSSY_temp_flatten_expr_150135 := ( FOSSY_SUB_U32_U32 ( y_150125 , x_150111 ) ) ; FOSSY_temp_flatten_expr_150136 := ( FOSSY_RANGE_S34_32 ( FOSSY_temp_flatten_expr_150135 , 31 ) ) ; y_150125 := ( UNSIGNED ( ( SIGNED ( FOSSY_temp_flatten_expr_150136 ) ) ) ) ; end if; run_state <= FOSSY_const_3_150139 ; else if go_i then r_o <= x_150111 ; done_o <= TRUE ; else end if; run_state <= FOSSY_const_4_150140 ; end if; when 4 => if go_i then run_state <= FOSSY_const_4_150140 ; else done_o <= FALSE ; run_state <= FOSSY_const_5_150141 ; end if; when 5 => if not ( go_i ) then run_state <= FOSSY_const_5_150141 ; else x_150111 := ( x_i ) ; y_150125 := ( y_i ) ; run_state <= FOSSY_const_1_150147 ; end if; when others => NULL ; end case; end if; end if; end process run ; end architecture BEHAVIOUR;