mina.nms
Junior Member level 3
- Joined
- Sep 1, 2010
- Messages
- 29
- Helped
- 1
- Reputation
- 2
- Reaction score
- 1
- Trophy points
- 1,283
- Activity points
- 1,468
hi
would you plz help me?
what is the problem with this vhdl code for dividing two numbers by state machine?
Thanks
would you plz help me?
what is the problem with this vhdl code for dividing two numbers by state machine?
Thanks
Code VHDL - [expand] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 library IEEE; use IEEE.STD_LOGIC_1164.ALL; use IEEE.numeric_STD.ALL; entity divi is Port ( a,b : in STD_LOGIC_VECTOR (15 downto 0); clk,e_in,res : in STD_LOGIC; e_out : out STD_LOGIC; div_out : out STD_LOGIC_VECTOR (15 downto 0); mod_out : out STD_LOGIC_VECTOR (15 downto 0)); end divi; architecture Behavioral of divi is type state is (init,divid); signal s_reg, s_next : state; signal div1,b1,dive : Unsigned (15 downto 0); signal mod1,mode: Unsigned (15 downto 0); begin process (clk,res) begin if (res ='1') then s_reg <= init; elsif (clk'event and clk='1') then s_reg <= s_next; end if; end process; process (s_reg,div1) begin case s_reg is when init => div1 <="0000000000000000"; b1 <= unsigned (b) ; mod1 <= unsigned (a) ; e_out<='0'; --if (e_in ='1') then s_next <= divid; -- end if; when divid => if (mod1>=0)then mod1<=mod1-b1; div1<=div1+1; else mode<=mod1+b1; dive<=div1-1; --div_out <= STD_LOGIC_VECTOR (dive); --mod_out <= STD_LOGIC_VECTOR (mode); e_out <='1'; --s_next <= init; end if; end case; end process; end Behavioral;
Last edited by a moderator: