Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronic Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Register Log in

Questions about for loops in VHDL

Status
Not open for further replies.

Flo89

Newbie level 4
Joined
Feb 16, 2014
Messages
5
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
44
Dear expers,

I'm new to VHDL and would need advice for a loop. Would it be possible to use a signal instead of the variable z in the following code?
Will it be a problem to use z in a way like in the code because of the read and then write access. I've heard about possible oscillation or things like that.
Here's the code (Of course not functional and only a cutout)


Code VHDL - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
cordic: process(clk)
    variable di: std_logic;
    variable z : std_logic_vector (PA_RES DOWNTO 0) := (others => '0');
    variable sin_temp, cos_temp : sfixed (1 downto -14);
        begin
        if(rising_edge(clk) and (enable_cordic='1')) then
                z := phase;
                sin_temp := sin_init;
                cos_temp := cos_init;
                FOR i in 0 to 12 LOOP
                    if (z(PA_RES)='1') then
                        z := std_logic_vector(signed(z) + signed(my_Rom(i)));
                    else    
                        z := std_logic_vector(signed(z) - signed(my_Rom(i)));
                    end if;
                END LOOP;
        end if;
    end process cordic;



Thanks a lot!!
Best regards,
Florian
 

FvM

Super Moderator
Staff member
Joined
Jan 22, 2008
Messages
46,972
Helped
13,933
Reputation
28,114
Reaction score
12,573
Trophy points
1,393
Location
Bochum, Germany
Activity points
273,896
Signals are updated at the end of a process, thus won't work in a loop like this.
my_ROM can't be a block RAM, because you can't access multiple memory locations in a single clock cycle.
 
  • Like
Reactions: Flo89

    Flo89

    points: 2
    Helpful Answer Positive Rating

Flo89

Newbie level 4
Joined
Feb 16, 2014
Messages
5
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
44
Thanks for the fast answer!
my_Rom is implemented like this:

Code:
type mem is array ( 0 to 12) of std_logic_vector(PA_RES downto 0);
  constant my_Rom : mem := (
    0  => "0010000000000000",
    1  => "0001001011100100",
    2  => "0000100111111011",
    3  => "0000010100010001",
    4  => "0000001010001011",
    5  => "0000000101000110",
    6  => "0000000010100011",
    7  => "0000000001010001",
    8  => "0000000000101001",
    9  => "0000000000010100",
    10 => "0000000000001010",
    11 => "0000000000000101",
    12 => "0000000000000011");
Will it work, I didn't really understand the thing with multible momory locations!
Again, thanks in advance!
 

TrickyDicky

Advanced Member level 5
Joined
Jun 7, 2010
Messages
7,001
Helped
2,056
Reputation
4,129
Reaction score
2,006
Trophy points
1,393
Activity points
38,425
That is just a constant declaration. It is how you access it in a process that makes a rom or not.
 

FvM

Super Moderator
Staff member
Joined
Jan 22, 2008
Messages
46,972
Helped
13,933
Reputation
28,114
Reaction score
12,573
Trophy points
1,393
Location
Bochum, Germany
Activity points
273,896
The rom table will be synthesized as parallel logic in the present code, in so far it works.

But you are synthesizing 13 cascaded adders and multiplexers without any pipelining, so fmax will be rather low. I also assume that the final cordic code will have more arithmetic and can't achieve any reasonable speed without pipelining.
 

Status
Not open for further replies.
Toggle Sidebar

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top