Blackjack – Zynq Zybo – A VHDL project


Hi, I’m Giulio
Hi, I’m Rehan
Hi, I’m Enrico
We’re introducing the project
we worked on last semester for our
Computer Architecture course. It’s a Blackjack game,
running on an FPGA board, called Zybo.
Our tool of choice was Vivado, a VHDL programming suite.
Our board features an FPGA chip,
alongside with an ARM processor
which we didn’t use, and which is powered by
the micro USB port also used for programming it.
As far as the video is concerned
we used the VGA output, also onboard.
At its current state the game supports only
one player and just the basic features of Blackjack
However, we’re planning to make
a multiplayer mode and specific variations
of the card game, such as
double down, insurance, and so on.
Each of us was in charge of a specific
part of the project: Rehan took care of the
algorithm, Giulio designed the graphics and
I, Enrico, designed the I/O.
So, initially the idea was to use a PS/2 keyboard but
however, due to lack of time and
resources, we resorted to using the built-in
buttons on the board, and switches,
and since we’re implementing a simplified
version of Blackjack those were enough.
So, there are two modules that
I implemented: ‘HWreset’, that is this one
that basically takes one button
debounces it and then outputs two control signals, ‘b_upper’ and ‘b_lower’
that serve a purpose later on in the stages
and Rehan will discuss those
Then, we have IOblock that is the main I/O block
as the name suggests, that takes switches
and buttons, debounces them
and then outputs several control signals that are
‘iobus’ and ‘iochoice’ and ‘leds’
We use the switches and the LEDs
to output the betting amount in the betting stage
difficulty setting in the diffulty setting stage
and in all other states we have the current state
output in four bits, by means of the LEDs.
Hi, I’m Rehan again
I took care of the algorithm
used in this game
A Finite State Machine is created within the framework
of the ‘Single Control Unit’ module.
It serves as the brain of this whole game.
The game works in this way: at the start of
the game the user decides to bet a certain
amount of money. A signal is then sent
from the Control Unit to the ‘wallet’ module
to check the availability
of the entered amount of money.
If the player owns the
said amount of money the ‘wallet’ module
sends back a signal
to the Central Control Unit
allowing the game to go on.
When the user or the computer decide to ‘hit’
that is, to take a card
the Control Unit outputs a signal to the ‘memory’ block
which then randomly picks a card from the deck.
If the card was not picked before
this memory signals the Control Unit
to proceed, informing it about
the availability of the card.
When the user or the computer
decide to ‘stand’
that is, stop taking cards
the Control Unit simply moves on
to the next state.
The basic rules are these:
The score can’t exceed 21.
After receiving four cards each
whoever has the highest score wins.
If the player runs out of money
bankruptcy occurs,
and the game ends.
If this state is never reached
the user can continue to play indefinitely.
Me, Giulio
took care of the video part.
As previously stated
we chose to employ the VGA output.
According to the VGA specifications
I built the ‘sync’ unit which was able to
synchronize each specific pixel on the
screen at each clock signal.
An appropriate frequency for the clock
has been chosen in relation to
the screen resolution.
Additionally, several units constructing
the images for each phase in the game
were implemented.
Information about the phase and
other data to be shown
are sent by the CPU
and stored in a buffer, to properly
stabilize the signal before
they are transmitted to the assigned unit.
All these units are then connected to a
multiplexer which is able
knowing the state of the game, to connect
with external ports the signal incoming
from the right block.
Then, the output is sent out
by means of a 16-bit signal
defining colors through the RGB spectrum.
And finally, you can see everything on the screen.
This is an example of how the game works.
So, first you get this splash screen and then
this button brings you to
the first difficulty selection screen.
By setting these switches you can set the
difficulty in this case I want this one
which is ‘medium’ as you can see in the
top left corner
and then you have to bet:
so you set the switches in binary
according to the amount you want to bet
in this case I bet 15
as is displayed here and my updated budget
right here.
Then, I have to take a card:
so I press this button right here
and I get a card
So my total stands at eight
I want another card,
so I press the button again
and I get 15
and also the dealer gets his card.
So I hit again
and I get 20
and now I am at a reasonable amount.
So I want to stand
that is, not take any more cards so
I press this button.
I’m at 20
and I won.
And then
I’m brought back to the betting stage
at which I can set the betting amount
that is, pressing this button again
getting new cards and new budget.
So, as a conclusion we’d like to
thank Professor Sterpone and Professor Montuschi
for the encouragement during
the first stages of development
and Politecnico di Torino, for providing all the
hardware and facilities.
So like, share and subscribe
and all that good stuff
and see you next time.
Bye!

3 Comments

Add a Comment

Your email address will not be published. Required fields are marked *