|
楼主 |
发表于 2004-5-17 22:19:24
|
显示全部楼层
[求助]看看这句赋值为什么不可以?(verilog)
贴出全部的程序:
`timescale 1ns/1ns
module freqdiv(clock,num,rst,divout);
input clock,rst;
input [0:7]num;
output divout;
reg [0:7]count_p,count_n,half;
reg freq_p,freq_n;
assign divout=freq_p||freq_n;
initial
begin
half=num;
half=(half>>1);
count_p=0;
count_n=0;
end
always
@(posedge clock)
begin
if (rst)
begin
count_p=0;
count_n=0;
end
else
begin
if(count_p==num-1)
count_p<=0;
else
count_p<=count_p+1;
end
end
always
@(negedge clock)
begin
if (rst)
begin
count_p=0;
count_n=0;
end
else
begin
if(count_n==num-1)
count_n<=0;
else
count_n<=count_n+1;
end
end
always
@(clock)
begin
freq_p<=(count_p<=half)?1:0;
freq_n<=(count_n<=half)?1:0;
end
endmodule
是一个可控分频器。
testbench是
`timescale 1ns / 1ns
module freqdiv_tb;
//Internal signals declarations:
reg clock;
reg [0:7]num;
reg rst;
wire divout;
// Unit Under Test port map
freqdiv UUT (
.clock(clock),
.num(num),
.rst(rst),
.divout(divout));
initial
begin
clock=0;
rst=1;
num=5;
end
always
clock=#10 ~clock;
initial
begin
#30 rst=0;
#300 $stop;
end
initial
$monitor($realtime,,"ns %h %h %h %h ",clock,num,rst,divout);
endmodule |
|