In this code i have input called IP i want to divide it into sub-parts and each part appear in output (SUb_M) every clock cycle, but after simulation output remains at the same value at every clock cycle (which is the first part)
I need SUb_m to be changed at every clcok cycle.
Code:
process (clk, en)
begin
for i in 0 to addi-1 loop
if(clk='1' and clk'event) then
if(EN='1') then
Sub_M <= w(i); --- w is an array
end if;[syntax=vhdl][/syntax]
I would have thought you would get a multiple driver warning, but we can't see all of the code. Your problem is you are writing this as software. A FOR loop doesn't loop like software, it's a shortcut for typing. Search for "VHDL FOR LOOPS" and you will find many examples of how to use them. To solve your problem you need to make your own counter that increments every EN='1' cycle and use that to reference the array location.
bking, you won't get a multiple driver warning, as the VHDL loop is unrolled and only the last assignment Sub_M <= w(addi-1); gets assigned.
OP what you wrote does this.
Code VHDL - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
process(clk, en)beginif(clk='1' and clk'event)thenif(EN='1')then
Sub_M <= w(0);
Sub_M <= w(1);-- ...
Sub_M <= w(addi-3);
Sub_M <= w(addi-2);
Sub_M <= w(addi-1);-- this is the final assignment to Sub_M so it is the *only* assignment that matersendif;endif;
To output each w in sequence on each clock cycle you want to do something like this.
Code VHDL - [expand]
1
2
3
4
5
6
7
8
9
10
11
process(clk)-- en was unnecessary as the process is "clocked"beginif rising_edge(clk)thenif(en='1')then
Sub_M <= w(idx);
idx <= idx +1;else
idx <=0;-- clear it when not enabled in lieu of any reset in this code.endif;endif;endprocess;