--
-- 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
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
最高优先级编码器 8位相等比较器 三人表决器(三种不同的描述方式) 加法器描述 8位总线收发器:74245 (注2) 地址译码(for m68008) 多路选择器(使用select语句) LED七段译码 多路选择器(使用if-else语句) 双2-4译码器:74139 多路选择器(使用when-else语句) 二进制到BCD码转换 多路选择器 (使用case语句) 二进制到格雷码转换 双向总线(注2) 汉明纠错吗译码器 三态总线(注2) 汉明纠错吗编码器 解复用器
资源详情
资源评论
资源推荐
收起资源包目录
VHDL范例.rar (46个子文件)
VHDL范例
基本语法
adder_nbit_generate.txt 1KB
topdown.txt 2KB
counter_generate.txt 1KB
counter_wait.txt 1014B
counter_pload.txt 922B
convert.txt 809B
counter_nbit.txt 859B
时序逻辑
shift_register_164.txt 657B
d-filp-flop_hct175.txt 862B
universal_register.txt 2KB
register_374.txt 721B
存储器举例
fifo.txt 2KB
测试向量(Test Bench)举例
testadder_vhd.txt 4KB
state_classic.txt 3KB
adder_vhd.txt 3KB
状态机举例
statmach_altera_vhd.txt 773B
mealy1.txt 3KB
state_variable.txt 2KB
moor1.txt 3KB
State_areset.txt 1KB
moor2.txt 2KB
state_moor_mealy.txt 3KB
traffic_ls_vhd.txt 3KB
其他设计举例
mancala_vhd.txt 20KB
multiplier_booth.txt 5KB
step_motor_vhd.txt 3KB
pseudorandom_vhd.txt 8KB
random_generator.txt 2KB
uart_ls_vhd.txt 11KB
dc_motor_vhd.txt 10KB
组合逻辑
priority_encoder_highest.txt 1KB
address_decoder_m68008.txt 2KB
multiplexer_ifelse1.txt 783B
multiplexer_ifelse.txt 783B
hamming_decoder.txt 2KB
prebus.txt 428B
comparator8.txt 411B
decoder_hct139.txt 1KB
decoder_bcd_to_7segment.txt 874B
bidir.txt 1KB
hct245.txt 722B
multiplexer_ifelse2.txt 783B
hamming_encoder.txt 893B
majority_voter.txt 2KB
adder_variety_style.txt 3KB
www.pudn.com.txt 218B
共 46 条
- 1
寒泊
- 粉丝: 86
- 资源: 1万+
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- SEW Interface.xlsx 智能设备的相关参数及调试方法\SEW 变频器IO接口说明
- python实现的将 高德地图api内的省市区数据转换为指定表结构的sql语句
- 麒麟系统下Veyon远程控制软件的安装与配置指南
- 滚床SEW MOVIFIT- FC变频器配置手册.docx
- 免费的电脑时钟,副屏显示时间,可以设置字体大小和颜色
- C++语言实现的简单协程库.zip
- 升降机SEW MOVIDRIVE 变频器配置手册.docx
- 中文版infineon比例阀专用控制芯片TLE82453器件手册
- 移载机SEW MOVIDRIVE 变频器配置手册.docx
- C++11语言级别实现的简易数据库连接池.zip
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
评论0