]> hackdaworld.org Git - my-code/fpga.git/commitdiff
added vhd (test) code switch2usb (not working for known reasons, fixed @ccc)
authorhackbard <hackbard@hackdaworld.org>
Wed, 26 Dec 2007 01:03:42 +0000 (02:03 +0100)
committerhackbard <hackbard@hackdaworld.org>
Wed, 26 Dec 2007 01:03:42 +0000 (02:03 +0100)
switch2usb/s2u.ucf [new file with mode: 0644]
switch2usb/s2usb.vhd [new file with mode: 0644]

diff --git a/switch2usb/s2u.ucf b/switch2usb/s2u.ucf
new file mode 100644 (file)
index 0000000..4fa702b
--- /dev/null
@@ -0,0 +1,32 @@
+net "clock"      loc="A8";
+net "switch<0>"  loc="N15";
+net "switch<1>"  loc="J16";
+net "switch<2>"  loc="K16";
+net "switch<3>"  loc="K15";
+net "switch<4>"  loc="L15";
+net "switch<5>"  loc="M16";
+net "switch<6>"  loc="M15";
+net "switch<7>"  loc="N16";
+#net "button"     loc="K12";
+net "usb_full"   loc="P7";
+net "usb_data<0>" loc="N12";
+net "usb_data<1>" loc="P12";
+net "usb_data<2>" loc="N11";
+net "usb_data<3>" loc="P11";
+net "usb_data<4>" loc="N10";
+net "usb_data<5>" loc="P10";
+net "usb_data<6>" loc="M10";
+net "usb_data<7>" loc="R10";
+net "usb_fifo_addr<0>" loc="P5";
+net "usb_fifo_addr<1>" loc="M7";
+net "usb_write" loc="T5";
+net "usb_pktend" loc="M6";
+net "usb_cs" loc="T8";
+net "led<0>" loc="L14";
+net "led<1>" loc="L13";
+net "led<2>" loc="M14";
+net "led<3>" loc="L12";
+net "led<4>" loc="N14";
+net "led<5>" loc="M13";
+net "led<6>" loc="P14";
+net "led<7>" loc="R16";
\ No newline at end of file
diff --git a/switch2usb/s2usb.vhd b/switch2usb/s2usb.vhd
new file mode 100644 (file)
index 0000000..5b80e44
--- /dev/null
@@ -0,0 +1,52 @@
+library IEEE;
+use IEEE.STD_LOGIC_1164.ALL;
+use IEEE.STD_LOGIC_ARITH.ALL;
+use IEEE.STD_LOGIC_UNSIGNED.ALL;
+
+entity s2usb is
+    Port ( switch : in  STD_LOGIC_VECTOR (7 downto 0);
+           -- button : in  STD_LOGIC;
+                         clock : in STD_LOGIC;
+                         usb_full : in  STD_LOGIC;
+           usb_data : out  STD_LOGIC_VECTOR (7 downto 0);
+           usb_fifo_addr : out  STD_LOGIC_VECTOR (1 downto 0);
+           usb_write : out  STD_LOGIC;
+           usb_pktend : out  STD_LOGIC;
+                         usb_cs : out STD_LOGIC;
+                         led : out std_logic_vector(7 downto 0));
+end s2usb;
+
+architecture Behavioral of s2usb is
+
+signal prescaler : std_logic_vector(2 downto 0) := "000";
+signal state : std_logic := '1';
+
+begin
+
+usb_send : process(clock)
+begin
+
+       if(clock'event) and (clock='1') then
+               prescaler <= prescaler + 1;
+               if(prescaler="000") then
+                       if(usb_full='1') then
+                               if(state='1') then
+                                       state <= '0';
+                               elsif(state='0') then
+                                       state <= '1';
+                               end if;
+                               usb_write <= state;
+                       end if;
+               end if;
+       end if;
+       
+end process;
+
+usb_fifo_addr <= "10"; -- ep6
+usb_data <= switch;
+usb_cs <= '0';
+usb_pktend <= '1';
+led <= switch;
+
+end Behavioral;
+