EDA实验报告 EDA实验报告武汉理工大学(五篇)

  • 上传日期:2023-02-02 01:19:44 |
  • ZTFB |
  • 14页

“报告”使用范围很广,按照上级部署或工作计划,每完成一项任务,一般都要向上级写报告,反映工作中的基本情况、工作中取得的经验教训、存在的问题以及今后工作设想等,以取得上级领导部门的指导。那么什么样的报告才是有效的呢?下面是小编为大家整理的报告范文,仅供参考,大家一起来看看吧。

EDA实验报告 EDA实验报告武汉理工大学篇一

eda技术实验

二、教材名称: 《eda技术使用教程》,潘松等编著。

三、本课程教学目的、要求:

介绍eda的基本知识、常用的eda工具的使用方法和目标器件的结构原理、vhdl设计输入方法(图形和文本)、vhdl仿真、vhdl的设计优化等。

eda技术作为重要的专业课程,其实践性强。在教学时要注重理论和实践的紧密结合,通过大量上机操作,使学生掌握vhdl的基本结构和编程思想。实验1 原理图输入方法及8位全加器设计(4课时)

1)实验目的:

熟悉利用max+plusⅱ的原理图输入方法设计简单组合电路,掌握层次化设计的方法,并通过一个8位全加器的设计把握利用eda软件进行电子电路设计的详细流程。2)实验报告要求:

详细叙述8位加法器的设计流程;给出各层次的原理图及其对应的仿真波形图;给出加法器的延时情况。

3)实验步骤:

(1)设计一个一位半加器。

步骤1:输入设计项目和存盘 步骤2:输入半加器元件: 步骤3:将项目设置为工程文件 步骤4:选择目标器件并编译 步骤5:时序仿真 步骤6:包装元件入库

选择菜单“file”→“open”,在“open”对话框中选择原理图编辑文件选项“graphic editor files”,,重新打开半加器设计文件,然后选择如图4-5中“file”菜单的“create default symbol”项,将当前文件变成了一个包装好的单一元件(symbol),并被放置在工程路径指定的目录中以备后用。

(2)利用半加器组成一个一位全加器,并记录仿真结果。(3)利用全加器组成一个八位全加器,并记录仿真结果。

实验二

简单组合电路和时序电路设计(4课时)

一、实验目的:

熟悉max+plusⅱ的vhdl文本设计流程全过程,学习简单组合电路和时序电路的设计和仿真方法。

二、实验内容

1:首先利用max+plusⅱ完成2选1多路选择器和一位全加器的文本编辑输入和仿真测试等步骤,给出仿真波形,验证本项设计的功能。

2:设计触发器(j-k),给出程序设计、软件编译、仿真分析、硬件测试及详细实验过程。

3:先设计或门和一位半加器的vhdl描述文件,并进行仿真调试,再用元件例化的方法实现一位全加器,并仿真调试。要求记录vhdl文件内容和仿真波形结果。

4:用一位全加器设计8为全加器。要求记录vhdl文件内容和仿真波形结果。(选作)参考程序 entity mux21a is port(a, b : in bit;s : in bit;y : out bit);end entity mux21a;architecture one of mux21a is signal d,e : bit;begin d <= a and(not s);e <= b and s;y <= d or e;end architecture one;

library ieee;use ;entity or2a is port(a, b :in std_logic;c : out std_logic);end entity or2a;

architecture fu1 of or2a is begin c <= a or b;end architecture fu1;

半加器描述(1)library ieee;use ;entity adder is port(a, b : in std_logic;co, so : out std_logic);end entity adder;architecture fh1 of adder is begin so <= not(a xor(not b));co <= a and b;end architecture fh1;

1位二进制全加器顶层设计描述 library ieee;use ;entity f_adder is port(ain,bin,cin : in std_logic;cout,sum : out std_logic);end entity f_adder;architecture fd1 of f_adder is component h_adder port(a,b : in std_logic;co,so : out std_logic);end component ; component or2a port(a,b : in std_logic;c : out std_logic);end component;

signal d,e,f : std_logic;begin u1 : h_adder port map(a=>ain,b=>bin,co=>d,so=>e);u2 : h_adder port map(a=>e,b=>cin,co=>f,so=>sum);u3 : or2a port map(a=>d,b=>f,c=>cout);end architecture fd1;二选一多路选择器仿真结果:

实验三

含异步清0和同步时钟使能的4位加法计数器(4课时)

一、实验目的:

学习计数器的设计、仿真,进一步熟悉vhdl设计技术。

二、实验内容:

设计一含计数使能、异步复位和能进行计数值并行预置功能的4位加法计数器。rst是异步清零信号,高电平有效;clk是时钟输入信号;d0、d1、d2、d3是4位数据输入端(数据预置输入端)。q0、q1、q2、q3为计数器输出端。cout为进位输出端。ena为使能端,为„1‟时,计数器实现对clk时钟脉冲信号的加1计数,为0时停止计数。

参考程序:library ieee;use ;use ;entity cnt4b is port(clk : in std_logic;rst : in std_logic;ena : in std_logic;outy : out std_logic_vector(3 downto 0);cout : out std_logic);end cnt4b;architecture behav of cnt4b is signal cqi : std_logic_vector(3 downto 0);begin p_reg: process(clk, rst, ena)begin if rst = '1' then cqi <= “0000”;elsif clk'event and clk = '1' then if ena = '1' then cqi <= cqi + 1;else cqi <= “0000”;end if;end if;outy <= cqi;end process p_reg;cout <= cqi(0)and cqi(1)and cqi(2)and cqi(3);--进位输出 end behav;

实验四

7段数码显示译码器设计(2课时)

一、实验目的:

1、学习7段数码显示译码器设计;

2、学习vhdl的多层次设计方法。

二、实验原理:

7段数码是纯组合电路,通常的小规模专用ic,如74或4000系列的器件只能作十进制bcd码译码,然而数字系统中的数据处理和运算都是2进制的,所以输出表达都是16进制的,为了满足16进制数的译码显示,最方便的方法就是利用译码程序在fpga/cpld中来实现。但为了简化过程,首先完成7段bcd码译码器的设计。例如输出为“1101101”时,数码管的7个段:g、f、e、d、c、b、a分别接1、1、0、1、1、0、1;接有高电平的段发亮,于是数码管显示“5”。

图6-21 共阴数码管及其电路

三、实验内容

1、编程实现7段数码显示译码器设计;

2、对7段数码显示译码器设计进行编辑、仿真,给出其所有信号的时序仿真波形; 参考程序: library ieee;use ;entity decl7s is port(a : in std_logic_vector(3 downto 0);led7s : out std_logic_vector(6 downto 0));end;architecture one of decl7s is begin process(a)begin case a is when “0000” => led7s <= “0111111”;when “0001” => led7s <= “0000110”;when “0010” => led7s <= “1011011”;when “0011” => led7s <= “1001111”;when “0100” => led7s <= “1100110”;when “0101” => led7s <= “1101101”;when “0110” => led7s <= “1111101”;when “0111” => led7s <= “0000111”;when “1000” => led7s <= “1111111”;when “1001” => led7s <= “1101111”;when others => null;end case;end process;end;仿真结果:

综合后的计数器和译码器连接电路的顶层文件原理图:

实验五

用状态机实现序列检测器的设计(4课时)

一、实验目的:

1、掌握状态机的编程方法和步骤;

2、掌握用状态机设计序列检测器的方法和步骤;

二、实验内容

用状态机编程实现对系列数“11100101”的检测,当某一系列串(以左移方式)进入检测器后,若该串与预置的系列数相同,则输出“a”,否则输出“b”。

三、实验步骤:

1、编辑系列检测器的vhdl程序;

2、仿真测试并给出仿真波形,了解控制信号的时序;

3、将上述方案改为系列检测密码为可预置(外部输入)情况,重新编写程序、编译和仿真,并记录仿真结果。参考程序:

library ieee;use ;entity schk is port(din,clk,clr : in std_logic;ab : out std_logic_vector(3 downto 0));end schk;architecture behv of schk is signal q:integer range 0 to 8;signal d:std_logic_vector(7 downto 0);begin d<=“11100101”;process(clk,clr)begin if clr= '1' then q <= 0;elsif clk='1' and clk'event then case q is when 0 => if din = d(7)then q<=1;else q<=0;end if;when 1 => if din = d(6)then q<=2;else q<=0;end if;when 2 => if din = d(5)then q<=3;else q<=0;end if;when 3 => if din = d(4)then q<=4;else q<=0;end if;when 4 => if din = d(3)then q<=5;else q<=0;end if;when 5 => if din = d(2)then q<=6;else q<=0;end if;when 6 => if din = d(1)then q<=7;else q<=0;end if;when 7 => if din = d(0)then q<=8;else q<=0;end if;when others=> q<=0;end case;end if;end process;process(q)begin if q=8 then ab<=“1010”;else ab<=“1011”;end if;end process;end behv;仿真结果:

提高型实验:

实验六

用vhdl实现数字钟及校园打铃系统(6课时)

一、实验目的及要求:

1、掌握vhdl语言的基本结构及编程思想。

2、掌握vhdl语言的进行系统设计的方法和步骤。

3、提高学生综合应用能力。

二、实验内容:

1、用vhdl实现数字钟及校园打铃系统的软件编辑。

2、用vhdl实现数字钟及校园打铃系统的软件仿真。

三、实验步骤

1、用vhdl编辑60进制计数器,并进行软件仿真。

2、用vhdl编辑24进制计数器,并进行软件仿真。

3、用vhdl编辑30进制计数器,并进行软件仿真。

4、用元件例化的方法实现数字钟的软件编辑及软件仿真。

5、实现数字钟的校时功能。

6、实现数字钟的打铃功能。

7、完成数字钟及校园打铃系统的实验报告。

实验七

a/d采样控制器设计

一、实验目的及要求:

1、掌握vhdl语言的基本结构及编程思想。

2、掌握a/d采样控制器的工作原理。

3、掌握a/d采样控制器的vhdl语言编程方法。

二、实验内容:

1、设计一a/d0809模数转换器控制器。

2、将转换结果送数码管显示器显示(2位)。

3、模拟输入通道为in0。

三、实验步骤:

1、adc0809特点介绍

(1)、单极性输入,8位a/d转换精度。(2)、逐次逼近式,每次采样时间约为100us(3)、8通道模拟输入

2、a/d转换器外部引脚功能结构图

3、a/d转换器时序图

4、ad转换控制器与ad转换器的接口电路框图

5、状态控制

s0状态:初始状态。addc=‘1’,选择1通道模拟信号输入。

ale=start=oe=lock=‘0’;

s1状态:通道锁存。ale=‘1’, start=oe=lock=‘0’;

s2状态:启动a/d转换。ale=‘1’,start=‘1’,oe=lock=‘0’; s3状态:a/d转换等待状态。

ale=start=‘0’,oe=lock=‘0’;

if eoc=‘0’

保持当前状态不变,继续等待a/d转换。

else

转换结束,进入下一状态。

s4状态:数据输出允许状态。a/d转换完毕,开启数据输出允许信号。

ale=‘0’,start=‘0’,oe=‘1’,lock=‘0’;

s5状态:数据锁存状态。开启数据锁存信号,将转换结果送锁存器锁存。

ale=‘0’,start=‘0’,oe=‘1’,lock=‘1’; s6状态:延时状态。为了保证数据可靠锁存,延时一个时钟状态周期。

ale=‘0’,start=‘0’,oe=‘1’,lock=‘1’; 其它状态:返回到初始状态。ale=start=oe=lock=‘0’;

6、参考程序: library ieee;use ;entity ad0809 is

port(d :in std_logic_vector(7 downto 0);

clk0,eoc : in std_logic;

adda,oe : out std_logic;

ale,start : out std_logic;

q : out std_logic_vector(7 downto 0);

qq : out integer range 15 downto 0);end ad0809;architecture behav of ad0809 is

type st_type is(s0, s1, s2, s3,s4,s5,s6,s7);

signal current_state,next_state : st_type;

signal regl:std_logic_vector(7 downto 0);

signal lock :std_logic;

begin

adda<='1';

pro: process(current_state,eoc)

begin

case current_state is

when s0 => qq<=0;ale<='0';start<='0';oe<='0';lock<='0';next_state <= s1;

when s1 => qq<=1;ale<='0';start<='0';oe<='0';lock<='0';next_state <= s2;

when s2 => qq<=2;ale<='1';start<='1';oe<='0';lock<='0';next_state <= s3;

when s3 => qq<=3;ale<='1';start<='1';oe<='0';lock<='0';

if eoc='0' then next_state <= s4;

else next_state <= s3;

end if;

when s4 => qq<=4;ale<='0';start<='0';oe<='0';lock<='0';

if eoc='1' then next_state <= s5;

else next_state <= s4;

end if;

when s5 => qq<=5;ale<='0';start<='1';oe<='1';lock<='0';next_state <= s6;

when s6 => qq<=6;ale<='0';start<='0';oe<='1';lock<='1';next_state <= s7;

when s7 => qq<=7;ale<='0';start<='0';oe<='1';lock<='1';next_state <= s0;

when others => next_state <= s0;

end case;

end process pro;reg:process(clk0)

begin

if clk0'event and clk0='1' then

current_state<=next_state;

end if;

end process reg;

com:process(lock)

begin

if lock'event and lock='1' then

regl<=d;

end if;

end process com;

q<=regl;end behav;

实验八

数字频率计设计

一、实验目的及要求:

1、掌握vhdl语言的基本结构及编程思想。

2、掌握数字频率计的工作原理。

3、掌握数字频率计的vhdl语言编程方法。

二、实验内容:

1、设计8位十进制数字频率计。

2、测量频率范围为1hz-50mhz

三、实验原理: 测频原理框图

四、实验步骤 1、8位十进制计数器设计

(1)用vhdl设计十进制计数器,并进行软件和硬件仿真 参考程序如下: library ieee;use ;use ;entity cnt10 is

port(clk,rst,en : in std_logic;

cq : out std_logic_vector(3 downto 0);

cout : out std_logic);

end cnt10;architecture behav of cnt10 is begin

process(clk, rst, en)

variable cqi : std_logic_vector(3 downto 0);

begin

if rst = '1' then

cqi :=(others =>'0');--计数器复位

elsif clk'event and clk='1' then

--检测时钟上升沿

if en = '1' then

--检测是否允许计数

if cqi < “1001” then

cqi := cqi + 1;--允许计数

else

cqi :=(others =>'0');--大于9,计数值清零

end if;

end if;

end if;

if cqi = “1001” then cout <= '1';--计数大于9,输出进位信号

else

cout <= '0';

end if;

cq <= cqi;

--将计数值向端口输出

end process;end behav;(2)8位十进制频率计电路图 2、32位锁存器设计 参考程序

library ieee;use ;use ;entity reg32b is

port(load : in std_logic;

din: in std_logic_vector(31 downto 0);

dout : out std_logic_vector(31 downto 0));

end reg32b;architecture behav of reg32b is begin

process(load,din)

begin

if load'event and load='1' then

dout<=din;

end process;end behav;3控制器设计

(1)控制器时序图

(2)参考程序 library ieee;use ;use ;entity testctl is

port(clk : in std_logic;

tsten:out

std_logic;

clr_cnt: out

std_logic;

load:out

std_logic);

end testctl;architecture behav of testctl is

signal p2clk:std_logic;begin

process(clk)

begin

if clk'event and clk='1' then

p2clk<=not p2clk;

end process;

process(clk,p2clk)

begin

if clk='0' and p2clk='0'

then

clr_cnt<='1';

else clr_cnt<='0';

end if;

end process;

load<=not p2clk;

tsten<=p2clk;end behav;

end if;end if;

实验九

dac接口电路与波形发生器设计

一、实验目的及要求:

1、掌握vhdl语言的基本结构及编程思想。

2、掌握da转换器接口方法。

3、掌握da转换器的vhdl语言编程方法。

二、实验内容:

1、设计一dac0832数模转换器控制器。

2、要求使用dac转换器输出一正弦波,最大值为5v。(使用单缓冲方式)

3、要求正弦波频率能步进可调,步进间隔为100hz。(使用2个按键控制,一个步进为加,另一个为步进减)

三、实验原理

1、dac0832特点(1)、8位电流dac转换,输出为电流信号,因此要转换为电压输出,必须外接集成运算放大器。(2)、转换时间约为50---500ns,转换速度比电压型dac转换器快,电压型一般为1---10us(3)、20脚双列直插式封装的cmos型器件。(4)、内部具有两极数据寄存器,可采用单或双缓冲方式。

2、d/a转换器外部引脚功能及内部结构图

3、工作方式

方式一:直通工作方式(本实验采用此种方式)

一般用于只有一路输出信号的情况。

接线情况:ile=1,cs=wr1=wr2

=xfer=0 方式

二、双缓冲器工作方式

采用两步操作完成,可使da转换输出前一数据的同时,将采集下一个数据送到8位输入寄存器,以提高转换速度。

一般用于多路da输出。

4、da转换器与控制器接口电路设计

5、实验仪实际接口电路图

6、da转换器输出波形步进可调控制电路设计 设计思想:

设输入控制器的时钟频率为50mhz。

1、da转换一次,需要一个时钟周期。若采用64点输出,则需要64个时钟周期。如果控制器时钟频率为64hz,则输出的正弦波频率为1hz。

2、因此,只需要控制da转换控制器的时钟频率,则就可以控制正弦波频率,正弦波频率与时钟频率的 关系为1:64。

