needhelp123
Newbie level 5
- Joined
- Aug 7, 2013
- Messages
- 8
- Helped
- 0
- Reputation
- 0
- Reaction score
- 0
- Trophy points
- 1
- Activity points
- 65
Code VHDL - [expand] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 Library IEEE; use IEEE.std_logic_1164.all; use IEEE.std_logic_unsigned.all; use IEEE.std_logic_arith.all; ENTITY fpga is port( data_clk: in std_logic; data_out: out std_logic; data_in: in std_logic; osc: in std_logic; rst: in std_logic; LED: out std_logic ); END fpga; ARCHITECTURE behaviour of fpga is signal counter: integer range 0 to 7; signal data: std_logic; signal output2: std_logic_vector(7 downto 0); signal receiving: std_logic_vector(7 downto 0); begin process(osc,rst) begin if(rst = '0') then -- reset button pressed counter <= 0; -- counter will show 0 output2 <= "01000110"; -- output2 still running LED <= '1'; -- LED will not light up data_out <= '0'; elsif (rising_edge(osc)) then receiving <= receiving(6 downto 0) & data_in; --shifts the bottom seven bits of receiving left by one --puts the new data bit from the data_in to bit 0 of dat_reg if (data_in = data_out) then -- compare data_in & data_out LED <= '0'; else LED <= '1'; end if; if(counter < 7) then counter <= counter + 1; else counter <= 0; end if; case counter is -- Transmitter when 0 => data_out <= output2(0); when 1 => data_out <= output2(1); when 2 => data_out <= output2(2); when 3 => data_out <= output2(3); when 4 => data_out <= output2(4); when 5 => data_out <= output2(5); when 6 => data_out <= output2(6); when 7 => data_out <= output2(7); when others => data_out <= '0'; end case; end if; end process; end behaviour;
if(rising_edge(clk)) then
temp_delay <= temp;
end if;
Code VHDL - [expand] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 Library IEEE; use IEEE.std_logic_1164.all; use IEEE.std_logic_unsigned.all; use IEEE.std_logic_arith.all; ENTITY fpga is port( data_clk: in std_logic; data_out: out std_logic; data_in: in std_logic; osc: in std_logic; rst: in std_logic; LED: out std_logic ); END fpga; ARCHITECTURE behaviour of fpga is signal counter: integer range 0 to 7; signal data: std_logic; signal output2: std_logic_vector(7 downto 0); signal receiving: std_logic_vector(7 downto 0); begin process(osc,rst) variable tmp: std_logic; -- <----------------------------Variable used in the process begin tmp:=data -- <----------------------------Output result data_out<=tmp if(rst = '0') then -- reset button pressed counter <= 0; -- counter will show 0 output2 <= "01000110"; -- output2 still running LED <= '1'; -- LED will not light up data_out <= '0'; elsif (rising_edge(osc)) then receiving <= receiving(6 downto 0) & data_in; --shifts the bottom seven bits of receiving left by one --puts the new data bit from the data_in to bit 0 of dat_reg if (data_in = data_out) then -- compare data_in & data_out LED <= '0'; else LED <= '1'; end if; if(counter < 7) then counter <= counter + 1; else counter <= 0; end if; case counter is -- <---------------------------Memorise the result when 0 => data <= output2(0); when 1 => data <= output2(1); when 2 => data <= output2(2); when 3 => data <= output2(3); when 4 => data <= output2(4); when 5 => data <= output2(5); when 6 => data <= output2(6); when 7 => data <= output2(7); when others => data_out <= '0'; end case; end if; end process; end behaviour;
Code VHDL - [expand] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 Library IEEE; use IEEE.std_logic_1164.all; use IEEE.std_logic_unsigned.all; use IEEE.std_logic_arith.all; ENTITY fpga is port( data_clk: in std_logic; data_out: out std_logic; data_in: in std_logic; osc: in std_logic; rst: in std_logic; LED: out std_logic ); END fpga; ARCHITECTURE behaviour of fpga is signal counter: integer range 0 to 7; signal data: std_logic; signal output2: std_logic_vector(7 downto 0); signal receiving: std_logic_vector(7 downto 0); begin process(osc,rst) begin if(rst = '0') then -- reset button pressed counter <= 0; -- counter will show 0 output2 <= "01000110"; -- output2 still running LED <= '1'; -- LED will not light up data_out <= '0'; elsif (rising_edge(osc)) then receiving <= receiving(6 downto 0) & data_in; --shifts the bottom seven bits of receiving left by one --puts the new data bit from the data_in to bit 0 of dat_reg if (data_in = data_out) then -- compare data_in & data_out LED <= '0'; else LED <= '1'; end if; if(counter < 7) then counter <= counter + 1; else counter <= 0; end if; case counter is -- Transmitter when 0 => data <= output2(0); when 1 => data <= output2(1); when 2 => data <= output2(2); when 3 => data <= output2(3); when 4 => datat <= output2(4); when 5 => data <= output2(5); when 6 => data <= output2(6); when 7 => data <= output2(7); when others => data <= '0'; end case; data_out<=data end if; end process; end behaviour;
on which signal u want one cycle dealy...?
Code VHDL - [expand] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 library IEEE; use IEEE.STD_LOGIC_1164.ALL; ENTITY fpga is port( data_clk: in std_logic; data_out: inout std_logic; data_in: in std_logic; osc: in std_logic; rst: in std_logic; LED: out std_logic ); END fpga; ARCHITECTURE behaviour of fpga is signal counter: integer range 0 to 7; signal data: std_logic; signal output2: std_logic_vector(7 downto 0); signal receiving: std_logic_vector(7 downto 0); signal add_delay: std_logic; begin process(osc,rst) begin if(rst = '0') then -- reset button pressed counter <= 0; -- counter will show 0 output2 <= "01000110"; -- output2 still running LED <= '1'; -- LED will not light up receiving<= X"00"; data<='0'; add_delay<='0'; elsif (rising_edge(osc)) then receiving <= receiving(6 downto 0) & data_in; --shifts the bottom seven bits of receiving left by one --puts the new data bit from the data_in to bit 0 of dat_reg if (data_in = data_out) then -- compare data_in & data_out LED <= '0'; else LED <= '1'; end if; if(counter < 7) then counter <= counter + 1; else counter <= 0; end if; case counter is -- Transmitter when 0 => data <= output2(0); when 1 => data <= output2(1); when 2 => data <= output2(2); when 3 => data <= output2(3); when 4 => data <= output2(4); when 5 => data <= output2(5); when 6 => data <= output2(6); when 7 => data <= output2(7); when others => data <= '0'; end case; add_delay<= data; end if; end process; --data_out<=add_dealy; process(osc,rst) begin if rst='0' then data_out<='0'; elsif (rising_edge(osc)) then --add_delay<= data; data_out<= add_delay; end if; end process; end behaviour;
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?