rayLei-lxf 2015-12-04 04:06 采纳率: 100%
浏览 2065
已采纳

帮忙修改一下这个Verilog程序,关于两个源驱动同一个输出

要实现oe发生跳变时,这个输出置0,当定时时间到来时这个输出置1;
一下这个程序,帮忙修改下:
module Timer (
input rst,
input oe,
input clk,
output TI_flag
);

parameter
Ttime=100 ;//定时时间

wire flag; //定时器溢出标志位

reg [31:0] count;

assign (supply1 ,weak0)flag= (oe | ~oe) ? 0:1;
assign TI_flag=flag;
always @(posedge clk or negedge rst )
begin
if(!rst)
begin
count<=0;
flag<=0;
#3 flag<=1; //这里线网不能进行赋值
end
else if(count<(Ttime-1)&!TI_flag)

begin
count<=count+1'b1;
end
else
begin
count<=32'b0;
#3 flag<=0;
flag<=1; //定时溢出,标志位置1,定时完成,灭掉LED
end
end
endmodule

  • 写回答

2条回答 默认 最新

  • rayLei-lxf 2015-12-04 13:13
    关注

    我自己解决了 ,原来用状态机就好了

    module Timer (
    input rst,
    input oe,
    input clk,
    output TI_flag
    );

    parameter
    Ttime=100 ,//定时时间

    status0=0, //状态参数
    status1=1,
    status2=2;
    reg [2:0] st=status0;

    reg flag=1; //定时器溢出标志位

    reg [31:0] count=0;
    assign TI_flag= flag;

    always @(posedge clk or negedge rst )
    begin
    if(!rst)
    begin
    st<=status0;
    count<=0;
    flag<=1;
    end

    case (st)
    status0: begin
    if(oe)
    begin
    flag<=0; //清零 开始计数定时
    count<=0;

    st<=status1;
    end
    else
    st<= status0;
    end
    status1:begin
    if(count<Ttime-1)
    begin

    st<=status1;
    count<=count + 1;
    end
    else
    begin
    flag<=1;

    st<=status2;
    end

    end

    status2: begin
    while(oe); //等待不使能定时器信号,使得可以让下一次oe=1信号来临时定时器被触发
    st<=status0;
    end
    default: st<=status0;

    endcase
    end
    endmodule

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥20 matlab计算中误差
  • ¥15 对于相关问题的求解与代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料
  • ¥15 使用R语言marginaleffects包进行边际效应图绘制
  • ¥20 usb设备兼容性问题
  • ¥15 错误(10048): “调用exui内部功能”库命令的参数“参数4”不能接受空数据。怎么解决啊