About Black Matrix FPGA+USB Starter Kit~~~

参考设计之一:初始程序(包括LED,BTN,LCD;VHDL源码部分)

上一篇 / 下一篇  2008-06-10 22:56:10 / 个人分类:参考设计

EDA中国门户网站 S&_i^_l e

-- 黑色矩阵 FPGA+USB 开发板 参考设计之一:初始程序
V1URM+O2s-[^6SzP0-- 用于测试开发板的基本功能模块,包括:LED,BTN, LCDEDA中国门户网站 OUC!R1B;`8su
--
2Da,i2~H0--
kBK4QIW H0-- Reference design - Initial design for Black Matrix FPGA+USB Starter Kit when delivered.
:}4k(V,\P0--
#~9U%yS;M]S;M0-- Email: spartan3@163.com
7N%s,O'nE^0--EDA中国门户网站C}k)n4j G
-- All rights reserved.EDA中国门户网站yy9Q;u @DZe bcR
--EDA中国门户网站6K#_ b|3~ ^ dO
-- Introduction:EDA中国门户网站&u+AW:OGq
--EDA中国门户网站jf"h9uJ4B Sd
-- This design use LED, BTN and LCD to show the board is working OK!EDA中国门户网站,n5y j:F? `
--EDA中国门户网站$Z"O4hH0Us
-- PicoBlaze is included.EDA中国门户网站\.hG|i,c.hx
--EDA中国门户网站IxJ4t Q5] Hq
--
E.KG2M|!M rV!i0-- Library declarationsEDA中国门户网站y?VrN9T8W!f/ha
--
CD"dX8}*Y(t*D']"Uw0-- Standard IEEE libraries
P&wl {:p.S0--
2rS1b2d1GE:C0library IEEE;
9X\*u V:Ye(I2E0use IEEE.STD_LOGIC_1164.ALL;
c$g N1trw+V0use IEEE.STD_LOGIC_ARITH.ALL;
!I1GZ.X5w0use IEEE.STD_LOGIC_UNSIGNED.ALL;
C(q|*q&R0? F#E Z0--EDA中国门户网站A2L)R F/k&K8e
------------------------------------------------------------------------------------
7Cd7AM)OJ0--
,BH/`uc0--EDA中国门户网站tR2n${-HT1d$K)^0X(c
entity blackmatrix_startup isEDA中国门户网站3Z0ykQ4s
    Port (             led : out std_logic_vector(3 downto 0);EDA中国门户网站F oW#['rvd"p
                   led_sys : out std_logic;EDA中国门户网站&da\7vjEz+pZ
                   btn_rst : in std_logic;
%mh&zq7[+pV0                  btn_left : in std_logic;EDA中国门户网站&F4T s tn [;A\!k
                 btn_right : in std_logic;
Y%M&M[2Bwd0                     lcd_d : inout std_logic_vector(7 downto 4);EDA中国门户网站6[5yX8l/a
                    lcd_rs : out std_logic;
0B3j Z*aH/Z0                    lcd_rw : out std_logic;EDA中国门户网站i(G_%@'WA%_4C
                     lcd_e : out std_logic;EDA中国门户网站QG1cMX
                       clk : in std_logic);EDA中国门户网站9v+IB;w+G-zftt
    end blackmatrix_startup;
$}9`AdB+}0--
^Z h'U Vw&X;tx0------------------------------------------------------------------------------------EDA中国门户网站NT L:^%l!d|$D
--
]'N)` ^I#D,I*o0-- Start of test architectureEDA中国门户网站3r*B@}l$o[| \
--EDA中国门户网站uW!mkk M!n
architecture Behavioral of blackmatrix_startup is
i)U&b1ipMe?5w0--
:CHkKob1F0q0------------------------------------------------------------------------------------
ct~kb9x}Pq0--
T!M*x9wQ;J0-- declaration of KCPSM3
q\^{({:B0--
j0R?A8e0  component kcpsm3 EDA中国门户网站+C mX7u5ATJ?f@
    Port (      address : out std_logic_vector(9 downto 0);EDA中国门户网站8s^J _ t?*AJ
            instruction : in std_logic_vector(17 downto 0);EDA中国门户网站 M K3Jq&f2[ |
                port_id : out std_logic_vector(7 downto 0);EDA中国门户网站#I0x}ZqCQ
           write_strobe : out std_logic;
r1N"EXN0               out_port : out std_logic_vector(7 downto 0);EDA中国门户网站(H:L,Yt.ug
            read_strobe : out std_logic;EDA中国门户网站\ Q6m+`6]?
                in_port : in std_logic_vector(7 downto 0);EDA中国门户网站4t,Zq$[0QT'\
              interrupt : in std_logic;
,cj[X P0          interrupt_ack : out std_logic;
'o7o7NX0J6i"_A0_V0                  reset : in std_logic;
3v a7k^kZ*d:z0                    clk : in std_logic);
R;rg6}k|Jg0    end component;EDA中国门户网站!X6pY+y)|;l
--
B0^Y-d0RQC0Z0-- declaration of program ROM
];Q(s y l;_y0--
:s A9n)k5E&jH0  component control
{(I[']W5g(Jc&\0    Port (      address : in std_logic_vector(9 downto 0);EDA中国门户网站X-zS:IXSId)f%V D
            instruction : out std_logic_vector(17 downto 0);EDA中国门户网站7Z6Ufq!EVV2CYV'e
             proc_reset : out std_logic;                       --JTAG Loader versionEDA中国门户网站7R8z'`*{1Gm"H
                    clk : in std_logic);EDA中国门户网站 McP DgojN3c0W|C
    end component;
(N+Sy }/?u0--EDA中国门户网站?},@#}n#F { {a-A\9a
------------------------------------------------------------------------------------EDA中国门户网站o*[2a6ATa0w"Dq G@%Q
--EDA中国门户网站7Ym;r ]5xh U?\
-- Signals used to connect KCPSM3 to program ROM and I/O logicEDA中国门户网站D z&SLz:s d?D-q
--
U bAwRT0signal address          : std_logic_vector(9 downto 0);
FD}(l oo$G,t0signal instruction      : std_logic_vector(17 downto 0);EDA中国门户网站.uD-` R/b.tbj
signal port_id          : std_logic_vector(7 downto 0);
(f ]A&i;i0signal out_port         : std_logic_vector(7 downto 0);EDA中国门户网站 ``Fq8JE4t:H}
signal in_port          : std_logic_vector(7 downto 0);
/_C(iK k#x'x*Y v8I?m0signal write_strobe     : std_logic;EDA中国门户网站C)[%}eD"@}5N1|$\s&n P
signal read_strobe      : std_logic;
\P'f1Qrs'C*Nh1H0signal interrupt        : std_logic :='0';EDA中国门户网站8brhfap
signal interrupt_ack    : std_logic;EDA中国门户网站$J;tC-H;j
signal interrupt_event  : std_logic;EDA中国门户网站 j7wrn&g)A^2Z$H
--EDA中国门户网站IQ8? Gztt~
--EDA中国门户网站:P%xo/wb|
-- Signals for LCD operation
7d#^2Bmrz5a H0--EDA中国门户网站Y(M-P!d!|
-- Tri-state output requires internal signalsEDA中国门户网站8m W3a b n@o
-- 'lcd_drive' is used to differentiate between LCD and StrataFLASH communications EDA中国门户网站&W"smpY:M/Q
-- which share the same data bits.EDA中国门户网站forhg oF Q
--EDA中国门户网站z@%t~o8y
signal   lcd_rw_control : std_logic;
!F_G `/JJv v0signal  lcd_output_data : std_logic_vector(7 downto 4);EDA中国门户网站Jgt*DP3]
signal        lcd_drive : std_logic;
f"~Z;h5p,q(p7a0--EDA中国门户网站p s c(@$@-wc#JM*M%s
--EDA中国门户网站@5ZR*hzl!QD
--EDA中国门户网站K*aH Mq+nr
------------------------------------------------------------------------------------------------------------------------------------------------------------------------
#{4LW8Va7fE3K0--EDA中国门户网站Zt3h9i tW2WM
-- Start of circuit descriptionEDA中国门户网站,v"Se:B`C
--EDA中国门户网站O6H-vd7y7e[A
begin

[7wZJ,u4FD7f0 EDA中国门户网站\9o yg`cDA9^[8g

  ----------------------------------------------------------------------------------------------------------------------------------EDA中国门户网站x+m|L V|g/S
  -- KCPSM3 and the program memory EDA中国门户网站}Hj Tp)~7|
  ----------------------------------------------------------------------------------------------------------------------------------
J Z;Z cCJ0x0o+S:q a0  --EDA中国门户网站(}Hm)Y|ZD

|gi6Z-gE"u0  processor: kcpsm3
0U zb&?#|JP)I$\0    port map(      address => address,EDA中国门户网站:Yy)s8SR+_J
               instruction => instruction,EDA中国门户网站Mq;t6g8wZ%y L
                   port_id => port_id,
CitH0^/A0              write_strobe => write_strobe,EDA中国门户网站*h j7qK8]O1O
                  out_port => out_port,
d/CHgAj)t5UDp0               read_strobe => read_strobe,
5oeA@\N,aW0                   in_port => in_port,EDA中国门户网站v/Q%Tp LrBt
                 interrupt => interrupt,EDA中国门户网站;@7S)@3MB0v
             interrupt_ack => interrupt_ack,EDA中国门户网站5J"o k@:h![&RK
                     reset => btn_rst,
;l`1ZYx,I)x0                       clk => clk);
-{0V!u R tC0 
{+w0H]j.v0  program_rom: control
`FB[ s s @8l0    port map(      address => address,EDA中国门户网站a1z$Z(o FX
               instruction => instruction,EDA中国门户网站*Pav*p x6]D'M p+h
                proc_reset => btn_rst,                      
MO ^)cc"TGt-V;y0                       clk => clk);

"L ByW'xy)d3zx0

f!EkbQ.fzJ4}/A0  --EDA中国门户网站9C0j3y2F"C`,o2J
  ----------------------------------------------------------------------------------------------------------------------------------
sj0ss2Y:k3L/?0  -- Interrupt
tA8|Q`5|paK`0  ----------------------------------------------------------------------------------------------------------------------------------EDA中国门户网站.Wt`z9B
  --
?#v;M T)O0  --
7v8t*R [3hA0  -- Interrupt is used to detect rotation of the rotary encoder.
Jt[ R8N0  -- It is anticipated that the processor will respond to interrupts at a far higher EDA中国门户网站$Z{B7A;X~c
  -- rate that the rotary control can be operated and hence events will not be missed.
V'uUc5y}7~o`0  --

+AC+H;@ M:z8c0

?1a%\bor0  interrupt_control: process(clk)
y\'l jo/K0  begin
tF4PF7m:_0    if clk'event and clk='1' thenEDA中国门户网站 [g;j(K5z

cGf/NG Q0      -- processor interrupt waits for an acknowledgementEDA中国门户网站;xl5M$L*N.^8K)rr
      if interrupt_ack='1' then
\]4lzXy0         interrupt <= '0';EDA中国门户网站Y!?NLj$B'V
        elsif interrupt_event='1' then
9M%V B{7hZk-l0         interrupt <= '1';
,}Wj['@da5a S0        else
1^*B{^k@&[0         interrupt <= interrupt;
r-DN+f&zz7[(P0      end if;

r5k6a&Zj$[&v0 EDA中国门户网站pCWa!M{%eW

    end if; EDA中国门户网站}-] Y$|T.?l h B
  end process interrupt_control;

[S Q0f#Lx.?Z v0

m J{^E5F0  --EDA中国门户网站Z8cN7^ lir
  ----------------------------------------------------------------------------------------------------------------------------------EDA中国门户网站b9j!L8]nWf;a` B
  -- KCPSM3 input ports
?x T$hQV0  ----------------------------------------------------------------------------------------------------------------------------------EDA中国门户网站I.fe_lf
  --EDA中国门户网站 WtRQP,l
  --EDA中国门户网站Y Nsh$N G
  -- The inputs connect via a pipelined multiplexer
)h)\{6Z7S Q5d}G[0  --

'Xm8~zOC0 EDA中国门户网站&cS a'r(s N/d.C

  input_ports: process(clk)EDA中国门户网站 _&II@P5G}:R
  beginEDA中国门户网站/E U)l#Rg'SY;NX
    if clk'event and clk='1' then

J~.z0v5x9F(d0 EDA中国门户网站HWk*h4z ub1b2bz w\

      case port_id(1 downto 0) is

rB%^ k Zz0 EDA中国门户网站 e|V'ApWK.s"Qxp_

        -- read simple buttons at address 00 hex
6q Lz$l U|9y Sl0        when "00" =>    in_port <=  "000000" & btn_right & btn_left;

gP!X._$pY'W PO0

(CA$z/Q(A+oz$q]0        -- read rs232 datain at address 01 hexEDA中国门户网站U2H6f/ReX'J
        -- will include laterEDA中国门户网站}&J{9z F7B%c(e
        -- when "01" =>    in_port <=  uart_dout;

#Z+j _3BJ&gs/_-G2{0

;zHx^0A3`0
T:ZDb%?3H[7y$g0        when thers =>    in_port <= "XXXXXXXX";  EDA中国门户网站C OXo&|3~

EDA中国门户网站O*{V@+h#O!Zt

      end case;

4S:Cr x0T y0

3pXB:` {n6o8K2| zj0     end if;EDA中国门户网站AA y Z H

*Hg3LZ0B F e0  end process input_ports;EDA中国门户网站+`S/z Q(]g.q

EDA中国门户网站 ]C*z&^e{D\E2_Q


8ra];NZ'W@i ]LK0  --EDA中国门户网站s(H5p~tL
  ----------------------------------------------------------------------------------------------------------------------------------EDA中国门户网站%zu r{wT2hSz[
  -- KCPSM3 output ports
NJ4PRhr.Y0  ----------------------------------------------------------------------------------------------------------------------------------EDA中国门户网站*R1x0Al~;^$gEt J
  --

JL%^ hFeJ!Vx2e0

L!c.FhP)w8jg0  -- adding the output registers to the processorEDA中国门户网站oU X_)Ac
   EDA中国门户网站sEGp U7h x$bS
  output_ports: process(clk)
i9~2^TZ0  beginEDA中国门户网站B;K_ A#}{#F7J.n9Xh,Pn

EDA中国门户网站p3w*n'L vZt:j

    if clk'event and clk='1' thenEDA中国门户网站 yG^/z-z${o
      if write_strobe='1' thenEDA中国门户网站,Q&D#B)d2l^

EDA中国门户网站-s)_g.k1Nlfzj

        -- Write to LEDs at address 80 hex.EDA中国门户网站4N i{,h ^w8sk%N

#z&]DO!qemX0        if port_id(7)='1' thenEDA中国门户网站 m T;\4fN%[`
          led <= out_port(3 downto 0);EDA中国门户网站{2j*NZ%^2L
          led_sys <= out_port(4);EDA中国门户网站 Zme2l*O
        end if;

'RO C5rh7}:FbS5p|.l1A0

cU[nO4PG.Z0        -- LCD data output and controls at address 40 hex.EDA中国门户网站]_D8SsC| \@

EDA中国门户网站8|fsN N(m3w

        if port_id(6)='1' thenEDA中国门户网站*{ w,[K3f/I*G9W
          lcd_output_data <= out_port(7 downto 4);EDA中国门户网站9xl-ySGsj W%l
          lcd_drive <= out_port(3); 
~4f`_u#l}d#G5[1_0          lcd_rs <= out_port(2);
(PZ;re2Br"b,S0          lcd_rw_control <= out_port(1);EDA中国门户网站u2v/h3l(F&Ez&F/O
          lcd_e <= out_port(0);
$|1H ENuO"K0        end if;

1ku+b1ERX2Q*T"z&F0 EDA中国门户网站/{rnm4o^U.E4N U

      end if;

e'`b Z'QrF0 EDA中国门户网站 J$XLn4vR+TA7^3d0}

    end if;

h(Pi"p,[$R\h0

6QF Z)i H;uy0  end process output_ports;EDA中国门户网站-df8[k K&y+x

EDA中国门户网站;j*@uX~0I$Z

  --EDA中国门户网站gh'uR&g
  ----------------------------------------------------------------------------------------------------------------------------------
k;X7l9]-H }0  -- LCD interface  EDA中国门户网站/H&}FZ `
  ----------------------------------------------------------------------------------------------------------------------------------
1p+H1f o/]A+j"~Ls4A0  --EDA中国门户网站7z1ehP5p zh*O
  -- The 4-bit data port is bidirectional.EDA中国门户网站vp&k |F*YO)d
  -- lcd_rw is '1' for read and '0' for write EDA中国门户网站[ ["go5{{
  -- lcd_drive is like a master enable signal which prevents either the
!\2N4~5Xb0  -- FPGA outputs or the LCD display driving the data lines.EDA中国门户网站&g.pV s$kG@;q
  --
V\K1l0Wf W0  --Control of read and write signal
R$k j/uB]q4h0  lcd_rw <= lcd_rw_control and lcd_drive;EDA中国门户网站6jSh ~;r

EDA中国门户网站K ciZX"Z&h-L6C;R

  --use read/write control to enable output buffers.EDA中国门户网站#N.Z^l,G k7Q&B
  lcd_d <= lcd_output_data when (lcd_rw_control='0' and lcd_drive='1') else "ZZZZ";

U5H6XSh)q!kbC0

&E+@*rV1zD5O0 EDA中国门户网站#PB"d hgu/}9a!k

EDA中国门户网站N#`.u W?+mI

  --EDA中国门户网站{ ~&|9Y Z*d
  --
:V^)d[c!c%z6L0  --
6^$`~%K9PW T4]0end Behavioral;

}L*C\L:cn0

p-Gc1S`2A#j3VQ,b1W0------------------------------------------------------------------------------------------------------------------------------------
h?sp$uj{3T"Zg0--
OA,Jh"V }Kf5F0-- END OF FILE blackmatrix_startup.vhdEDA中国门户网站 C.GzCJ/h%sY
--
+]6E ivo*Y0------------------------------------------------------------------------------------------------------------------------------------EDA中国门户网站k:F$CRP

EDA中国门户网站~ Hf1y"pYR4B

 EDA中国门户网站+yG:bl(KN2Q)n


TAG: FPGA Fpga fpga USB usb 参考设计

引用 删除 tzhucq   /   2008-09-29 10:17:13
加一点中文说明啊!
 

评分:0

我来说两句

显示全部

:loveliness: :handshake :victory: :funk: :time: :kiss: :call: :hug: :lol :'( :Q :L ;P :$ :P :o :@ :D :( :)

日历

« 2009-01-06  
    123
45678910
11121314151617
18192021222324
25262728293031

数据统计

  • 访问量: 4101
  • 日志数: 18
  • 建立时间: 2008-05-22
  • 更新时间: 2008-06-13

RSS订阅

Open Toolbar