jimmykk
Full Member level 3
- Joined
- Oct 2, 2014
- Messages
- 158
- Helped
- 0
- Reputation
- 0
- Reaction score
- 1
- Trophy points
- 1,298
- Activity points
- 2,865
Hi
i am writing code for shift register with serial out data. i am having some code problem, when i change the STEP to value other than 14398, i dont get any output. basically STEP increases with every clock and when it equals certain count, it should output data serially.
here is my code:-
Anybody which can explain and help me where i am doing wrong
i am writing code for shift register with serial out data. i am having some code problem, when i change the STEP to value other than 14398, i dont get any output. basically STEP increases with every clock and when it equals certain count, it should output data serially.
here is my code:-
Code Verilog - [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 library ieee; use ieee.std_logic_1164.all; use ieee.numeric_std.all; entity light is port( CLOCK_50 : in std_logic; reset : in std_logic; enable : in std_logic; GPIO_1 : inout std_logic_vector(35 downto 0); GPIO_0 : out std_logic_vector(35 downto 0) ) ; end light; architecture logicfunction of light is type state_type is (wait_state,shift_state); SIGNAL present_state : state_type; signal turn : std_logic := '0'; signal RISINGEDGE : std_logic := '1'; signal count : integer range 0 to 10 :=0; -- register that keeps the count signal data : std_logic := '0'; signal shift_reg : std_logic_vector(13 downto 0) := (Others => '0'); --signal dac_cnt_half : std_logic_vector(13 downto 0) := "01110000011111"; signal dac_cnt_max : std_logic_vector(13 downto 0) := "11100000111110"; begin GPIO_1(1) <= turn; clk_div: process(CLOCK_50) begin if (rising_edge(CLOCK_50)) then if(count = 10) then --* turn <= turn XOR '1'; RISINGEDGE <= RISINGEDGE XOR '1'; count <= 0; else count <= count + 1; end if; end if; end process clk_div; MAIN: process(turn,reset) variable shift_counter : integer := 0; variable step : integer range 0 to 100000 := 0; begin if (reset = '1') then shift_reg <= (others => '0'); present_state <= wait_state; shift_counter := 0; elsif(turn'event and turn = '1') then case present_state is when wait_state => shift_counter := 0; shift_reg <= dac_cnt_max; GPIO_1(2) <= '0'; if (step = 14398) then step := 0; present_state <= shift_state; else step := step + 1; present_state <= wait_state; end if; when shift_state => shift_counter := shift_counter + 1; GPIO_1(2) <= shift_reg(0); shift_reg <= data & shift_reg(13 downto 1); if (shift_counter >= 13) then present_state <= wait_state; else present_state <= shift_state; end if; end case; end if; end process MAIN; end logicfunction;
Anybody which can explain and help me where i am doing wrong
Last edited by a moderator: