网友的类8051的MCU_EBI接口

 1 /********************************************************************************************************* 
 2  **                                  All right reserve 2008-2009(C)  
 3  **                           Created & maintained by http://www.edaok.net 
 4  **======================================================================================================= 
 5  ** 模 块 名:   ebi 
 6  ** 描    述:   连接类似于8051MCU外部总线模块, 输出从外部总线上接收的地址, 数据, 写信号线信号, 主要为工 
 7  **             程中的其它模块提供外部总线的地址和数据 
 8  ** 
 9  ** 原 作 者:   Adeko (from http://www.edaok.net) 
10  ** 参 与 者:   (...welcome you join in) 
11  ** 
12  **======================================================================================================= 
13  ********************************************************************************************************/ 
14 module ebi ( 
15     clk, 
16  
17     ebi_ad,  
18     ebi_addr_h,  
19     ebi_wr_n,  
20     ebi_rd_n,  
21     ebi_ale,  
22  
23     we, 
24     data_in, 
25     data_out, 
26     addr_out 
27 ); 
28  
29 input               clk;                                        //  全局时钟 
30 inout   [7:0]       ebi_ad;                                     //  外部总线的地址/数据线 
31 input   [7:0]       ebi_addr_h;                                 //  外部总线高位地址线 
32 input               ebi_wr_n;                                   //  外部总线写信号线 
33 input               ebi_rd_n;                                   //  外部总线读信号线 
34 input               ebi_ale;                                    //  外部总线地址锁存信号线 
35  
36 output              we;                                         //  写信号线上升沿有效信号 
37 input   [7:0]       data_in;                                    //  将要发送到外部总线上的数据 
38 output  [7:0]       data_out;                                   //  从外部总线上接收的数据 
39 output  [15:0]      addr_out;                                   //  从外部总线得到的16位地址线 
40  
41  
42 /* 
43  *  综合成8位锁存器, 当ALE高电平时锁存数据, 锁存外部总线的地址低8位 
44  */ 
45 reg     [7:0]       rAddrL; 
46 wire    [15:0]      wAddr; 
47 always @(ebi_ale or ebi_ad) 
48 begin 
49     if (ebi_ale) begin 
50         rAddrL[7:0] <= ebi_ad[7:0]; 
51     end 
52 end 
53  
54 assign  wAddr[15:0] = {ebi_addr_h[7:0], rAddrL[7:0]};           //  和地址高8位组合比16位地址 
55  
56  
57 /* 
58  *  产生和全局时钟同步的'写'信号上升沿信号,提供其它模块作为写线有效, 可以进行 
59  *  数据读写 
60  */ 
61  
62 wire                wWrNeg; 
63 assign  wWrNeg = ~ebi_wr_n; 
64  
65  
66 /* 
67  *  输出端口 
68  */ 
69 assign  ebi_ad = (~ebi_rd_n)? data_in : 8'hzz;                  //  输出三态, 当''信号为高时输出数据 
70  
71 assign  addr_out[15:0] = wAddr[15:0];                           //  输出外部总线的地址 
72  
73 //assign  data_out[7:0]  = rData[7:0];                            //  输出外部总线锁存的数据 
74 assign  data_out[7:0]  = ebi_ad[7:0]; 
75  
76 assign  we = wWrNeg;                                            //  输出写线有效信号, 同步于全局时钟 
77  
78  
79 endmodule 
80  
81 /********************************************************************************************************* 
82  ** End Of File 
83  ********************************************************************************************************/

 

posted @ 2012-12-06 11:07  fishplj2000  阅读(476)  评论(0编辑  收藏  举报