Circuits--Sequential--Finite7

1. Lemmings 3

module top_module(
    input clk,
    input areset,
    input bump_left,
    input bump_right,
    input ground,
    input dig,
    output walk_left,
    output walk_right,
    output aaah,
    output digging
);

    parameter left = 3'b0;
    parameter right = 3'b1;
    parameter d_left = 3'b10;
    parameter d_right = 3'b11;
    parameter f_left = 3'b100;
    parameter f_right = 3'b101;

    reg[2:0] state;
    reg[2:0] next_state;
    wire[1:0] bump;
    assign bump = {bump_left,bump_right};

    always @(*) begin
        case (state)
            left:begin
                if (ground == 1'b0) 
                    next_state = f_left;
                else if(dig == 1'b1)
                    next_state = d_left;
                else if((bump == 2'b10)||(bump == 2'b11))
                    next_state = right;
                else
                    next_state = left;               
            end 

             right:begin
                if (ground == 1'b0) 
                    next_state = f_right;
                else if(dig == 1'b1)
                    next_state = d_right;
                else if((bump == 2'b01)||(bump == 2'b11))
                    next_state = left;
                else
                    next_state = right;               
            end 

            d_left:begin
                if(ground == 1'b0)
                    next_state = f_left;
                else
                    next_state = d_left;

            end

             d_right:begin
                if(ground == 1'b0)
                    next_state = f_right;
                else
                    next_state = d_right;

            end

             f_left:begin
                if(ground == 1'b0)
                    next_state = f_left;
                else
                    next_state = left;

            end

            f_right:begin
                if(ground == 1'b0)
                    next_state = f_right;
                else
                    next_state = right;

            end       
            
        endcase
    end

    always @(posedge clk or posedge areset) begin
        if(areset)
            state <= left;
        else
            state <= next_state;
    end

    assign walk_left = (state == left);
    assign walk_right = (state == right);
    assign digging = ((state == d_left)||(state == d_right));
    assign aaah = ((state == f_left)||(state == f_right));


endmodule

相关推荐

  1. Circuits--Sequential--Finite7

    2024-05-03 07:54:06       36 阅读
  2. CIrcuits--Sequential--Finite_1

    2024-05-03 07:54:06       30 阅读
  3. Circuits--Sequential--Finite_2

    2024-05-03 07:54:06       30 阅读
  4. Circuits--Sequential--Finite4

    2024-05-03 07:54:06       31 阅读
  5. Circuits--Sequential--Finite6

    2024-05-03 07:54:06       33 阅读
  6. Circuits--Sequential--Finite5

    2024-05-03 07:54:06       32 阅读
  7. Circuits--Sequential--Finite--one hot

    2024-05-03 07:54:06       33 阅读
  8. Circuits--Sequential--More circuits

    2024-05-03 07:54:06       42 阅读
  9. Circuits--Sequential--Registers_1

    2024-05-03 07:54:06       33 阅读
  10. Circuits--Sequential--Registers_2

    2024-05-03 07:54:06       34 阅读

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2024-05-03 07:54:06       98 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-05-03 07:54:06       106 阅读
  3. 在Django里面运行非项目文件

    2024-05-03 07:54:06       87 阅读
  4. Python语言-面向对象

    2024-05-03 07:54:06       96 阅读

热门阅读

  1. Vagrant CentOS7 安装 Docker 及使用 Docker 安装 MySQL

    2024-05-03 07:54:06       30 阅读
  2. PostgreSQL自带的命令行工具02- createdb

    2024-05-03 07:54:06       33 阅读
  3. PostgreSQL日期和时间相关函数

    2024-05-03 07:54:06       34 阅读
  4. 身份证号对应地区信息-MySQL

    2024-05-03 07:54:06       30 阅读
  5. 最大似然估计(通俗讲解)

    2024-05-03 07:54:06       27 阅读
  6. 2012NOIP普及组真题 4. 文化之旅

    2024-05-03 07:54:06       41 阅读
  7. 【设计模式】16、state 状态模式

    2024-05-03 07:54:06       27 阅读
  8. React使用 lodash-es 中的throttle方法失效

    2024-05-03 07:54:06       34 阅读
  9. 论文笔记总结

    2024-05-03 07:54:06       39 阅读