HBLbits_Verilog Basic_Lemmings1
The game Lemmings involves critters with fairly simple brains. So simple that we are going to model it using a finite state machine.
In the Lemmings' 2D world, Lemmings can be in one of two states: walking left or walking right. It will switch directions if it hits an obstacle. In particular, if a Lemming is bumped on the left, it will walk right. If it's bumped on the right, it will walk left. If it's bumped on both sides at the same time, it will still switch directions.
Implement a Moore state machine with two states, two inputs, and one output that models this behaviour.
See also: Lemmings2, Lemmings3, and Lemmings4.
Lemmings is a puzzle video game originally developed by DMA Design in Dundee, Scotland and published by Psygnosis for the Amiga in 1991 and later ported for numerous other platforms. The game was programmed by Russell Kay, Mike Dailly and David Jones, and was inspired by a simple animation that Dailly created while experimenting with Deluxe Paint.
大概意思:有兩個方向可以走:往左走和往右走;如果碰到障礙物就需要切換方向。同時碰到障礙物也要切換方向。
根據輸出,輸出walk_left,walk_right分別對應輸入bump_left,bump_right,當輸入對應位置出現1,即出現障礙物,輸出需要翻轉一次。
因此,定義兩個狀態 (往左走LEFT,往右走RIGHT);在LEFT狀態下,如果遇到左邊有障礙物或者兩邊都有障礙物,則狀態切換到RIGHT。另一個狀態下同理。
沒有留言:
張貼留言