SLIDE 10 Ones counter: datapath (struct)
component adder is port ( A : in std_logic_vector(7 downto 0); B : in std_logic_vector(7 downto 0); Y : out std_logic_vector(7 downto 0) ); end component; component zerodetect is port ( A : in std_logic_vector(7 downto 0); Y : out std_logic ); end component; signal A_out, A_in : std_logic_vector(7 downto 0); signal ONES_out, ONES_in: std_logic_vector(7 downto 0); signal adder1_out : std_logic_vector(7 downto 0); signal shifter_out : std_logic_vector(7 downto 0);
file: datapath.vhdl
Ones counter: datapath (struct)
begin
A : reg8 port map (CLK, rst_n, loadA, A_in, A_out); ONES : reg8 port map (CLK, rst_n, loadONES, ONES_in, ONES_out);
MUX_A: mux2x8 port map (selA, X, shifter_out, A_in);
MUX_ONES: mux2x8 port map ( selONES, (others => '0'), adder1_out, ONES_in ); SHIFTER : rshift port map (A_out, shifter_out);
ADDER1 : adder port map (ONES_out, "00000001", adder1_out);
LSB_A <= A_out(0); ZD : zerodetect port map(A_out, zA);
OUTP <= ONES_out; end struct;
file: datapath.vhdl
Ones counter
toplevel
interface control unit and datapath declarations instantiate control unit and datapath add signals to connect CTRL-DP
Ones counter: top level
library ieee; use ieee.std_logic_1164.all;
entity onescounter is port ( CLK, rst_n : in std_logic;
X : in std_logic_vector(7 downto 0);
OUTP : out std_logic_vector(7 downto 0);
DATAIN : in std_logic; CALC : in std_logic;
READY : out std_logic; OK : out std_logic ); end onescounter;
file: onescounter.vhdl