Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

VHDL noobie 4 by 4 Sequential multiplier help

Status
Not open for further replies.

DosPesos

Newbie level 1
Joined
Mar 6, 2016
Messages
1
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
31
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.


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!
 

Would help to better analyze your program if you could show a draft of the circuit that you want to implement, and also inform exactly what the problem is occurring. Perhaps needless to say, the actual circuit synthesized on the FPGA chip will not necessarily have the same structure of the code, once each target may have slightly different cells.
 

Some signals have multiple drivers: P, A_reg, B, PP.
Preg is not used.
Some signals are not needed in the sensitivity list: load_a, load_b, sf_b, ld_p, sf_p.
Some signals do not have resets: A, B, remainder, Pr, PP.

Other advice would be to avoid std_logic_arith/unsigned or only import specific functions. std_logic_unsigned.all will also import the "=" comparison operator which changes the meaning of comparisons between std_logic_vectors of different length.

Also, I've never seen anyone place the infrastructure -- clk, clr -- in the middle of the port map. They are usually first or last depending on local coding standards.

I also wonder if you are not using the clocked process correctly. I wasn't entirely sure what you wanted it to do. It seems to try to do some of the same things as the components.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top