首页 > 其他 > 详细

define

时间:2015-07-23 23:17:41      阅读:199      评论:0      收藏:0      [点我收藏+]

【例 5.3】用 always 过程语句描述的简单算术逻辑单元
`define add 3‘d0
`define minus 3‘d1
`define band 3‘d2
`define bor 3‘d3
`define bnot 3‘d4
程序文本
- 4 -
module alu(out,opcode,a,b);
output[7:0] out;
reg[7:0] out;
input[2:0] opcode; //操作码
input[7:0] a,b; //操作数
always@(opcode or a or b) //电平敏感的 always 块
begin
case(opcode)
`add: out = a+b; //加操作
`minus: out = a-b; //减操作
`band: out = a&b; //求与
`bor: out = a|b; //求或
`bnot: out=~a; //求反
default: out=8‘hx; //未收到指令时,输出任意态
endcase
end
endmodule

define

原文:http://www.cnblogs.com/zhongguo135/p/4671947.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!