How to fix 'ERROR:Xst - basic_stringFATAL_ERROR' error in Xilinx fpga? - vhdl

I have been trying to synthesize a vhdl code which simulates perfectly in Active HDL but I get the following error when synthesizing.
ERROR:Xst - basic_stringFATAL_ERROR:Xst:Portability/export/Port_Main.h:159:1.18 - This application has discovered an exceptional condition from which it cannot recover. For technical support on this issue, please visit http://www.xilinx.com/support.
library IEEE;
use IEEE.std_logic_1164.all;
use IEEE.NUMERIC_STD.ALL;
use IEEE.STD_LOGIC_UNSIGNED.all;
--use IEEE.NUMERIC_STD_UNSIGNED.all;
library work;
use work.common.all;
library UNISIM;
use UNISIM.VComponents.all;
entity main is
port(
CLK : in STD_LOGIC;
reset : in STD_LOGIC;
V_Out : out STD_LOGIC
);
end main;
--}} End of automatically maintained section
architecture main of main is
signal text : string (1 to 15) := "This is a Test.";
signal text_len : integer := 15;
signal x : integer := 50;
signal y : integer := 50;
type vramt is array (0 to H_480_272p_AV*V_480_272p_AV-1) of std_logic_vector (0 downto 0);
signal vram : vramt := (others => (others => '0'));
--signal vram : std_logic_vector(H_480_272p_AV*V_480_272p_AV-1 downto 0) := (others => '0');
attribute RAM_STYLE : string;
attribute RAM_STYLE of vram: signal is "BLOCK";
signal vram_we : std_logic;
signal vram_addr, vram_wraddr : INTEGER range 0 to H_480_272p_AV*V_480_272p_AV-1;
signal rom_addr : std_logic_vector(10 downto 0);
signal rom_data : std_logic_vector(7 downto 0);
begin
inst_get_char : entity work.Font_Rom PORT MAP (
clk => CLK,
addr => rom_addr,
data => rom_data
);
Process (CLK)
begin
if rising_edge (CLK) then
if vram_addr = H_480_272p_AV*V_480_272p_AV-1 then
vram_addr <= 0;
end if;
vram_addr <= vram_addr + 1;
V_Out <= vram(vram_addr)(0);
end if;
end process;
Process (CLK)
variable char_count : integer := 1;
variable pix_line : integer := 0;
variable bit_count : integer := 0;
variable curr_char : std_logic_vector(7 downto 0);
variable bit_data : std_logic;
begin
if rising_edge(CLK) then
if bit_count = 0 then
rom_addr <= std_logic_vector(to_unsigned(character'pos(text(char_count)), 7)) & std_logic_vector(to_unsigned(pix_line, 4));
end if;
bit_data := rom_data(bit_count);
vram_wraddr <= (y + pix_line)*H_480_272p_AV + (x + bit_count + (8* (char_count-1)));
vram(vram_wraddr)(0) <= bit_data;
if bit_count = 7 then
bit_count := 0;
if pix_line = 15 then
pix_line := 0;
if char_count = text_len then
char_count := 1;
else
char_count := char_count + 1;
end if;
else
pix_line := pix_line + 1;
end if;
else
bit_count := bit_count + 1;
end if;
end if;
end Process;
end main;

Related

How can i implement byte addressable memory in VHDL?

I want to make 4kb byte addressable memory. sorry I'm new in VHDL
I wanted my code works first write 4byte number in adress 8 (rdwr=1, addr=1000, size=10(2^2byte), idata=10001100)
then wait 8 cycles to implement writing time(ivalid=0)
Second read 4byte number from adress 8(rdwr=0, addr=1000, size=10(2^2byte))
In my purpose, the "ready" signal should be '0' while waiting for writing time
but the signal is always 'U' in simulation. I tried to figure out what is the problem but i couldn't
Can anyone help me where did a make mistake?
Here is my code
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.NUMERIC_STD.ALL;
entity Memory is
port (
clk: in std_logic;
ready: out std_logic; -- 0: busy, 1: ready
ivalid: in std_logic; -- 0: invalid, 1: valid
rdwr: in std_logic; -- 0: read, 1: write
addr: in unsigned(11 downto 0); -- byte address
size: in std_logic_vector(1 downto 0); -- 00/01/10/11: 1/2/4/8 bytes
idata: in std_logic_vector(63 downto 0);
ovalid: out std_logic; -- 0: invalid, 1: valid
odata: out std_logic_vector(63 downto 0)
);
end entity;
architecture Behavioral of Memory is
type ram_type is array (0 to (2**12)-1) of std_logic_vector(7 downto 0);
signal RAM : ram_type;
signal state : std_logic := '1'; --if ready '1'
signal queue : std_logic := '0'; --if something to do '1'
signal timer : integer := 0; --timer
signal curr_addr : unsigned(11 downto 0);
signal curr_size : std_logic_vector(1 downto 0);
signal curr_data : std_logic_vector(63 downto 0);
signal write : std_logic := '0';
signal read : std_logic := '0';
begin
process(clk)
variable vstate : std_logic := state;
variable vqueue : std_logic := queue; --if something to do '1'
variable vtimer : integer := timer; --timer
variable vcurr_addr : unsigned(11 downto 0) := curr_addr;
variable vcurr_size : std_logic_vector(1 downto 0) := curr_size;
variable vcurr_data : std_logic_vector(63 downto 0) := curr_data;
variable vwrite : std_logic := write;
variable vread : std_logic := read;
begin
--get input
if(rising_edge(clk)) then
ovalid <= '0';
if(vstate='1') then
if(ivalid='1') then
vcurr_addr := addr;
vcurr_size := size;
if(rdwr='0') then
--read
vread := '1';
else
vwrite := '1';
vcurr_data := idata;
end if;
vqueue := '1';
vtimer := 2**(to_integer(unsigned(vcurr_size)))-1;
end if;
end if;
--process
if(vqueue = '1') then
if(vtimer > 0) then
--wait for next cycle
ready <= '0';
vstate := '0';
vtimer := vtimer - 1;
else
--ok to go
if(vwrite = '1') then
--write
for x in 0 to 2**(to_integer(unsigned(vcurr_size)))-1 loop
for y in 0 to 7 loop
RAM(to_integer(vcurr_addr) + x)(y) <= vcurr_data(y + 8*x);
end loop;
end loop;
elsif(vread = '1') then
--read
for x in 0 to 7 loop
for y in 0 to 7 loop
if(x < 2**(to_integer(unsigned(vcurr_size)))) then
odata(y + 8*x) <= RAM(to_integer(vcurr_addr) + x)(y);
else
odata(y + 8*x) <= '0';
end if;
end loop;
end loop;
ovalid <= '1';
end if;
vqueue := '0';
vstate := '1';
ready <= '1';
end if;
end if;
--save variable to signals
state <= vstate;
queue <= vqueue;
timer <= vtimer;
curr_addr <=vcurr_addr;
curr_size <=vcurr_size;
curr_data<= vcurr_data;
write <= vwrite;
read <= vread;
end if;
end process;
end architecture;

FIFO using vhdl

I am writing a VHDL for fifo , but when i simulate there is no output?i cantt view the output in behavioral simulation.its like There's no data in data_in for read to be writing to the output of fifo.In my code is to write data into the FIFO first push the data onto the DataIn bus and then strobe the WriteEn input high for one clock cycle.
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
use std.textio.all;
use IEEE.NUMERIC_STD.ALL;
entity fifo_mem is
port ( clk : in std_logic;
reset : in std_logic;
enr : in std_logic;
enw : in std_logic;
data_in : in std_logic_vector (15 downto 0); --input data
data_out : out std_logic_vector(15 downto 0); --output data
fifo_empty : out std_logic;
fifo_full : out std_logic );
end fifo_mem;
architecture Behavioral of fifo_mem is
type fifo_type is array(0 to 10) of bit_vector (15 downto 0);
signal memory : fifo_type :=(others => (others => '0'));
signal readptr,writeptr : integer := 0; --read and write pointers.
signal empty,full : std_logic ;
impure function InitRamFromFile (RamFileName : in string) return fifo_type is
FILE RamFile : text is in RamFileName;
variable RamFileLine : line;
variable RAM : fifo_type;
begin
for I in 0 to 10 loop
readline (RamFile, RamFileLine);
read (RamFileLine, RAM(I));
end loop;
return RAM;
end function;
signal RAM : fifo_type :=InitRamFromFile("C:\Users\hp\Desktop\file\file1.txt");
begin
fifo_empty <= empty;
fifo_full <= full;
process(Clk,reset)
--this is the number of elements stored in fifo at a time.
--this variable is used to decide whether the fifo is empty or full.
variable num_elem : integer := 0;
begin
if(reset = '1') then
data_out <= (others => '0');
empty <= '0';
full <= '0';
readptr <= 0;
writeptr <= 0;
num_elem := 0;
elsif(rising_edge(Clk)) then
if(enr = '1' and empty = '0') then --read
data_out <=to_stdlogicvector(RAM(readptr));
readptr <= readptr + 1;
num_elem := num_elem-1;
end if;
if(enw ='1' and full = '0') then --write
RAM(writeptr)<= to_bitvector(data_in);
writeptr <= writeptr +1;
num_elem := num_elem+1;
end if;
if(readptr = 10) then --resetting read pointer.
readptr <= 0;
end if;
if(writeptr = 10) then --resetting write pointer.
writeptr <= 0;
end if;
--setting empty and full flags.
if(num_elem = 0) then
empty <= '1';
else
empty <= '0';
end if;
if(num_elem = 10) then
full <= '1';
else
full <= '0';
end if;
end if;
end process;
end Behavioral;

VHDL 3 digit 7 segment display

I have a problem with code snippet from http://langster1980.blogspot.com/2015/09/more-on-seven-segment-displays-and.html
My code:
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use ieee.numeric_std.all;
entity main is
port (
clock_in : in std_logic;
Seven_Segment_Enable : out std_logic_vector(2 downto 0);
Seven_Segment_Display : out std_logic_vector(7 downto 0)
);
end main;
architecture Behavioral of main is
signal refresh_count : integer := 0;
signal refresh_clk : std_logic := '1';
signal second_count : integer := 0;
signal second_clk : std_logic := '1';
signal digit_sel : unsigned(1 downto 0);
signal bcd : integer := 0;
signal Seven_Segment_Display_output : std_logic_vector (7 downto 0) := (others => '0');
signal bcd0, bcd1, bcd2 : integer := 0;
signal unit_count : integer := 0;
signal ten_count : integer := 0;
signal hundred_count : integer := 0;
begin
process(Clock_in)
begin
if(clock_in'event and clock_in='1') then
refresh_count <= refresh_count+1;
second_count <= second_count+1;
if(second_count = 750000) then
second_clk <= not second_clk;
second_count <= 1;
end if;
if(refresh_count = 1200) then
refresh_clk <= not refresh_clk;
refresh_count <= 1;
end if;
end if;
end process;
process(second_clk)
begin
if(second_clk'event and second_clk='1') then
bcd0 <= 0;
bcd1 <= 1;
bcd2 <= 2;
end if;
end process;
process(refresh_clk)
begin
if(refresh_clk' event and refresh_clk='1') then
digit_sel <= digit_sel + 1;
end if;
end process;
with digit_sel select
bcd <= bcd0 when "00",
bcd1 when "01",
bcd2 when others;
with digit_sel select
Seven_Segment_Enable <= "110" when "00",
"101" when "01",
"011" when others;
with bcd select
Seven_Segment_Display_output(7 downto 0) <= B"00000011" when 0,
B"11110011" when 1,
B"00100101" when 2,
B"01100001" when 3,
B"11010001" when 4,
B"01001001" when 5,
B"00001001" when 6,
B"11100011" when 7,
B"00000001" when 8,
B"01000001" when 9,
B"11111111" when others;
Seven_Segment_Display(7 downto 0) <= Seven_Segment_Display_output(7 downto 0);
end Behavioral;
My problem is with draw on display.
According to code should be draw number 012, but me result is
(Click to enlarge)
and I don't know how to fix it.
Don't you know what to do?
Sorry for my bad English.

"Iteration limit reached at time" when i try to simulate my code

I'm trying to implement Booth Algorithm in VHDL, already run a "paper test" and the code apparently works but when I simulate it I'm not getting the desire results... Then I replace the code to do an A-Shift to test but when I simulate my code I'm getting this error:
Error (suppressible): (vsim-3601) Iteration limit 5000 reached at time 180 ns.
I just replace this line: P := STD_LOGIC_VECTOR(unsigned(P) SRA 1);
For this: P := P(16) & P(16 downto 1);
This is the code atm:
LIBRARY IEEE;
USE IEEE.STD_LOGIC_1164.ALL;
USE IEEE.STD_LOGIC_UNSIGNED.ALL;
ENTITY algor_booth IS
PORT(oper1 : IN STD_LOGIC_VECTOR(7 DOWNTO 0);
oper2 : IN STD_LOGIC_VECTOR(7 DOWNTO 0);
sel : IN STD_LOGIC;
result : OUT STD_LOGIC_VECTOR(15 DOWNTO 0)
);
END ENTITY;
ARCHITECTURE algor OF algor_booth IS
BEGIN
PROCESS (sel)
VARIABLE A, S, P: STD_LOGIC_VECTOR(16 DOWNTO 0);
VARIABLE Ma2: STD_LOGIC_VECTOR(7 DOWNTO 0);
--VARIABLE flag: STD_LOGIC;
BEGIN
IF sel = '0' THEN
Ma2 := (NOT oper1) + 1;
A := oper1 & "00000000" & '0';
S := Ma2 & "00000000" & '0';
P := "00000000" & oper2 & '0';
ELSE
--flag := '0';
FOR i IN 1 TO 8 LOOP
IF P(1 DOWNTO 0) = "01" THEN
P := P + A;
--flag := '0';
--P(17) := flag;
ELSIF P(1 DOWNTO 0) = "10" THEN
P := P + S;
--flag := '1';
--P(17) := flag;
END IF;
--P(17) := flag;
P := P(16) & P(16 downto 1);
--P(17) := flag;
END LOOP;
result <= P(16 DOWNTO 1);
END IF;
END PROCESS;
END algor;
After trying a lot, just changed this line: P := P(16) & P(16 downto 1);
For this one: P(16 downto 0) := P(17 downto 1);
And problem solved!
Here is the fixed code:
LIBRARY IEEE;
USE IEEE.STD_LOGIC_1164.ALL;
USE IEEE.STD_LOGIC_UNSIGNED.ALL;
ENTITY algor_booth IS
PORT(oper1 : IN STD_LOGIC_VECTOR(7 DOWNTO 0);
oper2 : IN STD_LOGIC_VECTOR(7 DOWNTO 0);
sel : IN STD_LOGIC;
result : OUT STD_LOGIC_VECTOR(15 DOWNTO 0)
);
END ENTITY;
ARCHITECTURE algor OF algor_booth IS
BEGIN
PROCESS (oper1, oper2)
VARIABLE A, S, P: STD_LOGIC_VECTOR(17 DOWNTO 0);
VARIABLE Ma2: STD_LOGIC_VECTOR(7 DOWNTO 0);
VARIABLE flag: STD_LOGIC;
BEGIN
Ma2 := (NOT oper1) + 1;
A := '0' & oper1 & "00000000" & '0';
S := '0' & Ma2 & "00000000" & '0';
P := '0' & "00000000" & oper2 & '0';
flag := '0';
FOR i IN 1 TO 8 LOOP
IF (P(1) = '0' AND P(0) = '1') THEN
flag := '0';
P(17) := flag;
P := P + A;
ELSIF (P(1) = '1' AND P(0) = '0') THEN
flag := '1';
P(17) := flag;
P := P + S;
END IF;
P(17) := flag;
P(16 downto 0) := P(17 downto 1);
P(17) := flag;
END LOOP;
result <= P(16 DOWNTO 1);
END PROCESS;
END algor;
Thanks for your help guys!

Altera FPGA hardware (has an issue) vs ModelSim simulation (ok) - self implemented UART

I have an issue with self implemented UART in VHDL.
I wrote VHDL code which generates proper waveform when running on Altera ModelSim:
UART.vhd:
LIBRARY ieee;
USE ieee.std_logic_1164.all;
use ieee.numeric_std.ALL;
entity UART is
port (
clk_10mhz: in STD_LOGIC;
uart_clk: out STD_LOGIC;
txPin: out STD_LOGIC
);
end entity;
architecture Test of UART is
signal txStart: STD_LOGIC := '0';
signal txIdle: STD_LOGIC;
signal txData: STD_LOGIC_VECTOR(7 downto 0);
component TX is
port (
clk_in: in STD_LOGIC;
start: in STD_LOGIC;
data: in STD_LOGIC_VECTOR(7 downto 0);
tx: out STD_LOGIC;
txIdle: out STD_LOGIC;
debug_clk: out STD_LOGIC
);
end component TX;
begin
process (clk_10mhz)
variable clkDividerCounter : integer range 0 to 10000000;
variable textToSend : string(1 to 31) := "Hello darkness my old friend!" & LF & CR;
variable currentCharacterIndex : integer range 1 to 31 := 1;
variable startSending : std_logic := '0';
variable characterReceivedByTX : std_logic := '1';
begin
if (rising_edge(clk_10mhz)) then
if (startSending = '1') then
if (txIdle = '0') then
characterReceivedByTX := '1';
end if;
if (txIdle = '1' and characterReceivedByTX = '1') then
txData <= std_logic_vector(to_unsigned(character'pos(textToSend(currentCharacterIndex)), 8));
txStart <= '1';
if (currentCharacterIndex < 31) then
currentCharacterIndex := currentCharacterIndex + 1;
characterReceivedByTX := '0';
else
txStart <= '0';
currentCharacterIndex := 1;
startSending := '0';
end if;
end if;
else
if (clkDividerCounter < 10000000) then
clkDividerCounter := clkDividerCounter + 1;
startSending := '0';
else
clkDividerCounter := 0;
startSending := '1';
end if;
end if;
end if;
end process;
u1: TX port map (clk_10mhz, txStart, txData, txPin, txIdle, uart_clk);
end Test;
TX.vhd:
LIBRARY ieee;
USE ieee.std_logic_1164.all;
use ieee.numeric_std.ALL;
entity TX is
port (
clk_in: in STD_LOGIC;
start: in STD_LOGIC;
data: in STD_LOGIC_VECTOR(7 downto 0);
tx: out STD_LOGIC := '1';
txIdle: out STD_LOGIC := '1';
debug_clk: out STD_LOGIC := '0'
);
end entity;
architecture Test of TX is
signal idle: STD_LOGIC := '1';
begin
process (clk_in)
variable bitIndex : integer range 0 to 9;
variable clkDividerCounter : integer range 0 to 1042;
variable dataFrame : STD_LOGIC_VECTOR(9 downto 0);
variable dataFrameCurrentIndex : integer range 0 to 9;
begin
if (rising_edge(clk_in)) then
if (start = '1' and idle = '1') then
dataFrame(0) := '0';
dataFrame(8 downto 1) := data;
dataFrame(9) := '1';
dataFrameCurrentIndex := 0;
idle <= '0';
end if;
if (idle = '0') then
if (clkDividerCounter < 521) then
debug_clk <= '0';
else
debug_clk <= '1';
end if;
if (clkDividerCounter < 1041) then
clkDividerCounter := clkDividerCounter + 1;
else
if (dataFrameCurrentIndex < 9) then
tx <= dataFrame(dataFrameCurrentIndex);
dataFrameCurrentIndex := dataFrameCurrentIndex + 1;
else
tx <= dataFrame(dataFrameCurrentIndex);
idle <= '1';
end if;
clkDividerCounter := 0;
end if;
else
debug_clk <= '0';
end if;
end if;
end process;
txIdle <= idle;
end Test;
Unfortunately, on hardware, instead of "Hello darkness my old friend!" sent, it sends "HHello darkness my old friend!" with double H at the beginning.
I checked it on SignalTap II and waveform confirms the problem:
What can cause this problem? How may I debug such an issue?

Resources