CS122A: Lab 1


Objectives:
Steps
-- decoder_2x4.vhd
library IEEE;
use IEEE.STD_LOGIC_1164.all;
use IEEE.STD_LOGIC_ARITH.all;
use IEEE.STD_LOGIC_UNSIGNED.ALL;

entity decoder_2x4 is
	-- declare input and output ports of the decoder
end decoder_2x4;

architecture bhv of decoder_2x4 is
begin
	-- add behavioral description of the decoder
end bhv;
(Hint: A 2x4 decoder has a single 2-bit input and enables a single bit of a 4-bit output based on the input)
-- counter_2bit.vhd
library IEEE;
use IEEE.STD_LOGIC_1164.all;
use IEEE.STD_LOGIC_ARITH.all;
use IEEE.STD_LOGIC_UNSIGNED.ALL;

entity counter_2bit is
	-- declare input and output ports of the counter 
end counter_2bit;

architecture bhv of counter_2bit is
begin
	-- add behavioral description of the counter
end bhv;
Note: Your counter must have a reset and clock input.
-- lab1_top.vhd
library IEEE;
use IEEE.STD_LOGIC_1164.all;
use IEEE.STD_LOGIC_ARITH.all;
use IEEE.STD_LOGIC_UNSIGNED.ALL;

entity top is
	-- declare input and output ports of the top-level entity
end top;

architecture bhv of top is
	-- declare the counter and decoder input
	-- declare any intermediate signals
begin
	-- declare any port mappings
end bhv;
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;

entity clockdiv is
	port(
		clock:	in STD_LOGIC;
		output:	out STD_LOGIC
	);
end clockdiv;

architecture bhv of clockdiv is
	signal output_temp: STD_LOGIC := '0';
begin
	process (clock)
		variable count: integer range 0 to 50000000;
	begin
		if (clock = '1' and clock'event) then
			if (count = 12499999) then
				output_temp <= not output_temp;
				count := 0;
			else
				count := count + 1;
			end if;
		end if;
		output <= output_temp;
	end process;
end bhv;
Why is the clock divider necessary? The Digilab's clock runs at 50MHz. At that rate, you would not be able to perceive any change in the LED output.
NET "clock"			LOC = "P182";
NET "reset"			LOC = "P187";

NET "output<0>"			LOC = "P111";
NET "output<1>"			LOC = "P109";
NET "output<2>"			LOC = "P102";
NET "output<3>"			LOC = "P100";

NET "ledgp"			LOC = "P45";
The four output pins are connected to four of the eight LEDs on the Digial I/O daughter board. You must also enable the ledgp signal to "activate" the LEDs: You are now ready to download your design to a board.
End of Lab
Prepared 9/27/04 by Ryan Mannion