数字电路课程设计报告
(3)分析
若reset为‘1’时,表示复位有效,对波形复位;否则判断脉冲信号输入是否为上升沿。如果为上升沿脉冲,将进行计数。在进行计数时,先判断当前计数值是否为“11111111”,若是则将计数值置为“00000000”;否则进行加1计数。再判断当前计数值是否为小于或等于“01000000”,若是,则将sign置为‘1‘,否则sign置为’0‘。占空比为1:1.
6、三角波模块
(1)程序
library ieee;
use ieee.std_logic_1164.all; use ieee.std_logic_unsigned.all; entity tria is
port( CLK:in std_logic; reset:in std_logic;
dout:out std_logic_vector(7 downto 0)); end tria;
architecture six of tria is begin
process(CLK,reset)
variable Q:std_logic_vector(7 downto 0); variable sign:std_logic; begin
if reset='1' then Q:=\sign:='0';
elsif CLK'event and CLK='1' then if sign='0' then if Q=\
Q:=\ sign:='1';
else
Q:=Q+'1'; end if; else
if Q=\ Q:=\ sign:='0'; else
Q:=Q-'1'; end if;
10
数字电路课程设计报告
end if; end if; dout<=Q; end process; end six;
(2)波形
加计减计数 数
(3)分析
若reset为‘1’时,表示复位有效,对波形复位,并将计数方向清零,否则判断脉冲信号输入是否为上升沿。如果为上升沿脉冲,将进行计数。在进行计数时,先判断计数方向是否为‘0’,若为‘0’则进行加计数,否则进行减计数,sign为‘0’时先判断当前计数值是否为“11111110”,如果是,则将计数值置为“11111111”,并将sign置为‘1’,为减计数做好准备;否则进行加‘1’计数。Sign为‘1’时,先判断当前计数值是否为“00000001”,如果是,则将计数值置为“00000000”,并将sign置为‘0‘,为加计数做好准备;否则加1计数。
7、递减锯齿波
(1)程序 library ieee;
use ieee.std_logic_1164.all; use ieee.std_logic_unsigned.all; use ieee.std_logic_arith.all; entity juchijian is
port ( clk:in std_logic; reset:in std_logic;
dout:out std_logic_vector(7 downto 0)); end juchijian;
architecture seven of juchijian is signal q:std_logic_vector(7 downto 0); begin
11
数字电路课程设计报告
process(clk,reset) begin
if reset='1' then q<=\else
if clk='1' and clk'event then if q<=\ q<=\ else q<=q-'1'; end if; end if; end if;
end process; dout<=q; end seven;
(2)波形
当计数值为0时,则将 计数值置为255 (3)分析
若reset为‘1’,表示复位有效,对波形复位,否则判断脉冲信号输入是否为上升沿。如果为上升沿脉冲,将进行计数。在进行计数时,先判断当前计数值是否为“00000000”;若是则将计数值置为“11111111”,否则进行减1计数。
8、阶梯波
(1)程序 library ieee;
use ieee.std_logic_1164.all; use ieee.std_logic_unsigned.all; entity jieti is
12
数字电路课程设计报告
port ( clk: in std_logic; reset: in std_logic;
dout: out std_logic_vector(7 downto 0)); end jieti;
architecture eight of jieti is begin
process(clk,reset)
variable Q:std_logic_vector(7 downto 0); begin
if reset='1' then q:=\
elsif clk'event and clk='1' then if q=\ q:=\ else
q:=q+16; end if; end if; dout<=Q; end process; end eight;
(2)波形
(3)分析
若reset为‘1’,表示复位有效,对波形复位;否则判断脉冲信号输入是否为上升沿。如果为上升沿脉冲,将进行计数。在进行计数时,先判断当前计数值是否为“11111111”,如果是,则将计数值置为“00000000”;否则进行加16计数。
四、 顶层电路的设计仿真结果与分析
(1)程序 library ieee;
use ieee.std_logic_1164.all; use ieee.std_logic_unsigned.all; entity xinhao is
13
数字电路课程设计报告
port( clk1:in std_logic; reset1:in std_logic;
sel0,sel:in std_logic_vector(2 downto 0); q1:out std_logic_vector(7 downto 0)); end xinhao;
architecture top of xinhao is component cout256 is
port( clk:in std_logic;
q7,q6,q5,q4,q3,q2,q1,q0:out std_logic); end component ; component mux81 is
port(sel:in std_logic_vector(2 downto 0); d0,d1,d2,d3,d4,d5,d6,d7:in std_logic; q:out std_logic); end component;
component juchi is
port( clk:in std_logic; reset:in std_logic;
dout:out std_logic_vector(7 downto 0)); end component ; component sine is
port( clk:in std_logic; reset:in std_logic;
dout:out std_logic_vector(7 downto 0)); end component ;
component square is
port( clk:in std_logic; reset:in std_logic;
q:out std_logic_vector(7 downto 0)); end component ; component tria is
port( clk: in std_logic; reset: in std_logic;
dout:out std_logic_vector(7 downto 0)); end component ;
component mux81_8 is
port(sel:in std_logic_vector(2 downto 0);
d0,d1,d2,d3,d4,d5,d6,d7:in std_logic_VECTOR(7 DOWNTO 0); q:out std_logic_VECTOR(7 DOWNTO 0)); end component mux81_8;
signal b0,b1,b2,b3:std_logic_vector(7 downto 0);
14
百度搜索“77cn”或“免费范文网”即可找到本站免费阅读全部范文。收藏本站方便下次阅读,免费范文网,提供经典小说综合文库基于FPGA的函数信号发生器的设计报告(3)在线全文阅读。
相关推荐: