vga图像显示控制器设计报告(编辑修改稿)内容摘要:

ponent vgasmode Define vag mode implement port (clk25m,clk1hz: in std_logic。 sw: in std_logic_vector(1 downto 0)。 hen,ven: in std_logic。 colors0,colors1,colors2,colors3: in std_logic_vector(5 downto 0)。 colors: out std_logic_vector(5 downto 0))。 end ponent。 ponent vgasig Define vag signal interface as a module port (clk25m: in std_logic。 ht,vt: in std_logic_vector(9 downto 0)。 hsync,vsync,henable,venable : out std_logic)。 end ponent。 ponent vgacolor Generate colors for each mode 数字电路综合 实验报告 第 16页 port (clk25m,clk100hz,clk1hz: in std_logic。 hpos,vpos: in std_logic_vector(9 downto 0)。 button: in std_logic_vector(4 downto 0)。 sw : in std_logic_vector(5 downto 0)。 colors0,colors1,colors2,colors3: out std_logic_vector(5 downto 0))。 end ponent。 ponent usermode Sub mode for user port (clk25m,clk100hz,clk1hz: in std_logic。 hpos,vpos: in std_logic_vector(9 downto 0)。 button : in std_logic_vector(4 downto 0)。 usercolors: out std_logic_vector(5 downto 0))。 end ponent。 end vgapackage。 然后在 VGAController 中进行例化, VHDL描述如下(仅给出关键部分的描述)。 begin sw = (sw7,sw6,sw5,sw4,sw3,sw2,sw1,sw0)。 bt = (bt4,bt3,bt2,bt1,bt0)。 (r0,r1,g0,g1,b0,b1) = colors。 clock_port_map: clock port map(clk50m = clk50m, clk25m = clk25m, clk100hz = clk100hz, clk1hz = clk1hz)。 pixelt_port_map: pixelt port map(clk25m = clk25m, htout = ht, vtout = vt)。 vgasig_port_map: vgasig port map(clk25m = clk25m, ht = ht, 数字电路综合 实验报告 第 17页 vt = vt,hsync = hs, vsync = vs, henable = hen, venable = ven)。 vgaemode_port_map: vgasmode port map(clk25m = clk25m, clk1hz = clk1hz, hen = hen ,ven = ven, colors0 = colors0,colors1 = colors1, colors2 = colors2,colors3 = colors3, colors = colors,sw = sw(1 downto 0))。 vgacolor_port_map: vgacolor port map(clk25m = clk25m, clk100hz = clk100hz, clk1hz = clk1hz, hpos = ht, vpos = vt, sw = sw(7 downto 2),button = bt, colors0 = colors0,colors1 = colors1, colors2 = colors2,colors3 = colors3)。 end arch。 图 是 QuartusII 生成的总体电路图 ,定义的第二层 5 个模块均对应生成了器件,由于 UserMode 模块是在 VGAColor 模块里进行的例化,故系统综合时将其归并在了 VGAColor 模块内。 QuartusII 生成的 电路图 和 节中模块设计图一致,信号连接图与。 设计是正确的。 数字电路综合 实验报告 第 18页 图 QuartusII 生成的总体电路图 分块电路的描述 本节给出分块电路的硬件描述,对关键部分进行了分析。 由于代码长度较长,只给出部分代码,完整的代码请参见。 各模块的 RTL图参考。 VGAMode 模块的描述 定义状态机的描述如下。 type states is (s0,s1,s2,s3)。 signal state:states:=s0。 该模块主要描述状态机的转移,转移条件是 SW1和 SW2的组合值,描述如下。 process(clk1hz) Detecting sw1 and sw0 and decide the state begin if(rising_edge(clk1hz)) then case sw is when 00 = state = s0。 when 01 = state = s1。 when 10 = state = s2。 when 11 = state = s3。 end case。 end if。 end process。 VGAMode 模块负责根据当前状态选择输出 VGAColor 送入的不同模式下的颜色图像信号,输出到 VGA接口。 process(clk25m) Select color of one mode to VAG interface begin if(rising_edge(clk25m)) then case state is when s0 = colorstmp = colors0。 when s1 = colorstmp = colors1。 when s2 = colorstmp = colors2。 when s3 = colorstmp = colors3。 end case。 数字电路综合 实验报告 第 19页 end if。 end process。 VGASig模块的描述 该模块 主要 负责 VGA 标准中的行同步信号和列同步信号以及行列消隐信号。 其输入信号来自于 PixelCNT模块的像素位置信号 ht和 vt。 VGA扫描显示的原理关键点在于同步信号和消隐信号的产生。 由 VGA 标准中定义的时序关系,可以等效地计算出像素点的时序关系图。 其中,行同步时序列表如下: 表 21 VGA行同步时序表 根据时序表,容易确定水平扫描的四个状态区,即:行显示区( h_video)、行前端消隐区( h_front)、行同步区( h_sync)、行后端消隐区( h_back)。 如图。 数字电路综合 实验报告 第 20页 图 VGA行扫描状态转移图 行同步信号产生描述如下。 行同步区定义在 656~ 752像素之间。 process(clk25m) hsync begin if (rising_edge(clk25m)) then if (ht = (640+8+8) and ht (640+8+8+96)) then hsync = 39。 039。 else hsync = 39。 139。 end if。 end if。 end process。 类似行同步,列同步时序表如下: 表 22 VGA行 列 同步时序表 数字电路综合 实验报告 第 21页 图 VGA列扫描状 态转移图 列同步信号产生描述如下。 列同步区在 490~ 492像素点之间。 process(vt) vsync begin if (vt = (480+8+2) and vt (480+8+2+2)) then vsync = 39。 039。 else vsync = 39。 139。 end if。 end process。 值得说明的是,由于时钟误差在所难免, VGA 标准实现时像素的计数要求并非一个像素点都不能差,微小误差是可以接受的。 最后是消隐信号的产生。 当显示像素不在定义的 640 480 范围内时,不输出颜色信号,称其为消隐区。 消隐去描述如下。 process(clk25m) no color when not in 640*480 begin if(rising_edge(clk25m)) then if((ht 640) or (vt 480)) then henable = 39。 039。 venable = 39。 039。 else henable = 39。 139。 venable = 39。 139。 end if。 end if。 end process。 VGAColor模块的描述 该模块 产生四种显示模式 S0、 S S S3 的颜色图像信号,其中用户模式 S3 是调用 UserMode 模块实现的。 数字电路综合 实验报告 第 22页 横向和纵向彩条显示,只需分别判断纵向和横向像素位置即可。 此处划分采用了均分方式,只要增加划分次数就可得到更多条幅,此处只按要求给出 8种颜色。 下面给出横向条幅的的描述,纵向条幅描述类似。 process(clk25m) state s0 process: horizontal colors begin if(rising_edge(clk25m)) then if hpos 640 and vpos 60 then colors0 = 100100。 elsif hpos 640 and vpos 120 then colors0 = 000001。 elsif hpos 640 and vpos 180 the。
阅读剩余 0%
本站所有文章资讯、展示的图片素材等内容均为注册用户上传(部分报媒/平媒内容转载自网络合作媒体),仅供学习参考。 用户通过本站上传、发布的任何内容的知识产权归属用户或原始著作权人所有。如有侵犯您的版权,请联系我们反馈本站将在三个工作日内改正。