找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
查看: 4379|回复: 0
打印 上一主题 下一主题
收起左侧

vhdl驱动lcd解决了ISE联合modelsim仿真看不见波形的问题

[复制链接]
跳转到指定楼层
楼主
本帖最后由 liuqq 于 2015-5-19 23:07 编辑

搞一个月解决了ISE联合modelsim仿真看不见波形的问题,写了一整天代码,最后结果还是有点问题,明天找老师帮忙吧~
  1. ----------------------------------------------------------------------------------
  2. library IEEE;
  3. use IEEE.STD_LOGIC_1164.ALL;
  4. use IEEE.STD_LOGIC_ARITH.ALL;
  5. use IEEE.STD_LOGIC_UNSIGNED.ALL;
  6. ---- Uncomment the following library
  7. declaration if instantiating
  8. ---- any Xilinx primitives in this code.
  9. --library UNISIM;
  10. --use UNISIM.VComponents.all;
  11. entity LCDb is
  12. Port ( clk : in STD_LOGIC;--48MHZ
  13. reset : in STD_LOGIC;
  14. display : in STD_LOGIC;
  15. xck : out STD_LOGIC;--6MHz
  16. din : in STD_LOGIC_VECTOR(2 downto 0);
  17. dout : out STD_LOGIC_VECTOR(7
  18. downto 0));
  19. end LCDb;
  20. architecture LCDb_arch of LCDb is
  21. signal sram1 :std_LOGIC_VECTOR(8 downto 0)
  22. :="000000000";--数据寄存器
  23. signal sram2 :std_LOGIC_VECTOR(8 downto 0)
  24. :="000000000";
  25. signal sram3 :std_LOGIC_VECTOR(8 downto 0)
  26. :="000000000";
  27. signal sram4 :std_LOGIC_VECTOR(8 downto 0)
  28. :="000000000";
  29. signal sram5 :std_LOGIC_VECTOR(8 downto 0)
  30. :="000000000";
  31. signal sram6 :std_LOGIC_VECTOR(8 downto 0)
  32. :="000000000";
  33. signal sram7 :std_LOGIC_VECTOR(8 downto 0)
  34. :="000000000";
  35. signal sram8 :std_LOGIC_VECTOR(8 downto 0)
  36. :="000000000";
  37. signal a : STD_LOGIC :='0';--系??分频用
  38. signal b : integer range 0 to 3;--系统分频用clk八分频得到xck
  39. signal c : integer range 0 to 72;--寄存器数据写入计数
  40. signal d : integer range 0 to 9;--寄存器数据读出计数
  41. begin
  42. xck<=a;
  43. process(clk)
  44. variable a_a :integer range 0 to 3;
  45. begin
  46. if(reset='1') then
  47. if(clk'event and clk='0') then
  48. if(a_a=3) then
  49. a_a:=0;
  50. a<=not a;
  51. else
  52. a_a:=a_a+1;
  53. end
  54. if;
  55. end if;
  56. end if;
  57. end process;
  58. process(clk)
  59. begin
  60. if(display='1') then
  61. if(clk'event and clk='0') then
  62. if(c=72) then
  63. c<=0;
  64. c<=c+1;
  65. else
  66. if(c=2) then
  67. sram1(8 downto 6)<=din;
  68. c<=c+1;
  69. elsif(c=5) then
  70. c<=c+1;
  71. sram1(5 downto 3)<=din;
  72. elsif(c=8) then
  73. sram1(2 downto 0)<=din;
  74. c<=c+1;
  75. elsif(c=11) then
  76. sram2(8 downto 6)<=din;
  77. c<=c+1;
  78. elsif(c=14) then
  79. sram2(5 downto 3)<=din;
  80. c<=c+1;
  81. elsif(c=17) then
  82. sram2(2 downto 0)<=din;
  83. c<=c+1;
  84. elsif(c=20) then
  85. sram3(8 downto 6)<=din;
  86. c<=c+1;
  87. elsif(c=23) then
  88. sram3(5 downto 3)<=din;
  89. c<=c+1;
  90. elsif(c=26) then
  91. sram3(2 downto 0)<=din;
  92. c<=c+1;
  93. elsif(c=29) then
  94. sram4(8 downto 6)<=din;
  95. c<=c+1;
  96. elsif(c=32) then
  97. sram4(5 downto 3)<=din;
  98. c<=c+1;
  99. elsif(c=35) then
  100. sram4(2 downto 0)<=din;
  101. c<=c+1;
  102. elsif(c=38) then
  103. sram5(8 downto 6)<=din;
  104. c<=c+1;
  105. elsif(c=41) then
  106. sram5(5 downto 3)<=din;
  107. c<=c+1;
  108. elsif(c=44) then
  109. sram5(2 downto 0)<=din;
  110. c<=c+1;
  111. elsif(c=47) then
  112. sram6(8 downto 6)<=din;
  113. c<=c+1;
  114. elsif(c=50) then
  115. sram6(5 downto 3)<=din;
  116. c<=c+1;
  117. elsif(c=53) then
  118. sram6(2 downto 0)<=din;
  119. c<=c+1;
  120. elsif(c=56) then
  121. sram7(8 downto 6)<=din;
  122. c<=c+1;
  123. elsif(c=59) then
  124. sram7(5 downto 3)<=din;
  125. c<=c+1;
  126. elsif(c=62) then
  127. sram7(2 downto 0)<=din;
  128. c<=c+1;
  129. elsif(c=65) then
  130. sram8(8 downto 6)<=din;
  131. c<=c+1;
  132. elsif(c=68) then
  133. sram8(5 downto 3)<=din;
  134. c<=c+1;
  135. elsif(c=71) then
  136. sram8(2 downto 0)<=din;
  137. c<=c+1;
  138. else
  139. c<=c+1;
  140. end if;
  141. end
  142. if;
  143. end if;
  144. end if;
  145. end process;
  146. process(a)
  147. begin
  148. if(display='1') then
  149. if(a'event and a='0') then
  150. if(d=9) then
  151. dout<=sram1(8 downto 1);
  152. d<=0;
  153. d<=d+1;
  154. else
  155. if(d=0) then
  156. dout<=sram1(8 downto 1);
  157. elsif(d=1) then
  158. dout(7)<=sram1(0);
  159. dout(6 downto 0)<=sram2(8 downto 2);
  160. elsif(d=2) then
  161. dout(7 downto 6)<=sram2(1 downto 0);
  162. dout(5 downto 0)<=sram3(8 downto 3);
  163. elsif(d=3) then
  164. dout(7 downto 5)<=sram3(2 downto 0);
  165. dout(4 downto 0)<=sram4(8 downto 4);
  166. elsif(d=4) then
  167. dout(7 downto 4)<=sram4(3 downto 0);
  168. dout(3 downto 0)<=sram5(8 downto 5);
  169. elsif(d=5) then
  170. dout(7 downto 3)<=sram5(4 downto 0);
  171. dout(2 downto 0)<=sram6(8 downto 6);
  172. elsif(d=6) then
  173. dout(7 downto 2)<=sram6(5 downto 0);
  174. dout(1 downto 0)<=sram7(8 downto 7);
  175. elsif(d=7) then
  176. dout(7 downto 1)<=sram7(6 downto 0);
  177. dout(0)<=sram8(8);
  178. else
  179. dout<=sram8(7 downto 0);
  180. end if;
  181. d<=d+1;
  182. end
  183. if;
  184. end if;
  185. end if;
  186. end process;
  187. end LCDb_arch;
复制代码



psb1.jpeg (113.48 KB, 下载次数: 203)

psb1.jpeg

psb.jpeg (96.88 KB, 下载次数: 216)

psb.jpeg
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖 顶 踩
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

手机版|小黑屋|51黑电子论坛 |51黑电子论坛6群 QQ 管理员QQ:125739409;技术交流QQ群281945664

Powered by 单片机教程网

快速回复 返回顶部 返回列表