naught
Member level 3
- Joined
- Aug 25, 2012
- Messages
- 59
- Helped
- 4
- Reputation
- 8
- Reaction score
- 4
- Trophy points
- 1,288
- Location
- chengdu
- Activity points
- 1,739
I have tried the single process FSM to code, after reading many posts that suggest that`s the better way. But I come across some problems, for I have to delay certain signals...all the time.
say if I want to manipulate some RAMs. To make RAMs work, I have to delay the address signal, to match the first rising edge of the enable ena and wea signal(that is, the address 0 would be occurring at the clk with ena and wea rise to 1).
This could really get complex and confused, because there are so many signals to be delayed, when using RAMs at different layers.
it`s very inconvenient, and the problem is that I spend most of the time, when coding vhdl, on figuring out which signal should be delayed, rather than arithmetic stuff...
please help. thanks in advance.
say if I want to manipulate some RAMs. To make RAMs work, I have to delay the address signal, to match the first rising edge of the enable ena and wea signal(that is, the address 0 would be occurring at the clk with ena and wea rise to 1).
This could really get complex and confused, because there are so many signals to be delayed, when using RAMs at different layers.
it`s very inconvenient, and the problem is that I spend most of the time, when coding vhdl, on figuring out which signal should be delayed, rather than arithmetic stuff...
please help. thanks in advance.
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 process(clk,rst) begin if(rst = '1') then pr_state <= s0; cnt3584 <= 0; addr2048 <= 0; addra_ram14336 <= 0; elsif(rising_edge(clk)) then case pr_state is when s0 => if(start = '1') then pr_state <= s1; else pr_state <= s0; end if; ena_ram3584 <= '0'; wea_ream3584 <= "0"; ena_ram14336 <= '0'; wea_ram14336 <= "0"; when s1 => if(cnt3584 = 3583) then cnt3584 <= 0; else cnt3584 <= cnt3584 + 1; end if; if(cnt3584 = 3583) then pr_state <= s2; else pr_state <= s1; end if; cnt3584_d1 <= cnt3584; ena_ram3584 <= '1'; wea_ream3584 <= "1"; when s2 => ena_ram3584 <= '0'; wea_ream3584 <= "0"; ena_ram14336 <= '1'; -- enable ram14336, 1 clk delay. wea_ram14336 <= '1'; if(addr2048 = 2047) then addr2048 <= 0; else addr2048 <= addr2048 + 1; end if; if(addra_ram14336 = 14335) then addra_ram14336 <= 0; else addra_ram14336 <= addra_ram14336 + 1; end if; if(addra_ram14336 = 14335) then --RAM14336 address, needs to delay 2 clk. pr_state <= s0; else pr_state <= s2; end if; end case; ena_ram14336_d1 <= ena_ram14336; wea_ram14336_d1 <= wea_ram14336; addra_ram14336_d1 <= addra_ram14336; addra_ram14336_d2 <= addra_ram14336_d1; end if; end process;
Last edited: