|
![](static/image/common/ico_lz.png)
楼主 |
发表于 2010-10-10 09:42:54
|
显示全部楼层
上个问题还没弄明白 又有疑问了 我的仿真时 output为什么是高阻态?
程序就是 对 a b 进行运算 通过 opcode 进行选择运算方式,输出结果out ,但结果除末尾外都呈高阻态? 我是新手,希望知道的大侠指点一下,感激。。
alu.v
`define plus 3'd0
`define minus 3'd1
`define band 3'd2
`define bor 3'd3
`define unegate 3'd4
module alu(out,opcode,a,b);
input [7:0]a,b;
input [2:0]opcode;
output [7:0]out;
reg 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: out=8'hx;
endcase
end
endmodule
alu_top.v //测试文件
`timescale 1ns/1ns
module alu_top;
wire [7:0]out_top;
reg [7:0]a,b;
reg [2:0]opcode;
parameter times=5;
initial
begin
a={$random}%256;
b={$random}%256;
opcode=3'h0;
repeat(times)
begin
#100
a={$random}%256;
b={$random}%256;
opcode=opcode+1;
end
#100 $stop;
end
alu i1(out_top,opcode,a,b);
endmodule
仿真波形图:
![](http://cache.amobbs.com/bbs_upload782111/files_34/ourdev_588602SV6WH5.png)
(原文件名:alu波形.png) |
|