Altera_Forum
Honored Contributor
11 years agonumbers, numbers...
Being new to VHDL, I must admit I find quite confusing the correct application of the use numbers in VHDL.
For the problem I wish to have help on in my thread here, I have found that my VHDL simulates correctly, but when finally mapped to a 'read' FPGA, the timings are halved. I think it must be down to the way in which I am using and applying numbers perhaps. If I hard code numbers in VHDL it is fine, if a core processor writes these numbers, my outputs go twice as fast. This works correctly:
Horizontal_proc : process (IN_RESETn, IN_CLK)
begin
if IN_RESETn = '0' then
counter_HORIZONTAL_7_0 <= (others=>'0');
counter_HORIZ_SYNC_WDTH_3_0 <= (others=>'0');
HS <= '0';
Hdisp <= '0';
elsif falling_edge(IN_CLK) then
--Horizontal TOTAL end? Hdisp Start
if MAKE_BINARY(counter_HORIZONTAL_7_0) = b"0010_1111" then --REG_R00_HORIZ_TOTAL_7_0
counter_HORIZONTAL_7_0 <= (others=>'0');
Twice as fast:
Horizontal_proc : process (IN_RESETn, IN_CLK)
begin
if IN_RESETn = '0' then
counter_HORIZONTAL_7_0 <= (others=>'0');
counter_HORIZ_SYNC_WDTH_3_0 <= (others=>'0');
HS <= '0';
Hdisp <= '0';
elsif falling_edge(IN_CLK) then
--Horizontal TOTAL end? Hdisp Start
if MAKE_BINARY(counter_HORIZONTAL_7_0) = REG_R00_HORIZ_TOTAL_7_0 then
counter_HORIZONTAL_7_0 <= (others=>'0');
etc.
I am including:
library IEEE;
use IEEE.std_logic_1164.all;
use IEEE.std_logic_arith.all;
use work.config.all;
The entity I/O's:
entity mythingy is
port (
IN_E : in STD_LOGIC;
IN_RS : in STD_LOGIC;
IN_CSn : in STD_LOGIC;
IN_RW : in STD_LOGIC;
IO_D_7_0 : inout STD_LOGIC_VECTOR (7 downto 0);
IN_RESETn : in STD_LOGIC;
IN_CLK : in STD_LOGIC
);
end mythingy;
That counter & matching 'reset' register above:
signal REG_R00_HORIZ_TOTAL_7_0 : STD_LOGIC_VECTOR (7 downto 0); --Horizontal Total
signal counter_HORIZONTAL_7_0 : UNSIGNED (7 downto 0);
Register 'programmed' thus:
ext_write : process(IN_RESETn, IN_E, IN_CSn, IN_RW, IN_RS)
begin
if IN_RESETn = '0' then
REG_R00_HORIZ_TOTAL_7_0 <= b"0010_1111";
elsif falling_edge(IN_E) and IN_CSn='0' and IN_RW='0' then --Grab data from data bus and program into indexed register.
case REG_INDEX_ADDR_4_0 is --Use Reg Index to write D0-7 to reg
when INDEX_HT => REG_R00_HORIZ_TOTAL_7_0 <= IO_D_7_0;
etc
appears OK to me, but I am thinking non-standard libraries or some mis-match of types or skewed binary numbers (right-shifted) and hence the counter stops at half the count I am expecting and hence runs twice as fast when VHDL mapped into an FPGA. Any useful insights would be much appreciated. Thorough understanding of number systems is VERY important of course! Cheers, Andy