-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpiso.vhd
More file actions
76 lines (66 loc) · 1.9 KB
/
Copy pathpiso.vhd
File metadata and controls
76 lines (66 loc) · 1.9 KB
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
library ieee;
use ieee.std_logic_1164.all;
entity piso is
generic ( n : integer := 24);
port( ext_clk: in std_logic;
reset: in std_logic;
enable: in std_logic; --enables shifting
fb_mem_addr: out std_logic_vector(15 downto 0);
fb_mem_data: in std_logic_vector(15 downto 0);
dac0_data: out std_logic; --serial output
sync: out std_logic := '1';
dac_clk: out std_logic;
leds: out std_logic_vector(3 downto 0)
);
end piso;
architecture behavioral of piso is
signal temp_reg: std_logic_vector(n-1 downto 0) := (others => '0');
TYPE POSSIBLE_STATES IS (waiting, shifting);
signal state : POSSIBLE_STATES;
begin
dac_clk <= ext_clk;
fb_mem_addr <= x"ffff";
leds(0) <= enable;
leds(2) <= '0';
leds(3) <= '1';
process(ext_clk,reset)
variable shift_counter: integer := 0;
begin
if(reset = '1') then
temp_reg <= (others => '0');
state <= waiting;
shift_counter := 0;
sync <= '1';
elsif(rising_edge(ext_clk)) then
case state is
when waiting =>
shift_counter := 0;
temp_reg <= "00000000" & fb_mem_data;
dac0_data <= '0';
sync <= '1';
if(enable = '1') then
state <= shifting;
else
state <= waiting;
end if;
when shifting =>
shift_counter := shift_counter + 1;
dac0_data <= temp_reg(n-1);
temp_reg <= temp_reg(n-2 downto 0) & '0';
sync <= '0';
if (shift_counter >= n or enable = '0') then
state <= waiting;
else
state <= shifting;
end if;
when others =>
null;
end case;
if(state = shifting) then
leds(1) <= '1';
else
leds(1) <= '0';
end if;
end if;
end process;
end behavioral;