提示:文章写完后,目录可以自动生成,如何生成可参考右边的帮助文档
目录
前言
用always块实现较复杂的组合逻辑电路。
一、简单的指令译码电路
1.1 程序语句:
`define plus 3'd0
`define minus 3'd1
`define band 3'd2
`define bor 3'd3
`define unegate 3'd4
module alu(a, b, opcode, out);
input [7:0]a, b;
input [2:0]opcode;
output [7:0]out;
reg [7:0]out;
always @(opcode or a or b)
begin
case(opcode)
`plus: out = a + b;
`minus: out = a - b;
`band: out = a & b;
`bor: out = a | b;
`unegate: out = ~a;
default: ou