首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >基于ACtive-HDL的结构仿真

基于ACtive-HDL的结构仿真
EN

Stack Overflow用户
提问于 2015-09-25 19:41:44
回答 1查看 262关注 0票数 0

我已经编写了两个在ISE Design Suit中成功模拟的代码:

代码语言:javascript
复制
-- 2X1 Multiplexer
library IEEE;
use IEEE.STD_LOGIC_1164.all;
package mux2to1_pkg is
component mux2to1  
    port(d1,d0: in std_logic;
         s: in std_logic;
         f: out std_logic);
end component;
end mux2to1_pkg;
library IEEE;
use IEEE.STD_LOGIC_1164.all;
entity mux2to1 is
port(d1,d0: in std_logic;
     s: in std_logic;
     f: out std_logic);
end mux2to1;          
architecture behavioral of mux2to1 is
begin
f <= (d0 and not s) or
     (d1 and     s);
end behavioral;

代码语言:javascript
复制
-- 6X1 Multiplexer
library IEEE;
use IEEE.STD_LOGIC_1164.all;
package mux6to1_pkg is
component mux6to1  
    port(d: in std_logic_vector(5 downto 0);
         s: in std_logic_vector(2 downto 0);
         f: out std_logic);
end component;
end mux6to1_pkg;
library IEEE;
use IEEE.STD_LOGIC_1164.all;
use WORK.mux2to1_pkg.all;
entity mux6to1 is
port(d: in std_logic_vector(5 downto 0);
     s: in std_logic_vector(2 downto 0);
     f: out std_logic);
end mux6to1;
architecture structural of mux6to1 is
signal m1,m2,m3,m4: std_logic;
begin
mux1: mux2to1 port map(d(5),d(4),s(0),m1);
mux2: mux2to1 port map(d(3),d(2),s(0),m2);
mux3: mux2to1 port map(d(1),d(0),s(0),m3);
mux4: mux2to1 port map(m2,m3,s(1),m4);
mux5: mux2to1 port map(m1,m4,s(2),f);
end structural;

问题是,当我想要在Active-HDL中模拟MUX6to1时,输出根本不会改变。这个程序的秘密是什么?泰。

EN

回答 1

Stack Overflow用户

发布于 2015-09-25 20:16:11

使用此测试平台:

代码语言:javascript
复制
library ieee;
use ieee.std_logic_1164.all;
entity mdl_tb is
end entity;

library ieee;
use ieee.numeric_std.all;
architecture sim of mdl_tb is
  signal s_d : std_logic_vector(8 downto 0) := (others => '0');
  signal f   : std_logic;
begin
  dut_e : entity work.mux6to1
    port map(d => s_d(5 downto 0),
             s => s_d(8 downto 6),
             f => f);
  process is
  begin
    wait for 1 ns;
    s_d <= std_logic_vector(unsigned(s_d) + 1);
  end process;
end architecture;

它显示了如下变化:

基于mdl.vhd中包含上述两个文件的Active-HDL脚本:

代码语言:javascript
复制
# Workspace "prod" create under current and open this workspace
workspace create prod
# Design "prod" create under current workspace
design create -a prod .
# Create to directory under workspace
cd $DSN/..
# Compile
acom ../mdl.vhd
acom ../mdl_tb.vhd
# Load module for simulation
asim work.mdl_tb
# Waveform add
add wave /mdl_tb/*
# Run
run 600 ns 

顺便说一句。如果您跳过组件声明和相关的包,则可以通过如下代码显著减少代码:

代码语言:javascript
复制
library IEEE;
use IEEE.STD_LOGIC_1164.all;
entity mux2to1 is
  port(d1,d0: in std_logic;
    s: in std_logic;
    f: out std_logic);
end mux2to1;
architecture behavioral of mux2to1 is
begin
  f <= d0 when (s = '0') else d1;
end behavioral;

library IEEE;
use IEEE.STD_LOGIC_1164.all;
entity mux6to1 is
  port(d: in std_logic_vector(5 downto 0);
    s: in std_logic_vector(2 downto 0);
    f: out std_logic);
end mux6to1;
architecture structural of mux6to1 is
  signal m1,m2,m3,m4: std_logic;
begin
  mux1: entity work.mux2to1 port map(d(5),d(4),s(0),m1);
  mux2: entity work.mux2to1 port map(d(3),d(2),s(0),m2);
  mux3: entity work.mux2to1 port map(d(1),d(0),s(0),m3);
  mux4: entity work.mux2to1 port map(m2,m3,s(1),m4);
  mux5: entity work.mux2to1 port map(m1,m4,s(2),f);
end structural;
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/32781410

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档