|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?注册
x
请哪位高手帮忙给下面Verilog程序写个测试模块,在ModelSim中实现单脉冲4-PPM调制。时间很紧,谢谢了!
module ppm_code(rst,clk,data_in,ppmdata);
input clk;
input rst;
input data_in;
output ppmdata;
reg [1:0] count;
reg [1:0] xreg;
reg [1:0] yreg;
reg ppmdata;
reg q;
always@(posedge clk or negedge rst)
if(!rst)
begin
count<=2'b11;
q<=0;
yreg<=0;
ppmdata<=1;
end
else
begin
if(count==2'b11)
begin
yreg<=xreg;
q<=~q;
count<=count+1;
end
else
begin
q<=~q;
count<=count+1;
end
if(yreg[0]==1'b0 && count==yreg)
begin
ppmdata<=q;
end
else if(yreg[0]==1'b1 && count==yreg)
begin
ppmdata<=~q;
end
else
ppmdata<=0;
end
always@(posedge clk or negedge rst)
if(!rst)
xreg<=2'b00;
else
if(count[0]==1'b1)
xreg<={xreg[0],data_in};
else
xreg<=xreg;
endmodule
2012-05-22 11:26 提高悬赏20分
2012-05-22 08:24 补充问题
我写了个测试模块,出的结果不对。请高手指点指点!
module sti_ppm_code;
reg clk,rst,data_in;
wire ppmdata;
ppm_code aa(.rst(rst),.clk(clk),. data_in (data_in), . ppmdata(ppmdata));
initial
begin #0
//0ns?? rst = 1'b1; clk=0; data_in =8'b0; #100
//100ns?? rst = 1'b0; data_in
=8'b1; end always #5 clk = ~clk;//???100m endmodule |
|