OpenCores
URL https://opencores.org/ocsvn/pdp1/pdp1/trunk

Subversion Repositories pdp1

[/] [pdp1/] [trunk/] [rtl/] [vhdl/] [display.vhd] - Blame information for rev 3

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 3 yannv
----------------------------------------------------------------------------------
2
-- Company: 
3
-- Engineer: 
4
-- 
5
-- Create Date:    19:20:52 03/03/2009 
6
-- Design Name: 
7
-- Module Name:    display - Behavioral 
8
-- Project Name: 
9
-- Target Devices: Spartan-3A starter kit SPI DAC
10
-- Tool versions: 
11
-- Description:    Oscilloscope output module for PDP-1.
12
--
13
-- Dependencies: 
14
--
15
-- Revision: 
16
-- Revision 0.01 - File Created
17
-- Additional Comments: 
18
--
19
----------------------------------------------------------------------------------
20
library IEEE;
21
use IEEE.STD_LOGIC_1164.ALL;
22
use IEEE.STD_LOGIC_ARITH.ALL;
23
use IEEE.STD_LOGIC_UNSIGNED.ALL;
24
 
25
---- Uncomment the following library declaration if instantiating
26
---- any Xilinx primitives in this code.
27
--library UNISIM;
28
--use UNISIM.VComponents.all;
29
 
30
entity display is
31
    Port ( X : in  STD_LOGIC_VECTOR (0 to 9);
32
           Y : in  STD_LOGIC_VECTOR (0 to 9);
33
           CLK : in  STD_LOGIC;
34
           TRIG, DOPULSE : in  STD_LOGIC;
35
           DONE : out  STD_LOGIC := '0';
36
 
37
                          SPI_MOSI, DAC_CS, SPI_SCK, DAC_CLR : out STD_LOGIC);
38
end display;
39
 
40
architecture Behavioral of display is
41
        signal command : std_logic_vector(23 downto 6) := (others=>'1');
42
        shared variable Xin, Yin : std_logic_vector(0 to 9) := (others=>'0');
43
        shared variable newval, dodone : boolean := false;
44
begin
45
        DAC_CLR <= '1';
46
        SPI_SCK <= not CLK;
47
        SPI_MOSI <= command(command'left);
48
 
49
        process(CLK)
50
                constant exposure : integer := 50*50;   -- 50MHz clock, 50µs exposure
51
                variable Xidle, Yidle : std_logic_vector(0 to 9) := (others=>'0');
52
                variable count : integer range 0 to exposure := 0;
53
                type direction is (left, up, right, down);
54
                variable dir : direction := right;
55
        begin
56
                if rising_edge(CLK) then
57
                        if TRIG='1' then
58
                                if X(0)='1' then
59
                                  Xin(1 to Xin'right) := X(1 to X'right)+1;
60
                                else
61
                                  Xin(1 to Xin'right) := X(1 to X'right);
62
                                end if;
63
                                Xin(0) := not X(0);
64
                                if Y(0)='1' then
65
                                  Yin(1 to Yin'right) := Y(1 to Y'right)+1;
66
                                else
67
                                  Yin(1 to Yin'right) := Y(1 to Y'right);
68
                                end if;
69
                                Yin(0) := not Y(0);
70
                                newval := true;
71
                                count := 0;
72
                                dodone := DOPULSE='1';
73
                        end if;
74
                        case count is
75
                                when 0=>
76
                                        DONE <= '0';
77
                                        DAC_CS <= '0';
78
                                        if newval then  -- channel 3 does X, set without update
79
                                                command <= x"03" & Xin;
80
                                        else
81
                                                case dir is
82
                                                        when right =>
83
                                                                Xidle := Xidle+1;
84
                                                                if Xidle="1111111111" then
85
                                                                        dir:=up;
86
                                                                end if;
87
                                                        when up =>
88
                                                                Yidle := Yidle+1;
89
                                                                if Yidle="1111111111" then
90
                                                                        dir:=left;
91
                                                                end if;
92
                                                        when left =>
93
                                                                Xidle := Xidle-1;
94
                                                                if Xidle="0000000000" then
95
                                                                        dir:=down;
96
                                                                end if;
97
                                                        when down =>
98
                                                                Yidle := Yidle-1;
99
                                                                if Yidle="0000000000" then
100
                                                                        dir:=right;
101
                                                                end if;
102
                                                end case;
103
                                                command <= x"03" & Xidle;
104
                                        end if;
105
                                        count:=count+1;
106
                                when 24=>
107
                                        DAC_CS <= '1';
108
                                        count:=count+1;
109
                                when 25=>
110
                                        if newval then          -- channel 2 is Y, update all DACs
111
                                                command <= x"22" & Yin;
112
                                        else
113
                                                command <= x"22" & Yidle;
114
                                        end if;
115
                                        DAC_CS <= '0';
116
                                        count:=count+1;
117
                                when 25+24=>
118
                                        DAC_CS <= '1';
119
                                        if newval then
120
                                                count:=count+1;
121
                                        else
122
                                                count := 0;
123
                                        end if;
124
                                when exposure =>
125
                                        if dodone then
126
                                                DONE <= '1';
127
                                        end if;
128
                                        newval := false;
129
                                        count := 0;
130
                                when others =>          -- shift out command bits
131
                                        command <= command(command'left-1 downto command'right)&'1';
132
                                        count := count+1;
133
                        end case;
134
                end if;
135
        end process;
136
end Behavioral;

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.