All right strictly reserved. Reproduction or issue to third parties, in any form whatsoever, is not permitted without written authority from the proprietors.

VHDL Style Guide

Project Name/Projektname

Page/Seite


of/von 4

Prepared / Erstellt

Subject Responsible / Verantwortlich

Date/Datum

Rev.

File/Datei OpenOffice.org Writer

Mario Fohler

Peter Thorwartl

2008-07-31

1.0


1. VHDL Terms

1.1 Objects

1.2 Classes

1.2.1 Constants

...

architecture rtl of sine is


constant sin_ampl_c : vector_t_arr := init_sin_f(depth_g, width_g); -- returns sine amplitude value


signal ampl_cnt_s : integer range 0 to 255 := 0; -- amplitude counter

signal sine_s : std_logic_vector(width_g-1 downto 0) := (others=>'0'); -- sine


begin

...

1.2.2 Signals


1.2.3 Variable

...

write_p : process -- write 64 following sin-amplitude values in sin.txt at the work directory (only simulate)

file out_sin_f : text open write_mode is "sin.txt"; -- create file in write mode in work directory

variable out_sin_line_v : line; -- line variable

begin

wait until rising_edge(clk_in_s);

if wr_end_s = '0' and freq_trig_s = '1' then

if wr_count_s = 64 then -- write 64 amplitude values

wr_end_s <= '1'; -- write end/end of file

else

write(out_sin_line_v, dac_amplvalue_s); -- write dac_amplvalue_s value in out_sin_line_v

writeline(out_sin_f, out_sin_line_v); -- write out_sin_line_v in one line of out_sin_f

wr_count_s <= wr_count_s+1; -- increment write counter

end if;

end if;

end process;

...


1.2.4 Files

1.3 Types and Subtypes

package modulator_pkg is

type vector_t_arr is array (natural range <>) of integer;

function init_sin_f

(

constant depth_c : in integer;

constant width_c : in integer

)

return vector_t_arr;

end;

package body modulator_pkg is


function init_sin_f

(

depth_c : in integer;

width_c : in integer

)

return vector_t_arr is


variable init_arr_v : vector_t_arr(0 to (2 ** depth_c));


begin


for i in 0 to ((2 ** depth_c) / 2) loop -- calculate positive amplitude values

init_arr_v(i) := integer(round(sin((math_2_pi / real(2 ** depth_c))*

real(i)) * real(2 ** (width_c - 1)))) + integer(2 ** (width_c - 1) - 1);

end loop;


for i in ((2 ** depth_c) / 2 + 1) to (2 ** depth_c) loop -- calculate negativ amplitude values

init_arr_v(i) := integer(round(sin((math_2_pi / real(2 ** depth_c))*

real(i)) * real(2 ** (width_c - 1)))) - integer(2 ** (width_c - 1));

end loop;


return init_arr_v;


end;


end;



1.4 Units

1.4.1 Libraries

library ieee;

use ieee.std_logic_1164.all;

use ieee.std_logic_arith.all;

use ieee.std_logic_textio.all;

use ieee.std_logic_unsigned.all;

library modelsim_lib;

use modelsim_lib.util.all;

library std;

use std.textio.all;

1.4.2 Entity

entity dac_ltc2624 is

generic(

depth_g : integer range 1 to 99 := 8; -- sine signal 8bit quantized

width_g : integer range 1 to 99 := 12 -- 12 bit sine amplitude value

);

port(

btn_reset : in std_logic; -- reset button

clk_in : in std_logic; -- 50MHz clock

clkdv_in : in std_logic; -- 25MHz clock

dac_clk : out std_logic; -- dac clock

dac_cs_n : out std_logic; -- dac enable

dac_data : out std_logic; -- dac data

dac_reset_n : out std_logic; -- dac reset

freq_trig : in std_logic -- frequency for dac data packages

sine : in std_logic_vector(width_g-1 downto 0) -- frequented sine amplitude

);

end;

1.4.3 Architecture

architecture rtl of modulator is

...

begin

...

end;

1.4.4 Package

1.4.5 Package Body

1.4.6 Configuration