objective the object of the game is to convert as many hexadecimal numbers to binary coded decimal...
Post on 20-Dec-2015
225 views
TRANSCRIPT
Stack16x8
R
Rmuxrsel
clrclk
rpush
rpop
clrclk
rload
rdec
R
R1
r_in
ReturnStack
clrclk
rpush
rpop
rload
rdec
rsel
0 1
Tmux
Tregclkclr
Nregclkclr
ALU3
T1
N
Tin
alusel(3:0)
tsel(1:0)
tload
nload
y
Nmux
Nin
nsel
T1
Smux
stack16x8
N1
N1
N2
N2y
T1
N2
clkclr
pop
push
empty
full
d
ssel
0 1 2 3
0
0
1
1
DataStack_ALU
Rmux
Pmux
PCclrclk
ploadpinc
IRclrclkirload
W8Y_rom
W8Y_control
plus1
R
DS
Rin
R
T
P
Pin
M
M
P1
R
M
SW(1:8)
step_display
A(3:0) AtoG(6:0)
clk
clrBTN(2)
BTN(4)
clr
step
The W8YMicrocontroller
for HexBinIQ
psel
rinsel
dssel(1:0)
T
icode
E
BTN2(1:4)
0
1
1
1
0
0 2 3DSmux
N
TNDispReg
hi
Ndisp(7)
0 1esel
check randomhexclk
rstrndnewscore
chkload
SW
clk
rst
Emux
Tdisp
SW LDreg
LD(1:8)
ldloadclkclr
LDdisp
scoreled
newscore(3:0)
BTN(2)
dig3,4dig1,2
OutofTime
time
BTNcontrol
BTN2
BTN
Tdisp
TDispRegT
clk
clr
timerclkrst
clk clr
ndload
tdload
clr
ObjectiveThe object of the game is to convert as many hexadecimal numbers to binary coded decimal numbers correctly within
thirty (30) seconds.
How to PlayTo begin play press Button 4. The clock will begin and a value will be displayed. Enter the displayed value on the
switches. Zero is towards the top of the game board and one is towards the bottom of the game board. The player has 30 seconds to convert as many numbers as possible. At the end
of the 30 seconds, the player’s score will be displayed. If it is the new High Score “HI” will appear next to the player’s
score. If it is not the new High Score then “00” will appear next to the player’s score. To display the High Score press Button 3. To clear the High Score Memory, press Button 2.
• Continually cycles through 00-FF at each rising edge of the clock.
• When the game is started or a value gets checked, the random number output at that instant is displayed on the 7-segment display as the new hex value.
RandomhexModule
randomhexclk
rstrnd
BTN(2)
• This module sends W8Y_control the BTN2 signal, taking into account OutOfTime. This changes the button operations in different states.
BTNcontrolModule
OutofTime
BTNcontrol
BTN2
BTN
check newscore
chkload
SW
clk
rst
Tdisp
• Checks the random hex value against the switch value
• Only checks when BTN1 is pressed during the game - Controlled by chkload, which is controlled by
W8Y_control
• If the values are equal, then the score is incremented. If they are not equal, the score remains unchanged.
Check Module
check newscore
chkload
SW
clk
rst
Tdisp
Check Module
AA 00 Score = 1
A005 Score = 0
A009 Score = 1 (unchanged)
• The 30-second game timer. • When time runs out, OurtOfTime goes high.• The game timer is displayed in decimal.
- This was accomplished by a case statement.
Timer Module
OutofTime
time
timerclkrst
clr
case time30 is
when "00011110" => time <= "00110000"; --30
when "00011101" => time <= "00101001"; --29
…
when others => time <= time30; --09to00
end case;
Timer Module
OutofTime
time
timerclkrst
clr
elsif (clk = '1' and clk'event) then
…
elsif decenable = '1' then -- during game
time490 <= time490 + 1;
if time490 = "1011011111" then -- 735 decimal
time30 <= time30 - 1;
time490 <= "0000000000";
end if;
…
• Timer construction in VHDL.
Timer Module
Actual hex values “Forced” decimal values
OutOfTime goes low when timer is initialized andgoes back to high when time runs out.
OutofTime
time
timerclkrst
clr
• The running score is displayed as you play.• For each correct answer, one LED lights up.
Beginning with the 9th correct answer, the LEDs turn off for each additional correct answer.
ScoreLED ModuleLDdisp
scoreled
newscore(3:0)
• Three states for HexBinIQ: Main, Game, ShowHigh• Main waits for BTN1 to start a new game , or you
can press BTN3 to view the high score (ShowHigh).• ShowHigh cannot be executed during the game.• State Diagram:
The ROM
Main
Game
Show-High
BTN3 = 0
BTN3 = 1
OutOfTime = 1
BTN4 = 1
• There were seven new opcodes added to the set from Lab 9.
New OpCodes
-- New Data Stack Instructions constant swapNs: opcode := X"0B"; -- Swap N, N2 -- New Return Stack, Conditional, and I/O instructions constant e1fetch: opcode := X"38"; -- E1@ constant e2fetch: opcode := X"39"; -- E2@ constant Tstore: opcode := X"3A"; -- Tstore constant Nstore: opcode := X"3B"; -- Nstore constant reset: opcode := X"3C"; -- reset constant check: opcode := X"3D"; -- Check
New OpCodes
when E1fetch =>tsel <= "01"; tload <= '1'; dssel <= "11"; esel <= '0';
when E2fetch =>tsel <= "01"; tload <= '1'; dssel <= "11"; esel <= '1';
when swapNs =>nsel <= '1'; nload <= '1'; dpush <= '1'; dpop <= '1';
when Tstore => tdload <= '1';
when Nstore => ndload <= '1';
when Reset => ResetSig <= '1';
when Check => chkload <= '1';
• The new opcodes defined in W8Y_Control.