User Tools

Site Tools


fpga:vhdl

This is an old revision of the document!


Table of Contents

VHDL

Basics

Time suffixes

fs femtoseconds
ps picoseconds
ns nanoseconds
us microseconds
ms milliseconds
sec seconds
min minutes
hr hours

Conversions

library ieee;
use ieee.std_logic_1164.all; -- std_logic_vector
use ieee.numeric_std.all; -- signed and unsigned
 
-- numbers, math operations allowed
signal my_int : integer; -- 32 bit 2-complement
signal my_uint : unsigned (7 downto 0);
signal my_sint : signed (7 downto 0);
 
-- loose bits, math operations not allowed
signal my_bits : std_logic_vector (7 downto 0);
 
-- conversions between integers
my_uint <= to_unsigned(my_int, 8); -- Must specify bit length
my_sint <= to_signed(my_int, 8);
 
my_int <= to_integer(my_uint);
my_int <= to_integer(my_sint);
 
-- casts between binary representations, number of bits must match
my_uint <= unsigned(my_sint);
my_uint <= unsigned(my_bits);
 
my_sint <= signed(my_uint);
my_sint <= signed(my_bits);
 
my_bits <= std_logic_vector(my_uint);
my_bits <= std_logic_vector(my_sint);
fpga/vhdl.1641467265.txt.gz · Last modified: 2022/09/12 00:30 (external edit)

Except where otherwise noted, content on this wiki is licensed under the following license: CC0 1.0 Universal
CC0 1.0 Universal Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki