版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、VHDL 与 Verilog HDL 的对比1整体结构 VHDL Verilog HDLentity 实体名 is module 模块名(端口列表) port(端口说明 ) 输入/输出端口说明 end architecture 结构体名 of 实体名 is 说明部分; 变量类型说明; begin代入语句; assign 语句 (连续赋值语句);元件语句; 元件例化语句; 进程语句; always 块语句;end 结构体名; endmodule点评: 两者结构基本相似,并行语句的种类也类似; VHDL语言需要进行大量说明,程序通常比较长;Verilog HDL通常不进行说明,或只进行非常简短的说
2、明,程序比较简短。2数据对象及类型VHDL 常量 信号 变量 9种预定义类型 各类用户定义类型 可描述各类不同的量 必须进行类型说明运算时必须考虑类型的一致性和适用性Verilog HDL 常量: 数量,参量变量:网络型 寄存器型 类型种类少 运算时所受的约束少3运算符号 运算主要分为3类 : 算术运算 逻辑运算 关系运算 算术运算 VHDL中有10种 但很多都不能进行综合,只能用于行为描述 Verilog HDL中只有能够综合的5种 逻辑运算 VHDL中 有常用的6种,均用字符形式表达 Verilog HDL中有3类共14种,分为一般逻辑运算,位逻辑运算,缩减逻辑运算 关系运算 VHDL中有
3、6种 Verilog HDL中有2类共8种,对比增加了全等和不全等(用于对不定态比较)。 除了以上3类运算外,VHDL中还有连接运算,Verilog HDL中还有连接运算、移位运算和条件运算。点评:VHDL的运算划分比较抽象,适应面较广 Verilog HDL的运算划分比较具体,对逻辑代数反映更细致一些。4语句 两种语言的语句都分为并行语句和顺序语句,并行语句在主程序中使用,顺序语句只能在子结构中使用;并行语句都分为3种形式:代入语句(3种) assign语句(连续赋值)(对wire类型变量)元件语句 (需进行说明) 门原语、元件例化语句 (无需说明)process (敏感表) always
4、( ) begin begin . end process; end顺序语句 信号赋值 非阻塞赋值 ( 对reg型变量 ) 变量赋值 阻塞赋值 条件语句 if case 基本相同,VHDL稍微严密一些循环语句 loop(3种形式) for repeat while forever 时钟边沿检测 clkevent and clk=1 (0) posedeg clk (negedge) 5子结构 function function defineprocedure task6附加结构library package include 7典型程序对比:8位4选1MUXlibrary ieee; Use i
5、eee.std_logic_1164.all; entity mux4 is module kmux4_1(s,a,b,c,d,y); port (s: in std_logic_vector(1 downto 0); input1:0 s; a,b,c,d: in std_logic_vector(7 downto 0); input 7:0 a,b,c,d; y: out std_logic_vector( 7 downto 0); output7:0 y;End mux4; ;architecture rtl of mux4 is beginreg7:0 yprocess(a,b,c,d
6、,s)always (a or b or c or d or s) beginbegin case s iscase(s)when “00” = y y y y= d;default: y=d;End case;endcaseEnd process;endEnd rtl;endmodule8位加法器library ieee;Use ieee.std_logic_1164.all;Use ieee.std_logic_arith.all;entity vadd ismodule kadd (a,b,c,s); port (a,b: in std_logic_vector(7 downto 0);
7、input7:0 a ,b; c: in std_logic_vector(0 to 0);input c; s : out std_logic_vector( 8 downto 0 );output8:0 s;End vadd;architecture rtl of vadd isbegins = unsigned(a)+unsigned(b)+unsigned(c);assign s = a+b+c;End rtl;endmodule8位二进制加法计数器library ieee;Use ieee.std_logic_1164.all;Use ieee.std_logic_arith.all
8、;entity kcounter8 ismodule counter8(q,cout,data,load,en,clk); port ( clk,load: in std_logic; en: std_logic_vector (1 to 1);input load,en,clk; data: in std_logic_vector (3 downto 0);input 7:0 data; q: out std_logic_vector (3 downto 0);output7:0 q; cout:out std_logic);output cout;End kcounter8;archite
9、cture beh of kkcounter8 isSignal iq: std_logic_vector (3 downto 0);reg 7:0 q;beginprocess (clk)always (posedge clk)begin Begin if clkevent and clk=1 then if load =1 then iq = data;if(load) q=data; else iq=unsigned(iq)+unsigned(en);else q=q+en; end if;End end if; if (iq=1111)and(en=1) then cout=1;ass
10、ign cout=&q&en; else cout=0; end if; end process;q = iq;End beh;Endmodule序列信号发生器:kser 预先设计模块:8选1MUX:MUX8 控制输入a2.0 数据输入d7.0 数据输出y3位2进制加法计数器:COUNTER3 时钟输入 clk 状态输出q2.0设计要求:按照时钟节拍,由y端口循环顺序输出“11110101”序列信号 library ieee;use ieee.std_logic_1164.all;entity kser ismodule kser (clk,y);port ( clk: in std_logi
11、c;input clk;Yo: out std_logic);output y;end kser;architecture str of kser iscomponent mux8 port ( d: in std_logic_vector(7 downto 0);a: in std_logic_vector(2 downto 0);y: out std_logic); end component;component counter3 port ( clk: in std_logic;q: out std_logic_vector(2 downto 0); end component;sign
12、al b: std_logic_vector(2 downto 0);wire3:0 b;signal k: std_logic_vector(0 to 7);begink = 11110101;u1: counter3 port map (clk,b);counter3 mycounter(clk,b);u2: mux8 port map ( k,b,yo);mux8 mymux(b2:0,8b11110101,y);end str;Endmodule附:用Verilog HDL编写的两个模块module counter3(clk,q);input clk;output7:0 q;reg 7:0 q;always (posedge clk)beginq=q+1;endendmodulemodule mux8
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2026年云南城市建设职业学院单招职业倾向性测试题库附答案详解(突破训练)
- 2026年云南林业职业技术学院单招职业技能考试题库有完整答案详解
- 2026年伊春职业学院单招职业适应性考试题库附答案详解(夺分金卷)
- 2026年上海政法学院单招综合素质考试题库附参考答案详解(培优)
- 2026年上海海洋大学单招职业适应性测试题库附答案详解(完整版)
- 2026年九江职业大学单招职业适应性考试题库及答案详解(各地真题)
- 2026年云南能源职业技术学院单招职业倾向性测试题库含答案详解(轻巧夺冠)
- 2026年云南工贸职业技术学院单招综合素质考试题库及完整答案详解一套
- 2026年三门峡社会管理职业学院单招职业适应性考试题库及完整答案详解
- 2026年上海戏剧学院单招职业技能测试题库附答案详解ab卷
- 2026湖南衡阳日报社招聘事业单位人员16人备考题库参考答案详解
- GB 12801-2025生产过程安全基本要求
- 食堂管理内控制度
- 2026年江苏医药职业学院单招职业技能测试题库及答案详解一套
- 2025至2030中国数据分析超级计算机(DAS)行业项目调研及市场前景预测评估报告
- 口腔种植知识培训内容课件
- 仪表工业智能化规划方案
- 展会搭建方案(3篇)
- 危重患者护理记录书写
- 小学语文数字化教学论文
- 尼康-D300S-相机说明书
评论
0/150
提交评论