我在用VHDL设计存储器电路时遇到了问题。我试图找出以下提示的解决办法:
使用结构化VHDL方法在Xilinx工具中创建一个NAND基本单元。在两个NAND门上增加一个1ns的门延迟(对于上升和下降的转换)。标签输入S和R以及输出Q和QN (视情况而定)。创建一个VHDL测试平台来模拟电路,驱动输入,如下所示。
在模拟开始时,这两种输入都被取消断言.在100 S.,资产S.在200 S.,去断言S.在300 S.,断言R.在400 S.,.在500 S.,断言两种输入。在600 At时,两种输入都去断言。在700 At时,断言这两种输入。
如果我能得到代码的基本示例,我也可以设计一个NOR电路(这是我希望解决的实际问题),但是一个NAND示例就足够了。
我尝试过将这个模型用于结构代码。
import std_logic from the IEEE library
library ieee;
use ieee.std_logic_1164.all;
--ENTITY DECLARATION: name, inputs, outputs
entity nandGate is
port( A, B : in std_logic;
F : out std_logic);
end nandGate;
--FUNCTIONAL DESCRIPTION: how the NAND Gate works
architecture func of nandGate is
begin
F <= A nand B;
end func;
and this model for the test bench
architecture tb of nandGate_tb is
--pass nandGate entity to the testbench as component
component nandGate is
port( A, B : in std_logic;
F : out std_logic);
end component;
signal inA, inB, outF : std_logic;
begin
--map the testbench signals to the ports of the nandGate
mapping: nandGate port map(inA, inB, outF);
process
--variable to track errors
variable errCnt : integer := 0;
begin
--TEST 1
inA <= '0';
inB <= '0';
wait for 15 ns;
assert(outF = '1') report "Error 1" severity error;
if(outF /= '1') then
errCnt := errCnt + 1;
end if;
--TEST 2
inA <= '0';
inB <= '1';
wait for 15 ns;
assert(outF = '1') report "Error 2" severity error;
if(outF /= '1') then
errCnt := errCnt + 1;
end if;
--TEST 3
inA <= '1';
inB <= '1';
wait for 15 ns;
assert(outF = '0') report "Error 3" severity error;
if(outF /= '0') then
errCnt := errCnt + 1;
end if;
-------------- SUMMARY -------------
if(errCnt = 0) then
assert false report "Good!" severity note;
else
assert true report "Error!" severity error;
end if;
end process;
end tb;发布于 2013-10-07 03:36:16
问题是要求您从一对交叉耦合的NAND门创建一个SR锁存器(在指令中称为NAND基本单元)。所述延迟将在NAND门的功能描述的逻辑方程中。
以下是由两个NAND门组成的SR锁存器的结构VHDL模型:
entity nandCell is
port( S, R : in std_logic; --S and R are active low
Q, QN : out std_logic);
end nandCell;
architecture structural of nandCell is
--NAND gate component declaration
signal Qint, QNint : std_logic; --these internal signals are required to be able to read the "outputs"
begin
n1 : nandGate port map(S, QNint, Qint);
n2 : nandGate port map(R, Qint, QNint);
Q <= Qint;
QN <= QNint;
end structural;https://stackoverflow.com/questions/16392344
复制相似问题