我想转换integer类型的信号为real类型
程序如下。
这段程序在maxplus II报错:
file standard.vhdl:Unsupported feature error:floating is not supported
在quartus II中报错:
Error (10414): VHDL error at yuvtorgb.vhd(22), at object "red": a real cannot be non-constant
程序如下,请教各位大虾:
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
USE IEEE.STD_LOGIC_ARITH.ALL;
entity yuvtorgb is
port(
RAM_DBUS : in std_logic_vector(7 downto 0);
y2_select : in std_logic;
indata_v : in std_logic_vector(7 downto 0);
indata_y1 : in std_logic_vector(7 downto 0);
indata_u : in std_logic_vector(7 downto 0);
indata_y2 : in std_logic_vector(7 downto 0);
test: out std_logic
);
end entity;
architecture a of yuvtorgb is
signal data_v : INTEGER;
signal data_y1 : INTEGER;
signal data_u : INTEGER;
signal data_y2 : INTEGER;
signal red : real range 0.0 to 1000.0 :=10.0;
signal green : real;
signal blue : real;
signal addred : std_logic_vector(18 downto 0);
signal lcdpixel_num : integer range 0 to 2570;
signal pickup_tmp : std_logic;
begin
test<='1';
data_v<=conv_integer(indata_v);
data_y1<=conv_integer(indata_y1);
data_u<=conv_integer(indata_u);
data_y2<=conv_integer(indata_y2);
process(y2_select)
begin
if(y2_select'event and y2_select='0') then
red<=real(data_y1);
--red=1.164 * (data_y1 - 16) + 1.596 * (data_v - 128);
--green=1.164 * (data_y1 - 16) - 0.813 * (data_v - 128) - 0.392 * (data_u - 128);
--blue=1.164 * (data_y1 - 16) + 2.017 * (data_u - 128);
end if;
end process;
--*******************************************************************
-- Copyright(C) 2005 by Xilinx, Inc. All rights reserved.
-- This text/file contains proprietary, confidential
-- information of Xilinx, Inc., is distributed under license
-- from Xilinx, Inc., and may be used, copied and/or
-- disclosed only pursuant to the terms of a valid license
-- agreement with Xilinx, Inc. Xilinx hereby grants you
-- a license to use this text/file solely for design, simulation,
-- implementation and creation of design files limited
-- to Xilinx devices or technologies. Use with non-Xilinx
-- devices or technologies is expressly prohibited and
-- immediately terminates your license unless covered by
-- a separate agreement.
--
-- Xilinx is providing this design, code, or information
-- "as is" solely for use in developing programs and
-- solutions for Xilinx devices. By providing this design,
-- code, or information as one possible implementation of
-- this feature, application or standard, Xilinx is making no
-- representation that this implementation is free from any
-- claims of infringement. You are responsible for
-- obtaining any rights you may require for your implementation.
-- Xilinx expressly disclaims any warranty whatsoever with
-- respect to the adequacy of the implementation, including
-- but not limited to any warranties or representations that this
-- implementation is free from claims of infringement, implied
-- warranties of merchantability or fitness for a particular
-- purpose.
--
-- Xilinx products are not intended for use in life support
-- appliances, devices, or systems. Use in such applications are
-- expressly prohibited.
--
-- This copyright and support notice must be retained as part
-- of this text at all times. (c) Copyright 2005 Xilinx, Inc.
-- All rights reserved.
--
-- Title - Xil_YCrCb2RGB.vhd
-- Author(s) - GZ & WCC, Xilinx
-- Creation - 7 Dec 2005
--
-- $RCSfile: Xil_YCrCb2RGB.vhd,v $ $Revision: 1.10 $ $Date: 2006/03/15 19:56:55 $
--
-- Description -
--
--
--
--*******************************************************************
-- ******************************************************************
-- *007* YCrCb2RGB Macro from imagexlib
--
-- Description: Color Space Converter (YCrCb to RGB)
--
-- ******************************************************************
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_arith.all;
use ieee.std_logic_signed.all;
LIBRARY work;
USE work.color_space_pkg.all;
LIBRARY work;
USE work.genxlib_utils.ALL;
-- ******************************************************************
-- *009* YCrCb2RGB Macro
--
-- Description: Color Space Converter (RGB to YCrCb)
--
-- Generalized conversion:
--
-- R = (Y - Yoffset) + ACoeff' * (Cr - Coffset)
-- G = (Y - Yoffset) + BCoeff' * (Cr - 0.5) + CCoeff' * (Cb - 0.5)
-- B = (Y - Yoffset) + DCoeff' * (Cb - 0.5)
--
-- R = Y + ACoeff' * Cr - Roffset
-- G = Y + BCoeff' * Cr + CCoeff' * Cb - Goffset
-- B = Y + DCoeff' * Cb - Boffset
--
-- In order to complement RGB2YCrCb:
--
-- ACoeff' = 1/CCOEFF
-- BCoeff' = ACOEFF/CCOEFF * (1-ACOEFF-BCOEFF)
-- CCoeff' = BCOEFF/DCOEFF * (1-ACOEFF-BCOEFF)
-- DCoeff' = 1/DCOEFF
-- Roffset = Yoffset + Acoeff' * Coffset
-- Goffset = Yoffset + (Bcoeff' + Ccoeff') * Coffset
-- Boffset = Yoffset + Dcoeff' * Coffset
--
-- ITU 601 (SDTV) standard:
-- if RGB data is between 0 and 255
-- R = Y + 1.40252 * (Cr - 0.5)
-- G = Y - 0.24642 * (Cr - 0.5) - 0.11840 * (Cb - 0.5)
-- B = Y + 1.77305 * (Cb - 0.5)
--
-- In order to better match the RGB2YCbCr module:
-- For R: ACoeff' = (1/CCOEF) value 2048/1460 is approximated instead of 1.40252
-- For B: DCoeff' = (1/DCOEF) value 2048/1155 is approximated instead of 1.77305
--
-- This is the delay of a virtex4 multiplier followed by a rounder. In order to facilitate
-- grouping the rounder with the mult into the same DSP48, overall latency must be 2
--------------------------------------------------------------------
-- Create and round Cb*BCOEFF, Cb*DCOEFF, Cr*ACOEFF, Cr*CCOEFF
--------------------------------------------------------------------
del_Cr : entity work.delay(rtl) -- Delay Cr, so Acoef_by_Cr arrives in sync
generic map ( -- with Ccoef_by_Cb to the adder/rounder
width => IWIDTH,
delay => 1)
port map (
clk => clk,
d => Cr,
q => Cr_delay(IWIDTH-1 downto 0),
ce => ce);
del_Cb : entity work.delay(rtl) -- Delay Cb, so Dcoef_by_Cb arrives in sync
generic map ( -- with B_int and G_int are in sync.
width => IWIDTH,
delay => 1)
port map (
clk => clk,
d => Cb,
q => Cb_delay(IWIDTH-1 downto 0),
ce => ce);
Cb_unsign(IWIDTH-1 downto 0) <= Cb;
Cb_unsign(IWIDTH) <= '0'; -- Making sure that Cb and Cr signals are
Cb_delay(IWIDTH) <= '0'; -- interpreted as unsigned
Cr_delay(IWIDTH) <= '0'; -- at the mutlipliers
sp3_v2_v2p: if (FAMILY_HAS_MAC=0) generate
mult_aCr: entity work.mult(rtl) -- ACOEFF * Cr
generic map (
IWIDTHA => IWIDTH+1,
IWIDTHB => CWIDTH)
port map (
clk => clk,
ce => ce,
sclr => sclr,
a => Cr_delay,
b => ACOEFvec,
p => Acoef_by_Cr);
port map (
clk => clk,
ce => ce,
sclr => sclr,
a => Cb_delay,
b => DCOEFvec,
c => Boffsetvec,
p => Dcoef_by_Cb_rnd(MWIDTH downto 1));
-- sign extension for simulation (v4 results are the same as s3_v2_v2p)
--Dcoef_by_Cb_rnd(IWIDTH+CWIDTH) <= Dcoef_by_Cb_rnd(IWIDTH+CWIDTH-1);
--------------------------------------------------------------------
-- Add Y component
--------------------------------------------------------------------
del_Y : entity work.delay(rtl) -- Delay matching: y is delayed so it can be combined with rounded signals
generic map (
width => IWIDTH,
delay => 4) -- 3+FAMILY_HAS_MAC -- ADD_DELAY(FAMILY_HAS_MAC, FABRIC_ADDS)+MULT_DELAY(FAMILY_HAS_MAC)
port map (
clk => clk,
d => Y,
q => y_delay,
ce => ce);
connect_Y: if (IWIDTH=OWIDTH) generate
Y_padded(IWIDTH-1 downto 0) <= y_delay;
end generate;
padd_Y: if (IWIDTH
Y_padded(OWIDTH-1 downto OWIDTH-IWIDTH) <= y_delay;
Y_padded(OWIDTH-IWIDTH-1 downto 0) <= (others => '0');
end generate;
truncate_Y: if (IWIDTH>OWIDTH) generate
Y_padded(OWIDTH-1 downto 0) <= y_delay(IWIDTH-1 downto IWIDTH-OWIDTH);
end generate;
Y_padded(OWIDTH) <= '0'; -- Makes sure Y_padded is unsigned positive