搜索
bottom↓
回复: 2

关于MODELSIM仿真遇到的问题

[复制链接]

出0入0汤圆

发表于 2010-6-9 11:24:19 | 显示全部楼层 |阅读模式
--分配器
--**************库定义、 包定义********************
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
--**************实体定义********************
Entity div is
generic(duty:integer:=5);--类属参数说明语句
        --端口说明       
port(clk        :        in        std_logic;--时钟输入
                q        :   out std_logic--分频输出          
        );
end div;
--**************构造体定义********************
Architecture div10 of div is
  constant period : integer:=10;--常数定义,分频数
  signal count : integer range 0 to period-1;--信号定义,计数作用
begin
process(clk)--进程,由clk这个信号启动
  begin
        if rising_edge(clk) then --上升沿驱动,还有另一种写法,见其他例程
                if count<duty then
                        q<='0';
                        count<=count+1;
                elsif count<period-1 then
                        q<='1';
                        count<=count+1;
                else
                        count<=0;
                end if;
        end if;
end process;
end div10;
以上为基于VHDL的分频器程序,利用MODELSIM进行仿真,达到了预期的效果,波形图如下图

阿莫论坛20周年了!感谢大家的支持与爱护!!

曾经有一段真挚的爱情摆在我的面前,我没有珍惜,现在想起来,还好我没有珍惜……

出0入0汤圆

 楼主| 发表于 2010-6-9 11:25:40 | 显示全部楼层
图怎末发不了呢?

出0入0汤圆

 楼主| 发表于 2010-6-9 11:32:19 | 显示全部楼层
--计数器
--rst复位控制低电平有效;
--en使能控制高电平有效;
--up加/减控制,高电平加法,低电平减法。
--sum为计数输出;cout为进位输出。
--**************库定义、 包定义********************
Library ieee;
Use ieee.std_logic_1164.all;
Use ieee.std_logic_unsigned.all;
--**************实体定义********************
Entity counter is
        Port(clk,rst,en,up:        in        std_logic;
                Sum:        out        std_logic_vector(2 downto 0);
                Cout:        out        std_logic;
                red :        out std_logic
                );
End counter;
--**************构造体定义********************
Architecture a of counter is
Signal count:        std_logic_vector(2 downto 0);
signal clock : std_logic;
Begin
red<='1';
process(clk)--分频进程
        variable cnt1 : integer range 0 to 5000;
        variable cnt2 : integer range 0 to 2000;
        begin
                if clk'event and clk='1' then
                if cnt1=5000 then
                        cnt1:=0;
                        if cnt2=2000 then
                                cnt2:=0;
                                clock<=not clock;
                        else
                                cnt2:=cnt2+1;
                        end if;
                else
                        cnt1:=cnt1+1;
                end if;
        end if;
end process;

        Process(clock,rst)--计数器进程
        Begin
                If rst='0' then
                        Count<=(others=>'0');
                Elsif rising_edge(clock) then
                        If en='1' then
                                Case up is
                                        When '1' => count<=count+1;
                                        When others =>count<=count-1;
                                End case;
                        End if;
                End if;
        End process;
        Sum<=not count;--数据输入反逻辑
        Cout <='0' when en='1' and ((up='1' and count=7) or (up='0' and count=0)) else '1';--进位输出
End;

以上基于VHDL的计数器程序,想利用MODELSIM仿真,遇到点问题,请高手帮忙!
首先是分频功能步能实现
1、        给clk设为时钟驱动后,分频后CLOCK一直步变?怎么对CLOCK进行初始化?
2、        如何使用图像激励进行这个程序的仿真
3、        正在学TESTBENCH ,如可以请给出这个程序的测试激励


截图没发上来
回帖提示: 反政府言论将被立即封锁ID 在按“提交”前,请自问一下:我这样表达会给举报吗,会给自己惹麻烦吗? 另外:尽量不要使用Mark、顶等没有意义的回复。不得大量使用大字体和彩色字。【本论坛不允许直接上传手机拍摄图片,浪费大家下载带宽和论坛服务器空间,请压缩后(图片小于1兆)才上传。压缩方法可以在微信里面发给自己(不要勾选“原图),然后下载,就能得到压缩后的图片】。另外,手机版只能上传图片,要上传附件需要切换到电脑版(不需要使用电脑,手机上切换到电脑版就行,页面底部)。
您需要登录后才可以回帖 登录 | 注册

本版积分规则

手机版|Archiver|amobbs.com 阿莫电子技术论坛 ( 粤ICP备2022115958号, 版权所有:东莞阿莫电子贸易商行 创办于2004年 (公安交互式论坛备案:44190002001997 ) )

GMT+8, 2024-6-1 18:36

© Since 2004 www.amobbs.com, 原www.ourdev.cn, 原www.ouravr.com

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