VHDL Portfolio
VHDL Portfolio
Constraints file:
# UCF file for the Papilio One 500K & 250K boards
# Generated by pin_converter, written by Kevin Lindsey
# https://github.com/thelonious/papilio_pins/tree/development/pin_converter
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
## Prohibit the automatic placement of pins that are connected to VCC or GND for
configuration.
CONFIG PROHIBIT=P99;
CONFIG PROHIBIT=P43;
CONFIG PROHIBIT=P42;
CONFIG PROHIBIT=P39;
CONFIG PROHIBIT=P49;
CONFIG PROHIBIT=P48;
CONFIG PROHIBIT=P47;
#CONFIG PART=XC3S250E-VQ100-4;
#CONFIG PART=XC3S500E-VQ100-4;
NET CLK
LOC="P89"
CLK
#NET RX
LOC="P90"
# RX
#NET TX
LOC="P88"
# TX
#NET Seg7_AN(3) LOC="P18"
# A0
#NET Seg7_DP
LOC="P23"
# A1
#NET Seg7_AN(2) LOC="P26"
# A2
#NET Seg7_E
LOC="P33"
# A3
#NET Seg7_F
LOC="P35"
# A4
#NET Seg7_C
LOC="P40"
# A5
#NET Seg7_D
LOC="P53"
# A6
#NET Seg7_A
LOC="P57"
| IOSTANDARD=LVTTL | PERIOD=31.25ns;
| IOSTANDARD=LVTTL | DRIVE=8 | SLEW=FAST;
# A7
#NET Seg7_AN(1) LOC="P60"
# A8
#NET Seg7_G
LOC="P62"
# A9
#NET Seg7_B
LOC="P65"
# A10
#NET Seg7_AN(0) LOC="P67"
# A11
#NET SPI_CS
LOC="P70"
# A12
#NET SPI_MISO
LOC="P79"
# A13
#NET SPI_MOSI
LOC="P84"
# A14
#NET SPI_SCLK
LOC="P86"
# A15
#NET VGA_VSYNC
LOC="P85"
# B0
#NET VGA_HSYNC
LOC="P83"
# B1
#NET VGA_BLUE(0) LOC="P78"
# B2
#NET VGA_BLUE(1) LOC="P71"
# B3
#NET VGA_GREEN(0) LOC="P68"
# B4
#NET VGA_GREEN(1) LOC="P66"
# B5
#NET VGA_GREEN(2) LOC="P63"
# B6
#NET VGA_RED(0) LOC="P61"
# B7
#NET VGA_RED(1) LOC="P58"
# B8
#NET VGA_RED(2) LOC="P54"
# B9
#NET AUDIO
LOC="P41"
# B10
#NET JOY_RIGHT
LOC="P36"
# B11
#NET JOY_LEFT
LOC="P34"
# B12
#NET JOY_DOWN
LOC="P32"
# B13
#NET JOY_UP
LOC="P25"
# B14
#NET JOY_SELECT LOC="P22"
# B15
#NET SWITCH(7)
LOC="P4"
C0
#NET SWITCH(6)
LOC="P3"
C1
#NET SWITCH(5)
LOC="P2"
C2
#NET SWITCH(4)
LOC="P98"
# C3
#NET SWITCH(3)
LOC="P95"
# C4
NET SWITCH(2)
LOC="P94"
| IOSTANDARD=LVTTL;
| IOSTANDARD=LVTTL;
| IOSTANDARD=LVTTL;
| IOSTANDARD=LVTTL;
| IOSTANDARD=LVTTL;
| IOSTANDARD=LVTTL;
| IOSTANDARD=LVTTL;
| IOSTANDARD=LVTTL;
| IOSTANDARD=LVTTL;
| IOSTANDARD=LVTTL;
| IOSTANDARD=LVTTL;
| IOSTANDARD=LVTTL;
| IOSTANDARD=LVTTL;
| IOSTANDARD=LVTTL;
| IOSTANDARD=LVTTL;
| IOSTANDARD=LVTTL;
| IOSTANDARD=LVTTL;
| IOSTANDARD=LVTTL;
| IOSTANDARD=LVTTL;
| IOSTANDARD=LVTTL;
| IOSTANDARD=LVTTL;
| IOSTANDARD=LVTTL;
| IOSTANDARD=LVTTL;
| IOSTANDARD=LVTTL;
| IOSTANDARD=LVTTL;
| IOSTANDARD=LVTTL;
| IOSTANDARD=LVTTL;
| IOSTANDARD=LVTTL;
| IOSTANDARD=LVTTL;
| IOSTANDARD=LVTTL;
# C5
NET SWITCH(1)
# C6
NET SWITCH(0)
# C7
NET LED(0)
# C8
NET LED(1)
# C9
NET LED(2)
C10
NET LED(3)
C11
NET LED(4)
C12
NET LED(5)
C13
NET LED(6)
C14
NET LED(7)
C15
#NET JTAG_TMS
# JTAG_TMS
#NET JTAG_TCK
# JTAG_TCK
#NET JTAG_TDI
# JTAG_TDI
#NET JTAG_TDO
# JTAG_TDO
#NET FLASH_CS
# FLASH_CS
#NET FLASH_CK
# FLASH_CK
#NET FLASH_SI
# FLASH_SI
#NET FLASH_SO
# FLASH_SO
LOC="P92"
| IOSTANDARD=LVTTL;
LOC="P91"
| IOSTANDARD=LVTTL;
LOC="P17"
| IOSTANDARD=LVTTL;
LOC="P16"
| IOSTANDARD=LVTTL;
LOC="P15" | IOSTANDARD=LVTTL;
LOC="P12" | IOSTANDARD=LVTTL;
LOC="P11" | IOSTANDARD=LVTTL;
LOC="P10" | IOSTANDARD=LVTTL;
LOC="P9" | IOSTANDARD=LVTTL;
LOC="P5" | IOSTANDARD=LVTTL;
-- Revision:
-- Revision 0.01 - File Created
-- Additional Comments:
---------------------------------------------------------------------------------library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
-- Uncomment the following library declaration if using
-- arithmetic functions with Signed or Unsigned values
--use IEEE.NUMERIC_STD.ALL;
-- Uncomment the following library declaration if instantiating
-- any Xilinx primitives in this code.
--library UNISIM;
--use UNISIM.VComponents.all;
entity Switches_LEDs is
Port ( switch_0 : in STD_LOGIC;
switch_1 : in STD_LOGIC;
LED_0 : out STD_LOGIC;
LED_1 : out STD_LOGIC;
LED_2 : out STD_LOGIC;
LED_3 : out STD_LOGIC;
LED_4 : out STD_LOGIC);
end Switches_LEDs;
architecture Behavioral of Switches_LEDs is
begin
LED_0 <= NOT(switch_0) AND switch_1; -- will light if switch_1 is up
LED_1 <= NOT(NOT(switch_0) OR NOT(switch_1)); -- will not light if switch_0 or s
witch_1 are down
LED_2 <= NOT(NOT(switch_0) AND NOT(switch_1)); -- will not light if switch_0 and
switch_1 are down
LED_3 <= (switch_0 NOR switch_1) NOR (switch_0 NOR switch_1); --should do the sa
me thing
LED_4 <= (NOT(switch_0) AND switch_1) OR (switch_0 AND NOT(switch_1)); --XOR fun
ction of switch_0 & switch_1
end Behavioral;
Chapter 8: Signal buses
[Self-Explanatory]
Chapter 9: Adder/Subtractor
---------------------------------------------------------------------------------- Company: Howard Community College
-- Engineer: Renita Mwangachuchu
--- Create Date:
07:52:39 08/13/2015
-- Design Name: Switches_LEDs
-- Module Name:
Switches_LEDs - Behavioral
-- Project Name: Switches_LEDs
-- Target Devices:
Papilio One
-- Tool versions:
-- Description:
Adds when Joy stick is pressed, otherwise subtracts Switches(
7 downto 4) from Switches(3 downto 0)
--- Dependencies:
--- Revision:
-- Revision 0.01 - File Created
-- Additional Comments:
---------------------------------------------------------------------------------library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
-- Uncomment the following library declaration if using
-- arithmetic functions with Signed or Unsigned values
use IEEE.NUMERIC_STD.ALL;
-- Uncomment the following library declaration if instantiating
-- any Xilinx primitives in this code.
--library UNISIM;
--use UNISIM.VComponent*s.all;
entity Switches_LEDs is
Port ( switches : in STD_LOGIC_VECTOR(7 downto 0);
JOY_SELECT : in STD_LOGIC;
LEDs
: out STD_LOGIC_VECTOR(7 downto 3));
end Switches_LEDs;
architecture Behavioral of Switches_LEDs is
--Declaring signals to be used within the entity's architecture
signal x
:
STD_LOGIC_VECTOR(3 downto 0);
signal y
:
STD_LOGIC_VECTOR(3 downto 0);
signal carry
:
STD_LOGIC_VECTOR(3 downto 0);
signal result :
STD_LOGIC_VECTOR(4 downto 0) := (others =>'0');
signal joy
: STD_LOGIC := '0';
begin
--Flips the result into a readable order (left to right) and connects to LEDs.
LEDs <= result(4 downto 0);
--Assign switches 0-3 to the signal x.
x <= switches(3 downto 0);
--Assign switches 4-7 to the signal y.
y <= switches(7 downto 4);
--Assign joy stick to a signal
joy <= JOY_SELECT;
--Gives the first bit of sum result
carry(3)
<= joy;
result(0)
<= x(0) XOR (y(0) XOR carry(3));
--Something about the code right here makes subtracter add 1 to everything it su
btracts... lol.
carry(0)
<= (x(0) AND (y(0) XOR carry(3))) OR (carry(3) AND x(0)) OR (car
ry(3) AND y(0));
use IEEE.NUMERIC_STD.ALL;
-- Uncomment the following library declaration if instantiating
-- any Xilinx primitives in this code.
--library UNISIM;
--use UNISIM.VComponent*s.all;
entity Switches_LEDs is
Port ( CLK : in STD_LOGIC;
LED : out STD_LOGIC_VECTOR(7 downto 0));
end Switches_LEDs;
architecture Behavioral of Switches_LEDs is
--Declaring signals to be used within the entity's architecture
signal counter
:
STD_LOGIC_VECTOR(29 downto 0) := (others
=>'0');
begin
--Assign binary counter signals to LEDs. [Must be done before if statement but w
ithin the architecture]
LED(7 downto 0) <= counter(29 downto 22);
--begin process using clock for counter
count: process(CLK)
begin
--frequency counter eats cycles per second
if (rising_edge(CLK)) then
counter <= counter+1;
end if;
end process;
-- end process
end Behavioral;
--THAT'S ALL FOLKS!
Chapter 13: Modules- Two switches control two counters (reuses counter30 from Ch
11)
---------------------------------------------------------------------------------- Company: Howard Community College
-- Engineer: Renita Mwangachuchu
--- Create Date:
07:52:39 08/13/2015
-- Design Name:
Modules
-- Module Name:
Switches_LEDs - Behavioral
-- Project Name: Switches_LEDsEDs
-- Target Devices: Papilio One
-- Tool versions:
-- Description: Test the switches, mastery of modules test. Instantiates Ch11 co
unter.
--- Dependencies:
--
-- Revision:
-- Revision 0.01 - File Created
-- Additional Comments:
-----------------------------------------------------------------------------------Library declarations
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.NUMERIC_STD.ALL;
----------------------------------------------------------------------------------ENTITY-entity Switches_LEDs is
Port ( CLK : in STD_LOGIC;
SWITCH
: in STD_LOGIC_VECTOR(1 downto 0);
LED : out STD_LOGIC_VECTOR(7 downto 0));
end Switches_LEDs;
--ARCHITECTURE-architecture Behavioral of Switches_LEDs is
--Declaring signals to be used within the entity's architecture
signal count1
signal count2
:
:
begin
--INSTANCES-- "under Begin in Architecture"
Inst_count1: counter30 PORT MAP(
CLK => CLK,
enable => SWITCH(0),
count => count1
);
Inst_count2: counter30 PORT MAP(
CLK => CLK,
enable => SWITCH(1),
count => count2
);
--Assign binary counter signals to LEDs. [Must be done before if stateme
nt but within the architecture]
LED(3 downto 0) <= count1(3 downto 0);
LED(7 downto 4) <= count2(3 downto 0);
end Behavioral;
---------------------------------------------------------------------------------- Company: Howard Community College
-- Engineer: Renita Mwangachuchu
--- Create Date:
19:56:30 10/06/2015
-- Design Name:
Segmented Switches_LEDs
-- Module Name:
Switches_LEDs - Behavioral
-- Project Name: Hex Stop Watch
-- Target Devices: Papilio One
-- Tool versions:
-- Description: Decodes binary digits into hexadecimal.
--- Dependencies:
--- Revision:
-- Revision 0.01 - File Created
-- Additional Comments:
---------------------------------------------------------------------------------library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
-- Uncomment the following library declaration if using
-- arithmetic functions with Signed or Unsigned values
--use IEEE.NUMERIC_STD.ALL;
-- Uncomment the following library declaration if instantiating
-- any Xilinx primitives in this code.
--library UNISIM;
--use UNISIM.VComponents.all;
entity Binary_Decoder is
Port ( binary : in STD_LOGIC_VECTOR (3 downto 0);
Seg7_A : out STD_LOGIC;
Seg7_B : out STD_LOGIC;
Seg7_C : out STD_LOGIC;
Seg7_D : out STD_LOGIC;
Seg7_E : out STD_LOGIC;
Seg7_F : out STD_LOGIC;
Seg7_G : out STD_LOGIC;
Seg7_DP : out STD_LOGIC);
end Binary_Decoder;
architecture Behavioral of Binary_Decoder is
begin
decoder: process( binary(3 downto 0) )
begin
CASE binary(3 downto 0) IS
WHEN "0000" => --0
WHEN
WHEN
WHEN
WHEN
WHEN
WHEN
'0';
'0';
'0';
'0';
'0';
'0';
WHEN
WHEN
WHEN
WHEN
WHEN
WHEN
WHEN
'0';
'0';
'0';
'0';
'1';
'1';
'1';
--library UNISIM;
--use UNISIM.VComponents.all;
entity Counters is
Port ( JOY_SELECT: in STD_LOGIC;
SWITCH
: in STD_LOGIC_VECTOR (1
downto 0);
seconds
: out STD_LOGIC_VECTOR (15 downto 0);
digitcounter : out STD_LOGIC_VECTOR (1 downto 0);
CLK
: in STD_LOGIC
);
end Counters;
architecture Behavioral of Counters is
signal
signal
signal
signal
begin
seconds <= counter;
digitcounter <= digitmux;
count_clk: process(CLK)
begin
if (rising_edge(CLK)) then
ns_counter2 <= ns_counter2+1;
ns_counter <= ns_counter+1;
if (ns_counter=199999) then
digitmux <= digitmux+1;
ns_counter2 <= (others => '0');
if (digitmux=11) then
digitmux <= (others => '0');
end if;
end if;
if (ns_counter=31999999) then -- when 32mil cy
lces/1 second goes by
if (JOY_SELECT='0') then
counter <= (others => '0');
else
if (switch(0)='0') then
-- switch(1) off, begin counting
if (switch(1)='0') then
-- switch(0) on, count up
counter <= count
er+1;
else
-- switch(0) off, count down
counter <= count
er-1;
end if;
else
-- switch(1) on, pause
counter <= counter;
end if;
end if;
ns_counter <= (others => '0'); --after c
ounting, reset cycle/second counter to 0 and count to 32mil again
end if;
end if;
end process;
end Behavioral;
);
END COMPONENT;
COMPONENT memory
PORT (
clka : IN STD_LOGIC;
addra : IN STD_LOGIC_VECTOR(9 DOWNTO 0);
douta : OUT STD_LOGIC_VECTOR(7 DOWNTO 0)
);
END COMPONENT;
--the signal for the counter30 module:
signal counter : STD_LOGIC_VECTOR(29 downto 0) := (others => '0');
attribute box_type : string;
attribute box_type of counter30 : component is "black_box";
attribute box_type of memory : component is "black_box";
begin
--This is an Instance of the IP CORE generated counter30 module.
Inst_counter30 : counter30
PORT MAP (
clk => CLK,
q => counter
);
Inst_memory : memory
PORT MAP (
clka => CLK,
addra => counter(29 downto 20),
douta => LED
);
end Behavioral;
Chapter 16: Audio jack and Digital to Analog Converter
---------------------------------------------------------------------------------- Company: Howard Community College
-- Engineer: Renita Mwangachuchu
--- Create Date:
15:22:18 10/19/2015
-- Design Name:
Audio Wave File
-- Module Name:
clocked_LEDs - Behavioral
-- Project Name:
DAC Practice
-- Target Devices: Papilio One (Spartan 3E -- XC3S500E-5VQ100)
-- Tool versions:
-- Description: Plays a tone of harmonic frequencies at different octaves depend
ent on counter address speed.
--- Dependencies:
--- Revision:
-- Revision 0.01 - File Created
-- Additional Comments:
--
--------------------------------------------------------------------------------library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
LIBRARY XilinxCoreLib;
-- Uncomment the following library declaration if using
-- arithmetic functions with Signed or Unsigned values
use IEEE.NUMERIC_STD.ALL;
-- Uncomment the following library declaration if instantiating
-- any Xilinx primitives in this code.
library UNISIM;
use UNISIM.VComponents.all;
entity clocked_LEDs is
Port ( CLK : in STD_LOGIC;
AUDIO : out STD_LOGIC);
end clocked_LEDs;
architecture Behavioral of clocked_LEDs is
--The component of the IP CORE generated counter 30 module
COMPONENT counter30
PORT (
clk : IN STD_LOGIC;
q : OUT STD_LOGIC_VECTOR(29 DOWNTO 0)
);
END COMPONENT;
--The memory component.
--Finally just used MATLAB to generate coeffients for initializing coe file rath
er than using calculator.
COMPONENT memory
PORT (
clka : IN STD_LOGIC;
addra : IN STD_LOGIC_VECTOR(9 DOWNTO 0);
douta : OUT STD_LOGIC_VECTOR(7 DOWNTO 0)
);
END COMPONENT;
--The digital to analog converter.
COMPONENT dac8
PORT(
CLK : IN std_logic;
Data : IN std_logic_vector(7 downto 0);
PulseStream : OUT std_logic
);
END COMPONENT;
--the signal for the counter30 module:
signal counter : STD_LOGIC_VECTOR(29 downto 0) := (others => '0');
--the signal that transfers sine wave values to analog converter.
signal datastream: STD_LOGIC_VECTOR(7 downto 0) :=(others => '0');
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
-- Uncomment the following library declaration if using
-- arithmetic functions with Signed or Unsigned values
--use IEEE.NUMERIC_STD.ALL;
-- Uncomment the following library declaration if instantiating
-- any Xilinx primitives in this code.
--library UNISIM;
--use UNISIM.VComponents.all;
entity dac8 is
Port ( CLK : in STD_LOGIC;
Data : in STD_LOGIC_VECTOR (7 downto 0);
PulseStream : out STD_LOGIC);
end dac8;
architecture Behavioral of dac8 is
signal sum : STD_LOGIC_VECTOR(8 downto 0);
begin
Pulsestream <= sum(8);
process (CLK, sum)
begin
if (rising_edge(CLK)) then
sum <= ("0" & sum(7 downto 0)) + ("0" &data);
end if;
end process;
end Behavioral;
Chapter 17: Combination Lock (Password: LOGIC)
---------------------------------------------------------------------------------- Company: Howard Community College
-- Engineer: Renita Mwangachuchu
--- Create Date:
18:24:33 12/03/2015
-- Design Name:
Combination LockMech
-- Module Name:
LockMech - Behavioral
-- Project Name: MyCombination
-- Target Devices: Papilio One 500K
-- Tool versions:
-- Description: Makes a combination lock out of switches, LEDs, and joystick.
-Reuses Ch15 flashylights and counter30 f
rom Ch11
-- Dependencies:
--- Revision:
-- Revision 0.01 - File Created
-- Additional Comments:
---------------------------------------------------------------------------------library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
-- Uncomment the following library declaration if using
-- arithmetic functions with Signed or Unsigned values
--use IEEE.NUMERIC_STD.ALL;
-- Uncomment the following library declaration if instantiating
-- any Xilinx primitives in this code.
--library UNISIM;
--use UNISIM.VComponents.all;
entity LockMech is
Port ( CLK : in STD_LOGIC;
SWITCH : in STD_LOGIC_VECTOR (7 downto 0);
LED : out STD_LOGIC_VECTOR (7 downto 0));
end LockMech;
architecture Behavioral of LockMech is
--Components
COMPONENT counter30
PORT (
clk : IN STD_LOGIC;
q : OUT STD_LOGIC_VECTOR(29 DOWNTO 0)
);
END COMPONENT;
COMPONENT flashylights
PORT (
clka : IN STD_LOGIC;
addra : IN STD_LOGIC_VECTOR(9 DOWNTO 0);
douta : OUT STD_LOGIC_VECTOR(7 DOWNTO 0)
);
END COMPONENT;
attribute box_type: string;
attribute box_type of counter30: component is "black_box";
attribute box_type of flashylights: component is "black_box";
--Constants
constant error_state
constant start_state
constant first_state
constant second_state:
constant third_state
constant open_state
--Signals
signal state
');
signal flashy
');
signal counter
;
begin
--Instances
CounterMod : counter30
:
STD_LOGIC_VECTOR(3 downto 0) := (others => '0');
:
STD_LOGIC_VECTOR(3 downto 0) := "0001";
: STD_LOGIC_VECTOR(3 downto 0) := "0010";
STD_LOGIC_VECTOR(3 downto 0) := "0011";
: STD_LOGIC_VECTOR(3 downto 0) := "0100";
: STD_LOGIC_VECTOR(3 downto 0) := "0101";
: STD_LOGIC_VECTOR(3 downto 0) := (others => '0
: STD_LOGIC_VECTOR(7 downto 0) := (others => '0
:
PORT MAP (
clk => CLK,
q => counter
);
MemoryMod : flashylights
PORT MAP (
clka => CLK,
addra => counter(29 downto 20),
douta => flashy
);
--Processes
fsm : process(CLK, SWITCH, state, flashy)
begin
if (rising_edge(CLK)) then
if (SWITCH(0) = '1') then
case state is --WHEN the current state is in....
when start_state =>
--in start state...
case SWITCH(7 downto 1) is
--LEDs do start sequence, look at the switches for next state
when "0011001" =>
state
start_state; --"L" to stay in start state
when "1111001" =>
state <= first_state; --"O" to move to first state
when others =>
state <= error_state;
LED <= "10000001";
end case;
when first_state => --in first state...
case SWITCH(7 downto 1) is
--No LEDs, look at the switches for next state
when "1111001" =>
state
first_state; --"O"
when "1110001" =>
state <= second_state; --"G"
when others =>
state <= error_state;
LED <= (others => '0');
end case;
when second_state =>
--in second state
case SWITCH(7 downto 1) is
--No LEDs, look at the switches for next state
when "1110001" =>
state
second_state; --"G"
when "1001001" =>
state <= third_state; --"I"
when others =>
state <= error_state;
end case;
when third_state => -- in third state
case SWITCH(7 downto 1) is
--No LEDs, look at the switches for open state
when "1001001" =>
state
third_state; --"I"
when "1100001" =>
state <= open_state; --"C"
when others =>
state <= error_state;
<=
<=
<=
<=
end case;
when open_state=>
-- Additional Comments:
---------------------------------------------------------------------------------library IEEE;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
-- Uncomment the following library declaration if using
-- arithmetic functions with Signed or Unsigned values
--use IEEE.NUMERIC_STD.ALL;
-- Uncomment the following library declaration if instantiating
-- any Xilinx primitives in this code.
--library UNISIM;
--use UNISIM.VComponents.all;
entity TX is
Port ( CLK : in STD_LOGIC;
SWITCH : in STD_LOGIC_VECTOR(7 downto 0);
JOY_SELECT : in STD_LOGIC;
data_out : out STD_LOGIC);
end TX;
architecture Behavioral of TX is
signal busyshiftreg : STD_LOGIC_VECTOR(9 downto 0) := (others => '0');
signal datashiftreg : STD_LOGIC_VECTOR(9 downto 0) := (others => '1');
signal counter : STD_LOGIC_VECTOR(12 downto 0) := (others => '0');
signal databyte : STD_LOGIC_VECTOR(7 downto 0) := "01011010" ;
--signal busy_out : STD_LOGIC;
begin
data_out <= datashiftreg(0);
--busy_out <= busyshiftreg(0);
databyte <= SWITCH;
TXshiftreg : process(CLK)
begin
if (rising_edge(CLK)) then
if (JOY_SELECT = '0') then --When the Joy stick is pressed
if busyshiftreg(0) = '0' then -- if the transmitter is n
ot busy then
busyshiftreg <= (others => '1'); --set busyshift
register to busy
datashiftreg <= '1' & databyte & '0'; -- load da
tabyte into shift register
counter <= (others => '0'); --reset counter
else
if counter = 3332 then --sending data bits at 96
00 baud
datashiftreg <= '1' & datashiftreg(9 dow
nto 1); -- shift register sends databytes in serial stream
busyshiftreg <= '0' & busyshiftreg(9 dow
nto 1); --count down til busy signal is turned off
counter <= (others => '0');
else
counter <= counter+1;
end if;
end if;
end if;
end if;
end process;
end Behavioral;
Chapter 21: Use putty to transmit and recieve signals (RX/TX)
---------------------------------------------------------------------------------- Company: Gadget Factory
-- Engineer: Jack Gassett
--- Create Date:
22:31:30 11/27/2010
-- Design Name:
UART Example
-- Module Name:
UARTExample - Behavioral
-- Project Name:
CH21
-- Target Devices: Papilio One 500K
-- Tool versions:
-- Description: Example code for implementing the Xilinx UART example on the Pap
ilio One. Edited to send typed letters to LED and send SWITCHES to Putty.
-http://www.xilinx.com/support/documentation/application_notes/x
app223.pdf
-- Dependencies:
-Requires the latest Picoblaze so
urce code. Xilinx EULA does not allow the redistribution of Source code so the s
ource modules must be downloaded seperately.
-- Revision:
-- Revision 0.01 - File Created
-- Additional Comments:
---------------------------------------------------------------------------------library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
-- Uncomment the following library declaration if using
-- arithmetic functions with Signed or Unsigned values
--use IEEE.NUMERIC_STD.ALL;
-- Uncomment the following library declaration if instantiating
-- any Xilinx primitives in this code.
--library UNISIM;
--use UNISIM.VComponents.all;
entity UARTExample is
Port ( rx : in STD_LOGIC;
tx : out STD_LOGIC;
JOY_SELECT: in STD_LOGIC;
SWITCH: in STD_LOGIC_VECTOR(7 downto 0);
LED: out STD_LOGIC_VECTOR(7 downto 0);
extclk : in STD_LOGIC
);
end UARTExample;
component uart_rx is
port (
serial_in : in STD_LOGIC;
read_buffer : in STD_LOGIC;
reset_buffer : in STD_LOGIC;
en_16_x_baud : in STD_LOGIC;
clk : in STD_LOGIC;
data_out : out STD_LOGIC_VECTOR (7 downto 0);
buffer_data_present : out STD_LOGIC;
buffer_half_full : out STD_LOGIC;
buffer_full : out STD_LOGIC);
end component;
COMPONENT dcm32to96
PORT(
CLKIN_IN : IN std_logic;
CLKFX_OUT : OUT std_logic;
CLKIN_IBUFG_OUT : OUT std_logic;
CLK0_OUT : OUT std_logic
);
END COMPONENT;
signal dout : STD_LOGIC_VECTOR (7 downto 0);
signal data_present, en_16_x_baud, clk, clk32 : STD_LOGIC;
signal baud_count : integer range 0 to 5 :=0;
begin
LED <= dout;
baud_timer: process(clk)
begin
if clk'event and clk='1' then
if baud_count=1 then
baud_count <= 0;
en_16_x_baud <= '1';
else
baud_count <= baud_count + 1;
en_16_x_baud <= '0';
end if;
end if;
end process baud_timer;
Final Project: Display a circle on the VGA monitor (Uses VGA_Palette mostsimple
design).
---------------------------------------------------------------------------------- Company: Howard Community College
-- Engineer: Renita Mwangachuchu
--- Create Date:
19:11:09 12/08/2015
-- Design Name:
CircleProject
-- Module Name:
CircleProject - Behavioral
-- Project Name: CircleProject
-- Target Devices: Papilio One 500K
-- Tool versions:
-- Description: Make a circle by manipulating given VGA project files.
--- Dependencies:
--- Revision:
-- Revision 0.01 - File Created
-- Additional Comments:
--
--------------------------------------------------------------------------------library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
-- Uncomment the following library declaration if using
-- arithmetic functions with Signed or Unsigned values
--use IEEE.NUMERIC_STD.ALL;
-- Uncomment the following library declaration if instantiating
-- any Xilinx primitives in this code.
--library UNISIM;
--use UNISIM.VComponents.all;
entity CircleProject is
port(
ext_clock: in std_logic;
red: out std_logic;
green: out std_logic;
blue: out std_logic;
hsync: out std_logic;
vsync: out std_logic;
-c: out std_logic
);
end CircleProject;
architecture Behavioral of CircleProject is
component dcm_32_to_25
port(
clkin_in: in std_logic;
clkfx_out: out std_logic;
clkin_ibufg_out: out std_logic;
clk0_out: out std_logic
);
end component;
constant PIXEL_COUNT: integer := 800;
constant LINE_COUNT: integer := 525;
signal pixel_counter: unsigned(9 downto 0) := (others => '0');
signal line_counter: unsigned(9 downto 0) := (others => '0');
signal clock: std_logic;
begin
vga_clock: dcm_32_to_25
port map(
clkin_in => ext_clock,
clkfx_out => clock,
clkin_ibufg_out => open,
clk0_out => open
);
update_pixel_counter: process(clock)
begin
if clock'event and clock = '1' then
if pixel_counter = PIXEL_COUNT - 1 then
pixel_counter <= (others => '0');
else
pixel_counter <= pixel_counter + 1;
end if;
end if;
end process;
update_line_counter: process(clock)
begin
if clock'event and clock = '1' then
if line_counter = LINE_COUNT - 1 then
line_counter <= (others => '0');
elsif pixel_counter = PIXEL_COUNT - 1 then
line_counter <= line_counter + 1;
end if;
end if;
end process;
update_hsync: process(clock)
begin
if clock'event and clock
if pixel_counter
hsync <=
else
hsync <=
end if;
end if;
end process;
= '1' then
<= 95 then
'0';
'1';
update_vsync: process(clock)
begin
if clock'event and clock = '1' then
if line_counter <= 1 then
vsync <= '0';
else
vsync <= '1';
end if;
end if;
end process;
update_pixel: process(clock)
begin
if rising_edge(clock) then
if pixel_counter >144 and pixel_counter <PIXEL_COUNT-16 and line_cou
nter < LINE_COUNT-35 and line_counter > 30 then
blue <= '1';
green <= '1';
red <= '1';
if (480*pixel_counter-pixel_cou
nter*pixel_counter+640*line_counter-line_counter*line_counter )> 157696 then
blue <= '1';
green <= '0';
red <= '1';
end if;
else
red <= '0';
green <= '0';
blue <= '0';
end if;
end if;
end process;
process(clock)
begin
c <= clock;
end process;
end Behavioral;