3、题目要求正弦波步进频率为100hz,则时钟频率步进应为6400hz。按“加”键,则时钟频率增加6400hz,按“减”减,时钟频率减小6400hz。

7、带按键控制da转换器与控制器接口电路设计

四、实验程序 参考程序:

library ieee;use ;entity dac0832 is

port(clk :in std_logic;

dd : out integer range 255 downto 0);end dac0832;architecture behav of dac0832 is signal q:integer range 63 downto 0;signal d : integer range 255 downto 0;begin

process(clk)

begin

if clk'event and clk='1' then q<=q+1;

end if;

end process;process(q)

begin

case q

is

when 00=>d<=254;when 01=>d<=252;when 02=>d<=249;when 03=> d<=245;

when 04=>d<=239;when 05=>d<=233;when

06=> d<=225;when

07=> d<=217;

when 08=>d<=207;when 09=>d<=197;when

10=> d<=186;when

11=> d<=174;

when 12=>d<=162;when 13=>d<=150;when 14=> d<=137;when

15=> d<=124;

when 16=>d<=112;when 17=>d<=99;when 18=> d<=87;

when

19=> d<=75;

when 20=>d<=64;when

21=>d<=53;when 22=>d<=43;

when 23=> d<=34;

when 24=>d<=26;when 25=>d<=19;when

26=> d<=13;

when

27=> d<=8;

when 28=>d<=4;

when

29=>d<=1;

when 30=>d<=0;

when

31=> d<=0;

when 32=>d<=1;when 33=>d<=4;

when 34=> d<=8;

when 35=> d<=13;when 36=>d<=19;when 37=>d<=26;

when 38=> d<=34;

when

39=> d<=43;

when 40=>d<=53;when

41=>d<=64;when 42=> d<=75;

when

43=> d<=87;

when 44=>d<=99;when 45=>d<=112;when 46=>d<=124;when

47=> d<=137;

when 48=>d<=150;when 49=>d<=162;when 50=> d<=255;when 51=> d<=174;

when 52=>d<=186;when 53=>d<=197;when 54=>d<=207;when 55=> d<=217;

when 56=>d<=225;when 57=>d<=233;when 58=> d<=239;when

59=> d<=245;

when 60=>d<=249;when 61=> d<=252;when 62=> d<=254;when 63=>d<=255;when others=>null;end case;end process;

dd<=d;

end;

实验十

七段显示器动态扫描电路设计(提高型)

实验目的及要求:

1、掌握vhdl语言的基本结构及编程思想。

2、掌握七段显示器动态扫描电路设计方法。设计要求:

1、设计一个七段数码管动态扫描电路。

2、数码管个数为8个,共阴极接法。

3、设计bcd码--七段字符码的转换电路;

4、设计一电路,控制上述电路实现“12345678”八个数字的显示,要求显示方式为:

(1)自左至右逐个点亮数码管,最后全亮;再重复以上动作,每次变化时间间隔为1秒。

(2)自左至右点亮数码管,每次只点亮一个,最后全息灭,再重复以上动作,每次变化时间间隔为1秒。

(3)先中间两个点亮,再依次向外点亮;全亮后,再依次向中间熄灭;重复上述步骤,每次变化时间间隔为1秒。一、七段显示器动态扫描电路设计框图

二、存储器设计(8位8字节静态随机存储器sram)library ieee;

use ;entity memo_rd_wr is port(wr,rd: in std_logic;

a : in std_logic_vector(2 downto 0);

b : in std_logic_vector(2 downto 0);

d : in std_logic_vector(7 downto 0);

q : out std_logic_vector(7 downto 0));end memo_rd_wr;architecture a of memo_rd_wr is

signal q0,q1,q2,q3: std_logic_vector(7 downto 0);

signal q4,q5,q6,q7: std_logic_vector(7 downto 0);begin process(wr,a)

begin

if wr='1' then

case

a

is

when “000”=>q0<=d;

when “001”=> q1<=d;

when “010”=>q2<=d;

when “011”=> q3<=d;

when “100”=>q4<=d;

when “101”=> q5<=d;

when “110”=>q6<=d;

when “111”=> q7<=d;

when others=>null;

end case;

end if;

end process;process(rd,b)

begin

if rd='1' then

case

b

is

when “000”=>q<=q0;

when “001”=> q<=q1;

when “010”=>q<=q2;

when “011”=> q<=q3;

when “100”=>q<=q4;

when “101”=> q<=q5;

when “110”=>q<=q6;

when “111”=> q<=q7;

when others=>null;

end case;

end if;

end process;end a;

四、循环取数电路设计 library ieee;

use ;entity get_code is port(clk1: in std_logic;

d : in std_logic_vector(7 downto 0);

rd:out std_logic;

a : out std_logic_vector(2 downto 0);

dout:out std_logic_vector(7 downto 0));end get_code;architecture a of get_code

is

signal load: std_logic;

signal qq : std_logic_vector(7 downto 0);

signal num: integer range 7 downto 0;begin

rd<=„1‟;

load<=clk1;process(clk1)

begin

if clk1'event and clk1='1' then

if num<=7

then

num<=num+1;

else num<=0;

end if;

end if;end process;process(num)

begin

case num is

when 0 =>a<=“000”;

when 1 =>a<=“001”;

when 2 =>a<=“010”;

when 3 =>a<=“011”;

when 4 =>a<=“100”;

when 5 =>a<=“101”;

when 6 =>a<=“110”;

when 7 =>a<=“111”;

when others =>null;

end case;

end process;process(load)

begin

if load„event and load=„1‟

then-------上升沿锁存

qq<=d;

end if;end process;dout(7 downto 0)<=qq(7 downto 0);end a;

五、扫描控制器设计 library ieee;

use ;entity scan_8 is port(clk2: in std_logic;

c : out std_logic_vector(7 downto 0));

end scan_8;architecture a of scan_8

is

signal num: integer range 7 downto 0;begin process(clk2)

begin

if clk2'event and clk2=‘1' then

if num<=7

then

num<=num+1;

else num<=0;

end if;

end if;end process;process(num)

begin

case

num

is

when 1=>c<=“11111110”;when 2=> c<=“11111101”;

when 3=>c<=“11111011”;when 4=> c<=“11110111”;

when 5=>c<=“11101111”;when 6=> c<=“11011111”;

when 7=>c<=“10111111”;when 0=> c<=“01111111”;

when

others=>null;

end case;end process;end a;

应用实例一:显示“01234567”八个数字

library ieee;

use ;entity disp_data is port(clk: in std_logic;

wr:out std_logic;

a:out std_logic_vector(2 downto 0);

q:out std_logic_vector(7 downto 0));end disp_data;architecture a of disp_data

is

--signal qq : std_logic_vector(7 downto 0);

signal num: integer range 7 downto 0;begin

wr<=„1‟;process(clk)

begin

if clk'event and clk='1' then

if num<=7

then

num<=num+1;

else num<=0;

end if;

end if;end process;process(num)

begin

case num is

when 0 =>q<=“00111111”;a<=“000”;

when 1 =>q<=“00000110”;a<=“001”;

when 2 =>q<=“01011011”;a<=“010”;

when 3 =>q<=“01001111”;a<=“011”;

when 4 =>q<=“01100110”;a<=“100”;

when 5 =>q<=“01101101”;a<=“101”;

when 6 =>q<=“01111101”;a<=“110”;

when 7 =>q<=“01111111”;a<=“111”;

when others =>null;

end case;end process;end a;实验十一

彩灯控制器设计(提高型实验)

实验目的及要求:

1、掌握vhdl语言的基本结构及编程思想。

2、掌握vhdl语言的进行系统设计的方法和步骤。

3、培养学生综合应用能力。实验内容:

1、了解各类节日彩灯的显示方式(主要是动态方式)(上街观察);

2、将你所了解的情况,画出你的设计思想框图;

3、根据框图画出电路框图(用eda技术);

4、用vhdl语言编程实现;

5、完成课程设计报告(约2000字)

实验

十二、红绿交通灯控制系统

实验目的及要求:

1、掌握vhdl语言的基本结构及编程思想。

2、掌握vhdl语言的进行系统设计的方法和步骤。

3、培养学生综合应用能力。实验内容:

设计一个简易十字路口交通灯控制器。要求:

1、每个路口有红、绿、黄三个指示灯指示交通运行情况。红灯亮,禁止车辆通行;绿灯亮,车辆正常通行。

2、利用两位数码管显示通行到计时时间。

3、用vhdl语言编程实现;

4、完成课程设计报告 实验步骤:

1、红绿黄灯秒计数选择控制电路(traffic_mux)sing_state:

00

绿灯20秒(横向路口);

01

黄灯5秒(横向路口)

绿灯20秒(直向路口)

黄灯5秒(直向路口)

