--
-- Copyright (c) 1993,1994 by Exemplar Logic, Inc. All Rights Reserved.
--
-- This source file may be used and distributed without restriction
-- provided that this copyright statement is not removed from the file
-- and that any derivative work contains this copyright notice.
--
-----------
--
-- This is a synthesizable description that implements an emulator
-- of the Mancala game (African beans game).
--
-- Description of the Hardware
-------------------------------
--
-- The hardware for the game includes a number of displays, each with a button and
-- a light, that each represent a 'bin' that can store marbles (beans).
--
-- The display indicates the number of marbles in each bin at any given time.
-- The light indecates that the present bin is not empty and that pushing the
-- button is a valid move in the game.
--
-- The button for each display indicates that a player takes the marbles from
-- the selected bin, and takes them in his hand. The hand is represented by a
-- diplay itself (no button).
--
-- Each player has a home bin, located on opposite sides of the game. The home
-- bin is also represented by a display. There should not be a button on the
-- home bins, since the game does not allow the removal of marbles from the home
-- bins.
--
-- Besides this, the game has a button to start the game, and a reset for power-up
-- purposes.
--
-- Here is a picture that represents the hardware setup of the game :
--
--
-- * == Light for valid move or to indicate the player who is active
-- O == Button to make move
-- _
-- | |
-- - == 7 - segment display
-- |_|
--
-- work bins
-- * O * O * O * O
-- _ _ _ _ _ _ _ _
-- | | | | | | | | | | | | | | | |
-- - - - - - - - -
-- * |_| |_| |_| |_| |_| |_| |_| |_| *
-- _ _ _ _
-- | | | | | | | |
-- - - - -
-- |_| |_| |_| |_|
--
-- home bin LEFT home bin right
-- * O * O * O * O
-- _ _ _ _ _ _ _ _
-- | | | | | | | | | | | | | | | |
-- - - - - - - - -
-- |_| |_| |_| |_| |_| |_| |_| |_|
--
-- work bins
--
-- _ _
-- | | | |
-- - - O Start Game
-- |_| |_|
--
-- Hand bin
--
--
-- The Rules of the game
------------------------
--
-- At the start of the game, the left player is active and can make a move.
-- The left player selects a bin (by pressing the corresponding button).
-- The machine will move the marbles from the bin (display) to the hand (diplay)
-- and drop one marble in each successive bin (clockwise) from the hand,
-- starting with the bin clock-wise adjecent to the selected bin.
-- A marble is never dropped in a opponents home bin (will be skipped).
--
-- If the last marble from the hand is dropped in an empty bin, the players
-- switch turns, and it is the other players turn to make a move.
--
-- If the last marble from the hand is dropped in the players home bin,
-- the player can make another move.
--
-- If the last marble from the hand is dropped in a non-empty work bin,
-- all the marbles from that bin will be moved back to the hand and the
-- game proceeds.
--
-- The game ends if there are no more marbles in any of the work bins.
--
-- The winner of the game is the player who has most marbles in his/her
-- home bin at the end of the game.
--
--
--
-- About the design
--------------------
--
-- The design contains a controller and a data path. The controller contains
-- a state machine that defines the overall state of the game (waiting for a
-- move, end of the game, playing).
-- The controller also has a register that defines which bin is active at any
-- point in time during active playing.
--
-- The controller provides signals for the data path to decrement the hand
-- marble count, or load the hand with the selected work bin count, or indecate
-- that the game is over and a winner should be defined etc.
--
-- The data path contains a register for each bin in the game.
-- The number of bins is easily programmable by setting a integer constant.
-- The data path also contains counters to decrement the hand marble count
-- or increment the bin marble counts.
--
-- The data path provides signals for the controller to indicate that the
-- hand bin is empty, or which of the work bins is empty.
--
-- The work bin registers are loaded with a equal number of marbles at the start
-- of the game. The total number of marbles in the game is programmable by setting
-- a generic in the top entity.
--
-- The data path also includes light drivers for the lights on each button that
-- indicate a valid move, and the lights that indicate which player is active.
-- Two extra signals are generated by the data path that let the home bin
-- display of the winner of the game blink on and off (at the end of the game).
--
-- The design does not include a merry-go-round display driver. This is done
-- outside this design, on the Aptix board.
--
-- The design does also not include a 18 bit clock devider that provides a
-- vary slow ticking clock to let humans follow the moves of the machine
-- cycle by cycle.
--
--
library ieee ;
use ieee.std_logic_1164.all ;
package mancala_pack is
type boolean_array is array (natural range <>) of boolean ;
type player_t is (LEFT, RIGHT, BOTH, NEITHER) ;
-- Define the number of bins in the game here.
-- This include the two home bins
constant nr_of_bins : natural := 10 ;
-- Define the indexes of the two home bins
constant OUTER_LEFT : natural := 0 ;
constant OUTER_RIGHT : natural := nr_of_bins/2 ;
-- Make a 'mask' constant that eliminates the home bins
constant not_home_bins : boolean_array (nr_of_bins-1 downto 0) :=
(OUTER_LEFT=>FALSE, OUTER_RIGHT=>FALSE, OTHERS=>TRUE) ;
-- Component Declaration of the controller of the game
component control
generic (nr_of_bins : natural := 32) ;
port (start_game : in boolean ;
reset, clk : in std_logic ;
buttons : in boolean_array (nr_of_bins-1 downto 0) ;
empty_bins : in boolean_array (nr_of_bins-1 downto 0) ;
hand_is_empty : in boolean ;
active_bin : buffer boolean_array (nr_of_bins-1 downto 0) ;
decrement_hand : out boolean ;
load_hand_with_active_bin : out boolean ;
the_player : out player_t ;
end_of_the_game : out boolean ;
waiting_for_move : out boolean
) ;
end component ;
end mancala_pack ;
library ieee ;
use ieee.std_logic_1164.all ;
use work.mancala_pack.all ;
entity control is
generic (nr_of_bins : natural := 10) ;
port (start_game : in boolean ;
reset, clk : in std_logic ;
buttons : in boolean_array (nr_of_bins-1 downto 0) ;
empty_bins : in boolean_array (nr_of_bins-1 downto 0) ;
hand_is_empty : in boolean ;
active_bin : buffer boolean_array (nr_of_bins-1 downto 0) ;
decrement_hand : out boolean ;
load_hand_with_active_bin : out boolean ;
the_player : out
寒泊
- 粉丝: 86
- 资源: 1万+
最新资源
- 多路Qt串口通信源码C++语言接口自定义协议帧Qt读写配置文件ini: 可变长定长通信接口协议实现Qt多路串口发送接收SerialProtocol.rar 工控自定义报文 可用于嵌入式,单片机,ARM
- 中关村在线Web自动化测试需求文档
- MATLAB代码:考虑综合负荷的主动配电网最优潮流计算 关键词:综合负荷 配电网优化 最优潮流 动态调度 二阶锥 参考文档:综合负荷部分店主自己编写了参考文档,可联系我查阅 主动配电网最优潮流研究
- lenevo D2000 cpld and uefi
- 两阶段市场投标策略 电力市场程序 提出了日前电力市场和实时电力市场下充电站的投标策 略 ,基于闵可夫斯基加法提出了充电站内电动汽车集群模型的压缩方法,并建立了日前可调 度潜力预测模型和实
- Java反编译工具:jd-jui
- 毕业设计基于单片机的室内有害气体检测系统源码+论文(高分毕设)
- 区块链理论与实践 课程作业手册
- 机械设计搅拌机sw21全套设计资料100%好用.zip
- 基于单片机的室内有害气体检测系统源码+论文(高分毕设)
- 机械设计互感器电流测试台(sw21可编辑+工程图)全套设计资料100%好用.zip
- Motorcad 外转子式42极36槽 永磁同步电机,直流无刷电机设计案例, 该电机55kw,220rpm,功率密度较高
- 欧姆龙CP1H+CIF11与施耐德ATV变频器通讯程序 功能:原创程序,可直接用于现场程序 欧姆龙CP1H的CIF11通讯板,实现对施耐德ATV12变频器 设定频率,读取实际频率,变频器状态功能
- 生成word文件的docxtemplater模板
- 2-StartAllBack Windows11开始菜单增强工具-V3.9.0.5220 PC绿色版
- 机械设计机器人取料检测抓手sw18可编辑全套设计资料100%好用.zip
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
评论0