DosPesos
Newbie level 1
Hello there! I am currently learning VHDL and am in the process of tying in all of my ports to make my top level design and I'm having trouble on how to essentially combine them with port maps to work under each condition.
We need to use 2 4 bit flip flops, a multiplexer, adder, and 2 Product registers (PH, PL) I was able to get each function working separately but am having trouble when i tie them all in together.
Do you guys have any tips or see anything blatantly wrong. Thanks again!
We need to use 2 4 bit flip flops, a multiplexer, adder, and 2 Product registers (PH, PL) I was able to get each function working separately but am having trouble when i tie them all in together.
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 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 library ieee; use ieee.std_logic_1164.all; use ieee.std_logic_1164.all; use ieee.std_logic_unsigned.all; use ieee.std_logic_arith.all; entity multiplier is port(clr,load_a, load_b,sf_b,ld_p,sf_p,clk: in std_logic; P: out std_logic_vector(7 downto 0)); end multiplier; architecture beh of multiplier is component dffa port(din:in std_logic_vector(3 downto 0); clr,clk,load:in std_logic; q: out std_logic_vector(3 downto 0)); end component; component dffb port(d: in std_logic_vector(3 downto 0); clk,load,clr, sb: in std_logic; qb0: out std_logic); end component; component mux port(d0, d1 :in std_logic_vector(3 downto 0); s: in std_logic; y: out std_logic_vector(3 downto 0)); end component; component adder port(a, b :in std_logic_vector(3 downto 0); res: out std_logic_vector(4 downto 0)); end component; component product port(sum:in std_logic_vector(4 downto 0); clr,clk,sb, load:in std_logic; Ph: out std_logic_vector(3 downto 0); Remain: out std_logic_vector (3 downto 0)); end component; component product2 port(Pcar:in std_logic_vector(3 downto 0); clk:in std_logic; Pl: out std_logic_vector(3 downto 0)); end component; signal A_reg,Zero,Y1, remainder, Preg, PP, Pr: std_logic_vector(3 downto 0); signal Addsum5: std_logic_vector(4 downto 0); signal carry: std_logic; signal A,B: std_logic_vector (3 downto 0); begin A <= "1011"; B <= "1101"; Zero <= "0000"; --remainder <= "0000"; g0: dffa port map(din => A, clr => clr, clk => clk, load => load_a, q => A_reg); g1: dffb port map(d => B, clk => clk, load => load_b, clr=> clr, sb => sf_b, qb0 => carry); g2: mux port map(d0 => Zero, d1 => A_reg,s => carry, y=> Y1); g3: adder port map(a => Y1, b=> remainder, res => Addsum5); g4: product port map(sum => Addsum5, clr => clr, clk => clk, sb => sf_p, load => ld_p, Remain => remainder, Ph => Preg); g5: product2 port map(Pcar => remainder, clk => clk, Pl => PP); process(clr,load_a, load_b,sf_b,ld_p,sf_p,clk) begin if(clr = '1') then P <= (others => '0'); elsif(rising_edge(clk)) then if(load_a = '1') then A_reg <= A(3 downto 0); elsif(load_b = '1') then B <= B(3 downto 0); elsif(sf_b = '1') then remainder <= "0000"; elsif(ld_p = '1') then remainder <= Addsum5(4 downto 1); elsif(sf_p = '1') then Pr <= '0'& Addsum5(3 downto 1); PP <= Pr(3 downto 0); end if; end if; end process; P(7 downto 4) <= Pr; P(3 downto 0) <= PP; end beh;
Do you guys have any tips or see anything blatantly wrong. Thanks again!