-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDIG_IN.vhd
41 lines (33 loc) · 871 Bytes
/
DIG_IN.vhd
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
-- DIG_IN.VHD (a peripheral module for SCOMP)
-- This module reads digital inputs directly
LIBRARY IEEE;
LIBRARY LPM;
USE IEEE.STD_LOGIC_1164.ALL;
USE LPM.LPM_COMPONENTS.ALL;
ENTITY DIG_IN IS
PORT(
CS : IN STD_LOGIC;
IO_WRITE : IN STD_LOGIC;
DI : IN STD_LOGIC_VECTOR(15 DOWNTO 0);
IO_DATA : INOUT STD_LOGIC_VECTOR(15 DOWNTO 0)
);
END DIG_IN;
ARCHITECTURE a OF DIG_IN IS
SIGNAL B_DI : STD_LOGIC_VECTOR(15 DOWNTO 0);
BEGIN
-- Use LPM function to create bidirectional I/O data bus
IO_BUS: lpm_bustri
GENERIC MAP (
lpm_width => 16
)
PORT MAP (
data => B_DI,
enabledt => CS AND (NOT IO_WRITE),
tridata => IO_DATA
);
PROCESS
BEGIN
WAIT UNTIL RISING_EDGE(CS);
B_DI <= DI; -- sample the input on the rising edge of CS
END PROCESS;
END a;