前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >HDLbits Exams/ece241 2013 q4

HDLbits Exams/ece241 2013 q4

原创
作者头像
Player
发布2022-07-24 21:23:12
2530
发布2022-07-24 21:23:12
举报
文章被收录于专栏:XilinxXilinx

fr1 fr2 fr3 输出完全由输入决定,和状态机其实没关系。

dfr 需要判断一下。

代码语言:javascript
复制
module top_module (
    input clk,
    input reset,
    input [3:1] s,
    output fr3,
    output fr2,
    output fr1,
    output dfr
); 
    reg [2:0] state;
    reg [2:0] next;
    reg ndfr;
    
    always@(*)begin
        if(reset)begin
            next = 3'b111;
            ndfr = 1;
        end else begin
            case(s)
                3'b111: next = 3'b000;
                3'b011: next = 3'b001;
                3'b001: next = 3'b011;
                3'b000: next = 3'b111;
            endcase
            case(s)
                3'b000: ndfr = 1;
                default: 
                    ndfr = (state == next) ? dfr : ((state > next) ? 0 : 1);
            endcase
        end
    end
    
    always@(posedge clk)begin
        state <= next;
        dfr <= ndfr;
    end
    
    assign {fr3, fr2, fr1} = state;

endmodule

原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。

如有侵权,请联系 cloudcommunity@tencent.com 删除。

原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。

如有侵权,请联系 cloudcommunity@tencent.com 删除。

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档