-
Notifications
You must be signed in to change notification settings - Fork 0
/
multiple.vhd.bak
63 lines (49 loc) · 1.46 KB
/
multiple.vhd.bak
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
library ieee;
use ieee.numeric_std.all;
use ieee.std_logic_1164.all;
use ieee.math_real.all;
library work;
use work.components.all;
entity ls_multiple is
generic(input_width: integer := 8);
port(
input: in std_logic_vector(input_width-1 downto 0);
ena, clk, set_zero: in std_logic;
valid, invalid_next: out std_logic;
address: out std_logic_vector(integer(ceil(log2(real(input_width))))-1 downto 0));
end entity;
architecture basic of ls_multiple is
signal reg_in, reg_out, reg_temp: std_logic_vector(input_width-1 downto 0);
signal reg_ena, not_zero: std_logic;
signal addr: std_logic_vector(address'length-1 downto 0);
component p_encoder is
port (PEReg : std_logic_vector(7 downto 0);
PE_out : OUT std_logic_vector(2 downto 0);
PE0 : OUT STD_LOGIC);
end component;
begin
PE_out <= addr;
PE: p_encoder
port map(PEReg => reg_out, PE_out => addr, PE0 => valid);
reg_ena <= ena or set_zero;
data_in: process(input, set_zero, reg_out, reg_temp, addr)
begin
reg_temp <= reg_out;
reg_temp(to_integer(unsigned(addr))) <= '0';
if(unsigned(reg_temp) = 0) then
invalid_next <= '1';
else
invalid_next <= '0';
end if;
if (set_zero = '1') then
reg_in <= reg_temp;
else
reg_in <= input;
end if;
end process;
T: reg_process
generic map(input_width)
port map(
Din => reg_in, Dout => reg_out,
clk => clk, ena => reg_ena);
end architecture;