recount:重新计数信号。=„1‟,发送倒计时时间数据; =„0‟,正常倒计时; library ieee;

use ;use ;

use ;entity traffic_mux is

port(reset,clk_1hz,recount: in std_logic;

sign_state: in std_logic_vector(1 downto 0);

load: out integer range 255 downto 0);end;

begin

process(reset,clk_1s)

begin

if reset='1' then

load<=“00000000”;

elsif(clk_1hz'event and clk_1hz='1')

then

if

recount = '1‘

then

case sign_state is

when “00” => load <= 20;

when “01” => load <= 5;

when “10” => load <= 20;

when “01” => load <= 5;

when others =>null;

end case;

end if;

end if;end process;end behavior;

2、倒计时控制电路(count_down)library ieee;use ;use ;use ;entity count_down is port(reset,clk_1hz: in std_logic;recount:in std_logic;load: in integer range 255 downto 0;seg7:out std_logic_vector(15 downto 0);next_state: out std_logic);end;architecture behavior of count_down is signal cnt_ff: integer range 255 downto 0;begin process(clk_1hz,reset)begin if(reset='1')then cnt_ff<=“00000000”;seg7<=“***0”;elsif(clk_1hz'event and clk_1hz='1')then if recount='1‘ then cnt_ff<=load-1;else cnt_ff<=cnt_ff-1;end if;end if;end process;process(cnt_ff)begin case cnt_ff is when 0=>seg7<=“***1”;when 1=>seg7<=“***0”;when 2=> seg7<=“***1”;when 3=> seg7<=“***1”;when 4=> seg7<=“***0”;when 5=> seg7<=“***1”;when 6=> seg7<=“***1”;when 7=> seg7<=“***1”;when 8=> seg7<=“***1”;when 9=> seg7<=“***1”;when 10=> seg7<=“***1”;when 11=> seg7<=“***0”;when 12=> seg7<=“***1”;when 13=> seg7<=“***1”;when 14=> seg7<=“***0”;when 15=> seg7<=“***1”;when 16=> seg7<=“***1”;when 17=> seg7<=“***1”;when 18=> seg7<=“***1”;when 19=> seg7<=“***1”;when 20=> seg7<=“***1”;when 21=> seg7<=“***0”;when 22=> seg7<=“***1”;when 23=> seg7<=“***1”;when 24=> seg7<=“***0”;when 25=> seg7<=“***1”;when 26=> seg7<=“***1”;when 27=> seg7<=“***1”;when 28=> seg7<=“***1”;when 29=> seg7<=“***1”;when others=> seg7<=“***1”;end case;end process;next_state <= '1' when cnt_ff=1 else '0';end behavior;

3、红绿灯信号控制电路(traffic_fsm)library ieee;use ;use ;use ;entity traffic_fsm is port(reset,clk,clk_1hz,flash_1hz: in std_logic;a_m:in std_logic;next_state: in std_logic;recount: out std_logic;sign_state: out std_logic_vector(1 downto 0);red: out std_logic_vector(1 downto 0);green: out std_logic_vector(1 downto 0);yellow: out std_logic_vector(1 downto 0));end;architecture behavior of traffic_fsm is type sreg0_type is(r0g1, r0y1, g0r1, y0r1, y0y1, y0g1, g0y1, r0r1);signal state : sreg0_type;signal light: std_logic_vector(5 downto 0);begin if(reset='1')then state<=r0g1;

----设定当前为横向红灯亮,竖向绿灯亮 sign_state<=“01”;------选择20秒倒计时

recount<=‘1’;------装入计数初值并启动倒计时 else if(clk'event and clk='1')then case state is when r0g1 => if(a_m='1' and clk_1hz='1')then if(next_state = ‘1’)then--当前计数完毕,转入下一种计时

recount<='1';state<=r0y1;sign_state <= “01”;else recount<=‘0’;state<=r0g1;----否则,继续倒计时 end if;when r0y1 =>--now state: red0 on yellow1 flash if(a_m='1' and clk_1hz='1')then if(next_state = '1')then recount<='1';state<=g0r1;sign_state <= “10”;else recount<='0';state<=r0y1;end if;when g0r1 =>--now state: green0 on red1 on if(a_m='1' and ena_1hz='1')then if(next_state = '1')then recount<='1';state<=y0r1;sign_state <= “11”;else recount<='0';state<=g0r1;end if;when y0r1 =>--now state: green0 on red1 on if(a_m='1' and ena_1hz='1')then if(next_state = '1')then recount<='1';state<=r0g1;sign_state <= “00”;else recount<='0';state<=y0r1;--red=2'b10;green=2'b00;yellow=2'b01;end if;when others => state<=r0g1;recount<='0';sign_state <= “00”;end case;end if;end if;end process;--light: r(10)y(10)g(10)light <= “010010” when(state=r0g1)else “011000” when(state=r0y1)else “100001” when(state=g0r1)else “100100” when(state=y0r1)else “110000”;red <= light(5 downto 4);yellow <= light(3 downto 2)and(flash_1hz & flash_1hz);green <= light(1 downto 0);end behavior;

EDA实验报告 EDA实验报告武汉理工大学篇二

实验四 计数器与七段译码器及显示的设计

一 实验目的

1、掌握七段译码器的工作原理;

2、学会用vhdl硬件描述语言进行数字系统设计;

3、学会运用波形仿真测试检验程序的正确性;

4、用quartusii完成基本组合电路的设计。

二 实验仪器

pc机、quartus ii 6.0软件、康芯eda实验箱

三 实验内容

选gw48系统的实验电路模式6,用数码8显示译码输出(pio46-pio40),键3到键8作为控制输入端。完成计数器的数码管显示设计。

四 实验原理及步骤

7段数码是纯组合电路,通常的小规模专用ic,如74或4000系列的器件只能作十进制bcd码译码,然而数字系统中的数据处理和运算都是2进制的,所以输出表达都是16进制的,为了满足16进制数的译码显示,最方便的方法就是利用译码程序在fpga/cpld中来实现。例6-18作为7段译码器,输出信号led7s的7位分别接如图6-2数码管的7个段,高位在左,低位在右。例如当led7s输出为“1101101”时,数码管的7个段:g、f、e、d、c、b、a分别接1、1、0、1、1、0、1;接有高电平的段发亮,于是数码管显示“5”。注意,这里没有考虑表示小数点的发光管,如果要考虑,需要增加段h,例6-18中的led7s:out std_logic_vector(6 downto 0)应改为...(7 downto 0)。

1、根据译码器真值表写出原程序。

译码器真值表:

输入

输出

值 a

b c d a b c d e f g 0 0 0 0 0 1 1 1 1 1 1 0 1 0 0 0 1 0 1 1 0 0 0 0 2 0 0 1 0 1 1 0 1 1 0 1 3 0 0 1 1 1 1 1 1 0 0 1 4 0 1 0 0 0 1 1 0 0 1 1 5 0 1 0 1 1 0 1 1 0 1 1 6 0 1 1 0 1 0 1 1 1 1 1 0 1 1 1 1 1 1 0 0 0 0 8 1 0 0 0 1 1 1 1 1 1 1 9 1 0 0 1 1 1 1 1 0 1 1 a 0 1 0 1 1 1 0 1 1 1 b 1 0 1 1 0 0 1 1 1 1 1 c 1 1 0 0 1 0 0 1 1 1 0 d 1 1 0 1 0 1 1 1 1 0 1 e 1 1 1 0 1 0 0 1 1 1 1 f 1 1 1 1 1 0 0 0 1 1 1

三、实验内容:

1、说明下列程序中各语句的含义,以及该例的整体功能。在quartus ii 6.0上对以下该例进行编辑、编译、综合、适配、仿真,给出其所有信号的时序仿真波形(提示:用输入总线的方式给出输入信号仿真数据)。

library ieee;use ;entity decl7s is port(a : in std_logic_vector(3 downto 0);led7s : out std_logic_vector(6 downto 0));end;architecture one of decl7s is begin process(a)begin case a(3 downto 0)is when “0000” => led7s <= “0111111”;--x“3f”0 when “0001” => led7s <= “0000110”;--x“06”1 when “0010” => led7s <= “1011011”;--x“5b”2 when “0011” => led7s <= “1001111”;--x“4f”3 when “0100” => led7s <= “1100110”;--x“66”4 when “0101” => led7s <= “1101101”;--x“6d”5 when “0110” => led7s <= “1111101”;--x“7d”6 when “0111” => led7s <= “0000111”;--x“07”7 when “1000” => led7s <= “1111111”;--x“7f”8 when “1001” => led7s <= “1101111”;--x“6f”9 when “1010” => led7s <= “1110111”;--x“77”10 when “1011” => led7s <= “1111100”;--x“7c”11 when “1100” => led7s <= “0111001”;--x“39”12 when “1101” => led7s <= “1011110”;--x“5e”13 when “1110” => led7s <= “1111001”;--x“79”14 when “1111” => led7s <= “1110001”;--x“71”15 when others => null;end case;end process;end;

图3-1 共阴数码管及其电路

2、引脚锁定以及硬件下载测试。建议选实验电路模式6,用数码8显示译码输出(pio46--pio40),键

8、键

7、键

6、键5四位控制输入,硬件验证译码器的工作性能。

3、用vhdl完成四位二进制加法计数器设计,命名为cnt4b.4、用vhdl例化语句(参考实验1中的1位全加vhdl文本输入设计)按图3-2 的方式,完成顶层文件设计,并重复以上实验过程。注意图3-2中的tmp是4位总线,led是7位总线。对于引脚锁定和实验,建议仍选实验电路模式6,用数码8显示译码输出,用键3作为时钟输入(每按2次键为1个时钟脉冲),或直接时钟信号clock0。

图3-2 计数器和译码器连接电路的顶层文件原理图

(提示:

1、将教材p89页程序和p154页程序读懂,分别建立工程、生成各自原理图。

2、将上述两个原理图按教材p155页图6-19连接起来建立新的原理图设计文件。

3、将上述原理图文件编译、仿真、引脚绑定,下载到实验箱验证。)

四、实验报告要求

1、总结quartus ii 6.0 vhdl 中case语句应用及多层次设计方法

2、根据以上的实验内容写出实验报告,包括程序设计、软件编译、仿真分析、硬件测试和实验过程;设计程序、程序分析报告、仿真波形图及其分析报告;

3、心得体会――本次实验中你的感受;你从实验中获得了哪些收益;本次实验你的成功之处;本次实验中还有待改进的地方;下次实验应该从哪些地方进行改进;怎样提高自的实验效率和实验水平等等。

五、问题与思考:

只要求译出数字0~9和“-”,怎样修改程序?

EDA实验报告 EDA实验报告武汉理工大学篇三

数字eda实验报告--------------薛蕾0941903207

数字eda实验 实验报告

学院: 计算机科学与工程学院 专业: 通信工程 学号: 0941903207 姓名: 薛蕾 指导老师: 钱强

数字eda实验报告--------------薛蕾0941903207 实验一 四选一数据选择器的设计

一、实验目的

1、熟悉quartus ii软件的使用。

2、了解数据选择器的工作原理。

3、熟悉eda开发的基本流程。

二、实验原理及内容

实验原理

数据选择器在实际中得到了广泛的应用,尤其是在通信中为了利用多路信号中的一路,可以采用数据选择器进行选择再对该路信号加以利用。从多路输入信号中选择其中一路进行输出的电路称为数据选择器。或:在地址信号控制下,从多路输入信息中选择其中的某一路信息作为输出的电路称为数据选择器。数据选择器又叫多路选择器,简称mux。4选1数据选择器:

(1)原理框图:如右图。

d0、d1、d2、d3

:输入数据 a1、a0

:地址变量

由地址码决定从4路输入中选择哪1路输出。

(2)真值表如下图:(3)逻辑图

数据选择器的原理比较简单,首先必须设置一个选择标志信号,目的就是为了从多路信号中选择所需要的一路信号,选择标志信号的一种状态对应着一路信号。在应用中,设置一定的选择标志信号状态即可得到相应的某一路信号。这就是数据选择器的实现原理。

三.实验内容

1、分别采用原理图和vhdl语言的形式设计4选1数据选择器

2、对所涉及的电路进行编译及正确的仿真。电路图:

四、实验程序

library ieee;use ;

entity mux4 is

port(a0, a1, a2, a3 :in std_logic;

s :in std_logic_vector(1 downto 0);

y :out std_logic);end mux4;architecture archmux of mux4 is

begin y <= a0 when s = “00” else

--当s=00时,y=a0 a1 when s = “01” else

--当s=01时,y=a1 a2 when s = “10” else

--当s=10时,y=a2 a3;

--当s取其它值时,y=a2 end archmux;

五、运行结果

六.实验总结

真值表分析:

当js=0时,a1,a0取00,01,10,11时,分别可取d0,d1,d2,d3.实验二 血型配对器的设计

一、实验目的

1、进一步熟悉quartus ii软件的使用。

2、掌握简单组合逻辑电路的设计方法与功能仿真技巧。

3、进一步学习quartus ii中基于原理图设计的流程。

二、实验原理及内容

实验原理

人类有o、a、b、ab 4种基本血型,输血者与受血者的血型必须符合图示原则。设计一血型配对电路,用以检测输血者与受血者之间的血型关系是否符合,如果符合,输出为1,否则为0。

已知: ab血型是万能受血者,o血型是万能献血者!如果要输血给o型血,那么可以的血型是o型!如果要输血给a型血,那么可以的血型是a,o型!如果要输血给b型血,那么可以的血型是b,o型!

如果要输血给ab型血,那么可以的血型是a,b,ab,o型!

输血者

受血者

o a

o a b ab

b ab

三.实验内容

1、用vhdl语言编写程序实现血型配对器的功能 library ieee;use ;use ;use ;entity vxuexing is port(p,q,r,s:in std_logic;f:out std_logic);end vxuexing;architecture a of vxuexing is begin

f<=((not p)and(not q))or(r and s)or((not p)and s)or((not q)and r);end a;

2、对所编写的电路进行编译及正确的仿真。

实验分析 真值表

pqrsf***************11111

p,q表示输血者的血型;r,s,表示受血者的血型。当两者符合血型配合原则时,f=1,否则为0.四、运行结果

五、实验总结

本实验给出了四种不同的血型编码,pq(1,1),rs(1,1)表示ab型血,p,q(1,0),rs(1,0)表示b型血,pq(0,1),rs(0,1)表示a型血,pq(0,0),rs(0,0)表示o型血。根据真值表,并根据实验的原理图,画出电路图并进行连接。

实验三 简单数字钟的设计

一、实验目的

1、了解数字钟的工作原理。

2、进一步学习quartus ii中基于vhdl设计的流程。

3、掌握vhdl编写中的一些小技巧。

4、掌握简单时序逻辑电路的设计方法与功能仿真技巧。

二、实验原理及内容

实验原理

简单数字钟应该具有显示时-分-秒的功能。首先要知道钟表的工作机理,整个钟表的工作应该是在1hz信号的作用下进行,这样每来一个时钟信号,秒增加1秒,当秒从59秒跳转到00秒时,分钟增加1分,同时当分钟从59分跳转

三.实验内容

1、用原理图的方式编写一个12/24进制的计数器,并创建为symbol文件。

2、用vhdl的方式编写一个60进制的计数器,并创建为symbol文件。

3、创建顶层文件。调用已编写的symbol文件,设计简单的数字钟电路。

2、对所编写的电路进行编译及正确的仿真。

二十四进制vhdl library ieee;use ;use ;use ;entity cnt24 is port(cp, en, rd, ld :in std_logic;

d

:in std_logic_vector(5 downto 0);

co

:out std_logic;q

:out std_logic_vector(5 downto 0));end cnt24;architecture str of cnt24 is

signal qn : std_logic_vector(5 downto 0);

begin co<= '1'when(qn = “010111”and en='1')

else '0';process(cp, rd)

begin if(rd ='0')then

qn<= “000000”;elsif(cp'event and cp='1')then if(ld='0')then qn <= d;

elsif(en='1')then qn <= qn+1;end if;end if;end process;q <= qn;end str;

六十进制vhdl library ieee;use ;use ;use ;entity jsq60 is port(en,rd,cp :in std_logic;

qh:buffer std_logic_vector(3 downto 0);

ql :buffer std_logic_vector(3 downto 0);

co :out std_logic);end jsq60;architecture b of jsq60 is begin co<='1'when(qh=“0101”and ql=“1001” and en='1')else'0';process(cp,rd)

begin if(rd='0')then qh<=“0000”;ql<=“0000”;elsif(cp'event and cp='1')then

if(en='1')then

if(ql=9)then

ql<=“0000”;

if(qh=5)then

qh<=“0000”;

else qh<=qh+1;

end if;

else

ql<=ql+1;

end if;

end if;

end if;end process;end b;

原理图

四、运行结果

24进制

60进制

时钟仿真结果

五、实验总结

此设计问题可分为主控电路,计数器模块和扫描显示三大部分,计数器在之前的学习中已经非常熟悉,只要掌握60,12进制的技术规律,用同步或异步计数器都可以实现。二扫描电路我们学过两种驱动方式:bcd码驱动方式和直接驱动方式。

实验四 简单交通灯的设计

一、实验目的

1、了解交通灯的亮灭规律。

2、了解交通灯控制器的工作原理。

3、进一步熟悉vhdl语言编程,了解实际设计中的优化方案。

二、实验原理及内容

实验原理

交通灯的显示有很多方式,如十字路口、丁字路口等,而对于同一个路口又有很多不同的显示要求,比如十字路口,车子如果只要东西和南北方向通行就很简单,而如果车子可以左右转弯的通行就比较复杂,本实验仅针对最简单的南北和东西直行的情况。

要完成本实验,首先必须了解交通路灯的亮灭规律。依人们的交通常规,“红灯停,绿灯行,黄灯提醒”。其交通灯的亮灭规律为:初始态是两个路口的红灯全亮,之后东西路口的绿灯亮,南北路口的红灯亮,东西方向通车,延时一段时间后,东西路口绿灯灭,黄灯开始闪烁。闪烁若干次后,东西路口红灯亮,而同时南北路口的绿灯亮,南北方向开始通车,延时一段时间后,南北路口的绿灯灭,黄灯开始闪烁。闪烁若干次后,再切换到东西路口方向,重复上述过程。

三.实验内容

1、用vhdl的方式编写一个简单的交通控制灯电路

2、对所编写的电路进行编译及正确的仿真。

程序: library ieee;use ;use ;

entity traffic is port(clk,enb : in std_logic;

ared,agreen,ayellow,bred,bgreen,byellow : buffer std_logic;

acounth,acountl,bcounth,bcountl : buffer std_logic_vector(3 downto 0));end traffic;

architecture one of traffic is begin process(clk,enb)variable lightstatus : std_logic_vector(5 downto 0);begin

if(clk'event and clk='1')then lightstatus := ared&agreen&ayellow&bred&bgreen&byellowif((acounth=“0000” and acountl=“0000”)or(bcounth=“0000” and bcountl=“0000”))then case lightstatus is when “010100”=> lightstatus:=“001100”;acountl<=“0101”;acounth<=“0000”;bcountl<=“0101”;bcounth<=“0000”;when “001100”=> if(enb='1')then lightstatus:=“100010”;acountl<=“0000”;acounth<=“0011”;bcountl<=“0101”;bcounth<=“0010”;

else lightstatus:=“010100”;acountl<=“0101”;acounth<=“0100”;bcountl<=“0000”;bcounth<=“0101”;end if;

when “100010”=>

lightstatus:=“100001”;acountl<=“0101”;acounth<=“0000”;bcountl<=“0101”;bcounth<=“0000”;

when “100001”=>

lightstatus:=“010100”;acountl<=“0101”;acounth<=“0100”;bcountl<=“0000”;bcounth<=“0101”;

when others=> lightstatus:=“010100”;acountl<=“0101”;acounth<=“0100”;bcountl<=“0000”;bcounth<=“0101”;

end case;else if(acountl=“0000”)then acounth<=acounth-1;acountl<=“1001”;

else acountl<=acountl-1;

end if;

if(bcountl=“0000”)then bcounth<=bcounth-1;bcountl<=“1001”;

else bcountl<=bcountl-1;end if;end if;end if;

ared<=lightstatus(5);agreen<=lightstatus(4);ayellow<=lightstatus(3);

bred<=lightstatus(2);bgreen<=lightstatus(1);byellow<=lightstatus(0);end process;end one;

四、运行结果

分析:

这里a代表东西方向,b代表南北方向,acounth是表示东西方向五进制计数acountl是东西方向六进制计数,bcounth则表示南北方向五进制,bounthl则是南北方向六进制计数 东西方向为0时,东西方向红灯亮(ared=1)

东西方向在1~4之间,东西方向绿灯亮(即agreen=1)南北方向 的红灯亮起(即bred=1)

五、实验总结

此设计问题可分为主控电路,译码驱动电路和扫描显示部分。

但是,这远远不能满足实际生活的需要,还应设置倒计时秒数,因此可在此电路基础上外加一个定时模块。

实验五 流水灯的设计

一、实验目的

1、了解流水灯的工作原理。

二、实验原理及内容

实验原理

要完成本实验,首先必须了解流水灯的原理。所谓的流水灯实际上就是由多个led发光二极管构成的电路,当发光二极管可以依次点亮时,即能呈现流水的效果。实验内容

1、设计能带8个led发光管发光,并按照要求轮流发光,产生流水灯的流动效果。

2、应具有两种以上不同风格的流动闪亮效果。比如依次点亮或者依次熄灭。(选作)

3、有起动、停止控制键。(选作)

4、有流动闪亮效果选择设置键。(选作)

5、对所编写的电路进行编译及正确的仿真。

三、实验程序

library ieee;use ;use ;use ;entity yiweijicun1 is port(cp,r,dsr,dsl:in std_logic;

s:std_logic_vector(2 downto 0);

d:std_logic_vector(7 downto 0);

q:out std_logic_vector(7 downto 0));end yiweijicun1;architecture yiweijicun_arch of yiweijicun1 is

signal iq: std_logic_vector(7 downto 0);begin process(cp,r,iq)begin if(r='1')then iq <=(others =>'0');elsif(cp'event and cp ='1')then case conv_integer(s)is when 0=>null;when 1=> iq <= d;when 2=> iq <= dsr & iq(7 downto 1);when 3=> iq <=iq(6 downto 0)& dsl;when 4=> iq <= iq(0)& iq(7 downto 1);when 5=> iq <=iq(6 downto 0)& iq(7);when 6=> iq <= iq(7)& iq(7 downto 1);when 7=> iq <= iq(6 downto 0)& iq(0);when others => null;end case;end if;q <= iq;end process;end yiweijicun_arch;

四、运行结果

结果分析:

d[0]~d[7]为八个输入端,s[0]和s[1]控制流水灯得输出,s=1保持,s=2实现左移功能,s=3实现右移功能,因为延迟的原因,在s=2时,需要经过一段时间才能实现循环右移的功能,流水灯的实现其实是运用了8位移位寄存器,它只是运用了其中的保持左移与右移的功能,8lo位移位寄存器还有循环右移,循环左移,算数右移,算数左移等功能。

五、实验总结

了解了移位寄存器的功能和原理

通过这次实验,加深了vhdl语言的运用能力,更进一步了解了8位移位寄存器的功能。

实验六 乘法器的设计

一、实验目的

1、了解乘法器的工作原理。

2、了解复杂时序电路的设计流程。

二、实验原理及内容

实验原理

具体设计原理参见教材188页。实验内容

1、设计一个能进行两个十进制数相乘的乘法器,乘数和被乘数均小于100。(可以参考教材231页的vhdl代码来设计)

2、对所编写的电路进行编译及正确的仿真。

三、实验程序

library ieee;use ;

entity one_bit_adder is port(a: in std_logic;b: in std_logic;c_in: in std_logic;s: out std_logic;c_out: out std_logic);end one_bit_adder;

architecture one_bit_adder of one_bit_adder is begin

s <= a xor b xor c_in;c_out <=(a and b)or(c_in and(a xor b));

end one_bit_adder;library ieee;use ;

entity sichen is port(a: in std_logic_vector(3 downto 0);b: in std_logic_vector(3 downto 0);data_out: out std_logic_vector(6 downto 0));end sichen;

architecture multi_arch of sichen is signal a_mult_b0: std_logic_vector(2 downto 0);signal a_mult_b1: std_logic_vector(2 downto 0);signal a_mult_b2: std_logic_vector(2 downto 0);

signal s_temp1: std_logic_vector(1 downto 0);signal s_temp2: std_logic_vector(1 downto 0);

signal c_temp : std_logic_vector(6 downto 0);

signal c0_out_b0, c1_out_b0, c2_out_b0 : std_logic;signal c0_out_b1, c1_out_b1, c2_out_b1 : std_logic;

signal zero: std_logic;

component one_bit_adder port(a: in std_logic;b: in std_logic;c_in: in std_logic;s: out std_logic;c_out: out std_logic);end component;begin u_0_0 : one_bit_adder port map(a => a_mult_b0(1), b => a_mult_b1(0), c_in => zero, s => c_temp(1), c_out => c0_out_b0);u_0_1 : one_bit_adder port map(a => a_mult_b0(2), b => a_mult_b1(1), c_in => c0_out_b0, s => s_temp1(0), c_out => c1_out_b0);u_0_2 : one_bit_adder port map(a => zero, b => a_mult_b1(2), c_in => c1_out_b0, s => s_temp1(1), c_out => c2_out_b0);

u_1_0 : one_bit_adder port map(a => a_mult_b2(0), b => s_temp1(0), c_in => zero, s => c_temp(2), c_out => c0_out_b1);u_1_1 : one_bit_adder port map(a => a_mult_b2(1), b => s_temp1(1), c_in => c0_out_b1, s => s_temp2(0), c_out => c1_out_b1);u_1_2 : one_bit_adder port map(a => a_mult_b2(2), b => c2_out_b0, c_in => c1_out_b1, s => s_temp2(1), c_out => c2_out_b1);

a_mult_b0(0)<= a(0)and b(0);a_mult_b0(1)<= a(1)and b(0);a_mult_b0(2)<= a(2)and b(0);

a_mult_b1(0)<= a(0)and b(1);a_mult_b1(1)<= a(1)and b(1);a_mult_b1(2)<= a(2)and b(1);

a_mult_b2(0)<= a(0)and b(2);a_mult_b2(1)<= a(1)and b(2);a_mult_b2(2)<= a(2)and b(2);

zero <= '0';c_temp(0)<= a_mult_b0(0);c_temp(4 downto 3)<= s_temp2(1 downto 0);c_temp(5)<= c2_out_b1;

c_temp(6)<= a(3)xor b(3);

data_out <= c_temp;

end multi_arch;

四、运行结果

乘法器实现a,b两数的相乘。a[0]~a[3]以及b[0]~b[3]是实现输入端的控制。由图看出,输出上产生了延迟是因为当a[3]输入1,对应了十进制的8,b[0]输入1,对应了十进制的1,两者相乘得8,即在data_out端应输出8,此处因仍存在竞争冒险。

五、实验总结

乘法器的设计的问题可以分为乘数和被乘数控制模块,寄存模块,乘法模块和扫描显示模块几个部分。

两数相乘的方法很多,可以用移位相加的方法,也可以将乘法器看成计数器,乘积的初始值为零,每一个时钟周期将被乘数的值加到积上,同时乘数减一,这样反复执行,直到乘数为零。

EDA实验报告 EDA实验报告武汉理工大学篇四

实验二

数字秒表设计

一、实验目的

1、理解计时器的原理与verilog/vhdl 的编程方法;

2、掌握多模块设计及层次设计的方法。

二、实验原理

秒计时器是由计数器和译码器、显示器组成,其核心是计数器与译码器。60 秒计时器可由二个计数器分别完成:个位为十进制计数器,十位为 6 进 制计数。个位计数器的计数信号由实验开发板上主频20mhz分频产生的1hz 时钟信号提供, 十位计数器的计数信号由个位的进位信号提供。然后由译码器 对计数结果进行译码,送led 数码管进行显示。clr为清零,se t为开始。

三、实验框图

四、实验任务

1、采用层次设计的方法,设计一个包括顶层及底层模块的60 秒计时器,底 层模块用verilog/vhdl 设计,顶层用原理图设计。

2、秒计时器应当具有系统复位功能;

3、每十秒发出提示信号及计满60 秒时发出报警信号。(选做)

五、实验步骤与要求

1、分模块设计:首先分别设计10 进制、6 进制计数器、译码器模块;

2、顶层原理图如图7-1 所示;

3、编译完成后进行波形仿真;

4、进行引脚锁定,并下载至开发系统验证。

六、分模块设计 1.十进制计数器(1)程序代码:

module cnt10(clk,rst,en,cout,dout);

input clk,en,rst;

output [3:0]dout;

output cout;

reg[3:0]q1;

reg cout;

assign dout=q1;

always@(posedge clk or negedge rst)

begin

if(!rst)q1<=0;

else if(en)begin

if(q1<9)q1<=q1+1;

else q1<=4'b0000;end

end

always@(q1)

if(q1==4'h9)cout=1'b1;

else cout=1'b0;endmodule

(2)仿真波形

(3)模块符号

2.六进制计数器(1)程序代码:

module cnt6(clk,rst,en,cout,dout);

input clk,en,rst;

output [3:0]dout;

output cout;

reg[3:0]q2;

reg cout;

assign dout=q2;

always@(posedge clk or negedge rst)

begin

if(!rst)q2<=0;

else if(en)begin

if(q2<5)q2<=q2+1;

else q2<=3'b000;end

end

always@(q2)

if(q2==3'h5)cout=1'b1;

else cout=1'b0;endmodule

(2)仿真波形

(3)模块符号

3.分频器

(1)程序代码:

module fpq(clk0,clk1);

input clk0;

output clk1;

reg[26:0] q1;

reg clk1;always@(posedge clk0)

if(q1<10)q1<=q1+1;

else

begin q1<=0;

clk1<=~clk1;

end endmodule(2)模块符号

七.顶层原理图:

八.仿真波形

九.结果分析

当输入端clk,en,rst都不为0时,首先是十进制计数器开始进行计时,直到dout1输出端大于9时产生进位,并且自身变为0,同时使六进制计数器也开始计时,六进制输出端dout2大于5时产生进位,使cout输出为1.

EDA实验报告 EDA实验报告武汉理工大学篇五

《电子设计自动化实验》课程设计

题 目: 十六位硬件乘加器电路 姓 名: 江 璐 学院班级: 13级电子信息工程2班 学 号: 1315212017 指导老师: 邱应强老师 时 间: 20151122 目 录 一:摘要……………………………………………………3 二: 正文……………………………………………………3(一)系统设计………………………………………………3(二)单元电路设计…………………………………………4(三)仿真结果………………………………………………9(四)软件设计………………………………………………11(五)系统测试………………………………………………11(六)结论……………………………………………………14 三:参考文献………………………………………………14 四:附录……………………………………………………15 六:心得体会………………………………………………16 一:摘要

1.实验要求:采用并行、串行或流水线方式来实现对8个16位数据进行乘法和加法运算(yout=a0b0+a1b1+a2b2+a3b3),位宽16位。

2.实验方法:使用乘法器lpm_mult2、16位加法器adder16b、计数器cnt16以及锁存器en_dff四个模块。当clock出现上升沿时,对输入端输入的两个数dataa、datab进行乘法运算。将结果输入锁存器中,锁存上一阶段计算得到的值,16位加法器adder16b将锁存器锁存的上一阶段的值与进行完乘法计算得到的值dataa*datab加起来,并输出结果。计数器cnt16用于区分四组乘加所得数,当有一个上升沿脉冲送入cnt16时,若计数不到5,则进行计数+1,若计数达到5,cout输出进位信号到锁存器en_dff的reset端口,将锁存器复位清零,重新进行计数。

3.实验结论:经过仿真与硬件测试检验后证实可行,但是是对8个8位数据进行乘法和加法运算。

二:正文

(一)系统设计

1.设计要求

采用并行、串行或流水线方式来实现对8个16位数据进行乘法和加法运算(yout=a0*b0+a1*b1+a2*b2+a3*b3),位宽16位。

2.系统设计方案

(1)系统设计思路:由十六位加法器构成以时序逻辑方式设计的十六位乘加器,流水线方式,以移位加法为核心器件。(2)总体方案的论证与比较

方案一:采用四个乘法器,以串行方式输入各数据。

方案二:采用一个乘法器,先输入两数据进行运算,将得到结果保存,并与下一组乘法运算得到的结果相加。

方案的选择:第一种方案浪费大量的资源,考虑到实验箱条件限制,采用第二种方案。尽管速度较慢,但可省下相当多的资源,并且实验室可以实现。(3)各功能块的划分与组成

共有4个设计模块,分别是乘法器lpm_mult0、16位加法器adder16b、计数器cnt16以及锁存器en_dff。(4)系统的工作原理

以上是电路原理图。乘数dataa与被乘数datab输入乘法器lpm_mult0中,当start有上升沿出现时,乘法器计算出dataa*datab的结果并有result[15..0]输出。result[15..0]输出的结果送入8位加法器adder8b的a[15..0]输入端,加法器的b[15..0]输入端连接到锁存器en_dff的输出端q[15..0],这样锁存器锁存的值就可以与加法器所得到的值相加,得到两对乘法计算后值得和,以此类推,可以得到不断累加的值。而cin端口接地,这样可以确保cin端口不影响加法器的计算。加法器计算a[15..0](dataa*datab)和锁存器锁存的值b[15..0]的和从输出端s[15..0]输出,输入锁存器en_dff的输入端d[15..0],将数值锁存起来,同时输出端s[15..0]接到输出端yout[15..0],从而从仿真中可以看到每一阶段累加的结果。而计数器cnt16的作用是区分四组乘加所得数与四组乘加所得数。en接高电平,rst接低电平,保证计数器可用,clk接到start,每当有一个上升沿脉冲送入cnt16时,若计数不到5,则进行计数+1,若计数达到5,cout输出进位信号到锁存器en_dff的reset端口,将锁存器复位清零,重新进行计数。

(二)单元电路设计

总共有四大模块,分别为乘法器lpm_mult0、16位加法器adder16b、计数器cnt16以及锁存器en_dff。

1.乘法器lpm_mult0:当clock出现上升沿时,对输入端输入的两个数dataa、datab进行乘法运算。程序:

--megafunction wizard: %lpm_mult% 4--generation: standard--version: wm1.0--module: lpm_mult--==============--file name: --megafunction name(s):------simulation library files(s):--lpm--==============--************************************************************--this is a wizard-generated not edit this file!----7.2 build 151 09/26/2007 sj full version--************************************************************--copyright(c)1991-2007 altera corporation--your use of altera corporation's design tools, logic functions--and other software and tools, and its ampp partner logic--functions, and any output files from any of the foregoing--(including device programming or simulation files), and any--associated documentation or information are expressly subject--to the terms and conditions of the altera program license--subscription agreement, altera megacore function license--agreement, or other applicable license agreement, including,--without limitation, that your use is for the sole purpose of--programming logic devices manufactured by altera and sold by--altera or its authorized refer to the--applicable agreement for further y ieee;use ;library lpm;use ;entity lpm_mult0 is port();end lpm_mult0;architecture syn of lpm_mult0 is signal sub_wire0 : std_logic_vector(15 downto 0);clock dataa datab result

: in std_logic;

: in std_logic_vector(7 downto 0);: in std_logic_vector(7 downto 0);: out std_logic_vector(15 downto 0)lpm_mult 5 component lpm_mult generic();port();end component;begin result <= sub_wire0(15 downto 0);lpm_mult_component : lpm_mult generic map()port map();end syn;--==============--cnx file retrieval info--==============--retrieval info: private: autosizeresult numeric “1”--retrieval info: private: b_isconstant numeric “0”--retrieval info: private: constantb numeric “0”--retrieval info: private: intended_device_family string “cyclone ii”--retrieval info: private: lpm_pipeline numeric “1” dataa => dataa, datab => datab, clock => clock, result => sub_wire0 lpm_hint => “dedicated_multiplier_circuitry=yes,maximize_speed=5”, lpm_pipeline => 1, lpm_representation => “unsigned”, lpm_type => “lpm_mult”, lpm_widtha => 8, lpm_widthb => 8, lpm_widthp => 16

dataa datab clock result

: in std_logic_vector(7 downto 0);: in std_logic_vector(7 downto 0);: in std_logic;

: out std_logic_vector(15 downto 0)lpm_hint

: string;

: natural;

: string;lpm_pipeline lpm_type lpm_widtha lpm_widthb lpm_widthp lpm_representation

: string;

: natural;: natural;: natural 6--retrieval info: private: latency numeric “1”--retrieval info: private: optionalsum numeric “0”--retrieval info: private: synth_wrapper_gen_postfix string “1”--retrieval info: private: signedmult numeric “0”--retrieval info: private: use_mult numeric “1”--retrieval info: private: validconstant numeric “0”--retrieval info: private: widtha numeric “8”--retrieval info: private: widthb numeric “8”--retrieval info: private: widthp numeric “16”--retrieval info: private: widths numeric “1”--retrieval info: private: aclr numeric “0”--retrieval info: private: clken numeric “0”--retrieval info: private: optimize numeric “0”--retrieval

info:

constant:

lpm_hint

string “dedicated_multiplier_circuitry=yes,maximize_speed=5”--retrieval info: constant: lpm_pipeline numeric “1”--retrieval info: constant: lpm_representation string “unsigned”--retrieval info: constant: lpm_type string “lpm_mult”--retrieval info: constant: lpm_widtha numeric “8”--retrieval info: constant: lpm_widthb numeric “8”--retrieval info: constant: lpm_widthp numeric “16”--retrieval info: used_port: clock 0 0 0 0 input nodefval clock--retrieval info: used_port: dataa 0 0 8 0 input nodefval dataa[7..0]--retrieval info: used_port: datab 0 0 8 0 input nodefval datab[7..0]--retrieval info: used_port: result 0 0 16 0 output nodefval result[15..0]--retrieval info: connect: @dataa 0 0 8 0 dataa 0 0 8 0--retrieval info: connect: result 0 0 16 0 @result 0 0 16 0--retrieval info: connect: @datab 0 0 8 0 datab 0 0 8 0--retrieval info: connect: @clock 0 0 0 0 clock 0 0 0 0--retrieval info: library: lpm --retrieval info: gen_file: type_normal true--retrieval info: gen_file: type_normal false--retrieval info: gen_file: type_normal true--retrieval info: gen_file: type_normal true false--retrieval info: gen_file: type_normal false--retrieval info: gen_file: type_normal true--retrieval info: gen_file: type_normal lpm_mult0_wave*.jpg false--retrieval info: gen_file: type_normal lpm_mult0_syn.v true--retrieval info: lib_file: lpm

2.16位加法器adder16b:将锁存器锁存的上一阶段的值与进行完乘法计算得到的值dataa*datab加起来,并输出结果。程序:

library ieee;use ;use ;entity adder16b is port(cin:in std_logic;a,b :in std_logic_vector(15 downto 0);s :out std_logic_vector(15 downto 0);cout:out std_logic);end adder16b;architecture behav of adder16b is signal sint,aa,bb:std_logic_vector(16 downto 0);begin aa <= '0' & a;bb <= '0' & b;sint <= aa+bb+cin;s <= sint(15 downto 0);cout <= sint(4);end behav;

3.计数器cnt16:区分每两组乘加所得数。clk接到start,每当有一个上升沿脉冲送入cnt16时,若计数不到5,则进行计数+1,若计数达到5,cout输出进位信号到锁存器en_dff的reset端口,将锁存器复位清零,重新进行计数。程序:

library ieee;use ;use ;entity cnt16 is port(clk,rst,en:in std_logic;cq:out std_logic_vector(3 downto 0);cout:out std_logic);end cnt16;architecture behav of cnt16 is begin process(clk,rst,en)variable cqi:std_logic_vector(3 downto 0);begin if rst='1' then cqi:=(others=>'0');elsif clk'event and clk='1'then if en='1' then if cqi < 5 then cqi:=cqi+1;else cqi:=(others=>'0');end if;end if;end if;if cqi=5 then cout<='1';else cout<='0';end if;cq<=cqi;8 end process;end behav;4.锁存器en_dff:锁存上一阶段计算得到的值,从而使加法器实现累加功能。程序:

library ieee;use ;entity en_dff is port(d: in std_logic_vector(15 downto 0);reset,en,clk:in std_logic;q: buffer std_logic_vector(15 downto 0));end en_dff;architecture behavior of en_dff is begin process(reset,clk)begin if reset='1' then q<=“***0”;elsif clk'event and clk='1'then if en='1'then q<=d;else q<=q;end if;end if;end process;end behavior;

(三)仿真结果

(1)乘法器

给clock一个时钟信号,验证得当clock处于上升沿时result=dataa*datab

(2)16位加法器adder16b 将cin接低电平,随意设置a、b的值,s为a、b的和。

(3)计数器cnt16 给clk一个时钟信号。首先将rst置低电平,en置高电平,验证计数器的计数功能。再分别将rst置高电平、en置低电平,验证计数器的复位清零以及使能端控制功能。

(4)锁存器en_dff 给clk一个时钟信号。当reset=1时,锁存器清零,当reset=0时有上升沿且使能端en=1时,d锁存进锁存器中;当有上升沿但是使能端en=0时,d值不锁存进锁存器中,锁存器的值不改变。

(四)软件设计

1.软件设计平台:quartusii 7.2 2.实现方法:通过quartusii 7.2进行vhdl语言编程、方阵、引脚配置,然后烧入 gw48实验平台,选择模式no.1,进行硬件验证。

3.程序的流程方框图:

4.实现的功能:位宽16位;能对8个16位数据进行乘法和加法运算(yout=a0*b0+a1*b1+a2*b2+a3*b3),并行、串行或流水线方式。

(五)系统测试

1.系统的性能指标(1)总图(2)乘法器lpm_mult0

(3)8位加法器adder8b

(4)计数器cnt16(5)锁存器en_dff

2.功能仿真

3.引脚绑定

确定波形仿真成功后,再配置管脚,将程序烧录进ep2c5t144c8中,进行测试。选择模式1,管脚配置图如下(start设置为键8,使得人为可控,更方便调试)

(六)结论

根据硬件验证:键1和键2输入一个十六位数,键3和键4输入另一个十六位数,数码管1、2显示第一个数,3、4显示第二个数,键8是运算键,每点击一次运算一次,为一组运算,运算结果显示在数码管5、6、7、8,将显示这两个数的积,再次输入两个十六位数,数码管5、6、7、8将显示这两个数的积与前一组数积的和,依次输入四组十六位数,完成一次十六位乘加的运算,且结果显示在数码管5、6、7、8。能够实现对8个16位数据进行乘法和加法运算(yout=a0*b0+a1*b1+a2*b2+a3*b3)

三:参考文献

潘松,技术与vhdl(第3版)——清华大学出版社

潘松,技术实用教程—vhdl版(第4班)——科学出版社 四:附录

1.实验电路结构图

48系统引脚对照表

五.心得体会

本次的课程设计选题时间较短,由于不怎么会写程序,所以乘法器使用quartus ii生成,而其他模块是在网上找的资料,自己输入编译反复修改而成。总体来说过程比较顺利,但不足之处是不能完全实现设计要求。

您可能关注的文档