M
mightycatniyander
Hello,
I want to implement the following C++ code in VHDL
double t1 = u1 * ip1[i1] - u2 * op1[i1];
double t2 = u1 * op1[i1] + u2 * ip1[i1];
ip1[i1] = ip3 - t1;
op1[i1] = ip4 - t2;
ip3 += t1;
ip4 += t2;
i am not sure if this is correct but i have tried and came up with the
following VHDL
entity test is
port( clk : in std_logic;
ip1 : in std_logic_vector(7 downto 0);
op1 : in std_logic_vector(7 downto 0);
ip3 : in std_logic_vector(7 downto 0);
ip4 : in std_logic_vector(7 downto 0);
U1 : in std_logic_vector(7 downto 0);
U2 : in std_logic_vector(7 downto 0);
ip1o : out std_logic_vector(15 downto 0);
op1o : out std_logic_vector(15 downto 0);
ip3o : out std_logic_vector(15 downto 0);
ip4o : out std_logic_vector(15 downto 0));
end test;
architecture Behavioral of test is
signal T1 : std_logic_vector(15 downto 0);
signal T2 : std_logic_vector(15 downto 0);
begin
process(clk)
begin
T1 <= (U1 * ip1) - (U2 * op1);
T2 <= (U1 * op1) + (U2 * ip1);
ip1o <= ip3 - T1;
op1o <= ip4 - T2;
ip3o <= ip3 + T1;
ip4o <= ip4 + T2;
end process;
end Behavioral;
i would really appreciate if some one can tell me is it correct, if
not how can it be implemented correctly in VHDL?
further i want to implement this code in a sort of variable loop, i.e.
depending on the values of the output the length of the loop will
change. For example consider the following c++ code
for (int a=0; a<=100; a++)
{
i1 = i2;
i2 *= 2;
for (int i=i1; i<=k; i++)
{
//some code here;
}
}
could this be implemented in VHDL?
Thanks
I want to implement the following C++ code in VHDL
double t1 = u1 * ip1[i1] - u2 * op1[i1];
double t2 = u1 * op1[i1] + u2 * ip1[i1];
ip1[i1] = ip3 - t1;
op1[i1] = ip4 - t2;
ip3 += t1;
ip4 += t2;
i am not sure if this is correct but i have tried and came up with the
following VHDL
entity test is
port( clk : in std_logic;
ip1 : in std_logic_vector(7 downto 0);
op1 : in std_logic_vector(7 downto 0);
ip3 : in std_logic_vector(7 downto 0);
ip4 : in std_logic_vector(7 downto 0);
U1 : in std_logic_vector(7 downto 0);
U2 : in std_logic_vector(7 downto 0);
ip1o : out std_logic_vector(15 downto 0);
op1o : out std_logic_vector(15 downto 0);
ip3o : out std_logic_vector(15 downto 0);
ip4o : out std_logic_vector(15 downto 0));
end test;
architecture Behavioral of test is
signal T1 : std_logic_vector(15 downto 0);
signal T2 : std_logic_vector(15 downto 0);
begin
process(clk)
begin
T1 <= (U1 * ip1) - (U2 * op1);
T2 <= (U1 * op1) + (U2 * ip1);
ip1o <= ip3 - T1;
op1o <= ip4 - T2;
ip3o <= ip3 + T1;
ip4o <= ip4 + T2;
end process;
end Behavioral;
i would really appreciate if some one can tell me is it correct, if
not how can it be implemented correctly in VHDL?
further i want to implement this code in a sort of variable loop, i.e.
depending on the values of the output the length of the loop will
change. For example consider the following c++ code
for (int a=0; a<=100; a++)
{
i1 = i2;
i2 *= 2;
for (int i=i1; i<=k; i++)
{
//some code here;
}
}
could this be implemented in VHDL?
Thanks