how can i configure flycheck in vhdl code to recognize signals in packages - emacs

I 'm trying to use emacs flycheck for vhdl coding environment.
My problem is that flycheck cannot recognize packages and records in the packages and show warning such that "unit xx not found in library work"
I have also set (custom-set-variables '(flycheck-ghdl-workdir "/XXX/tWork/RTL/Mult/src/vhdl")) to show the directory of the source code to the flycheck
warning in emacs vhdl
How can i configure flycheck appropriately.
PS: below is new edit:
Let me clear this things first.
I have vhd file that includes a package as follows:
library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;
use work.multPckg.all;
entity mutl is
port(
iClk : in std_logic;
iRst : in std_logic;
iData : in dataInRecord;
);
end entity mutl;
architecture RTL of mutl is
signal dataIni1 : dataInRecord := cDataInRecord;
signal dataIni2 : dataInRecord := cDataInRecord;
--signal x : std_logic;
begin
--x <= osman;
inRegPro : process (iClk) is
begin
if rising_edge(iClk) then
dataIni1 <= iData;
dataIni2 <= dataIni1;
end if;
end process inRegPro;
end architecture RTL;`
and the multPckg is in the same directory and coded by me
library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;
package multPckg is
constant dataInBitW : integer := 8;
constant dataOutBitW : integer := 8;
type dataInRecord is record
in1 : std_logic_vector(dataInBitW-1 downto 0);
in2 : std_logic_vector(dataInBitW-1 downto 0);
end record dataInRecord;
constant cDataInRecord : dataInRecord := ((others => '0'), (others => '0'));
end package multPckg;
package body multPckg is
end package body multPckg;
emacs warn me about the line use work.multPckg.all; because of it cannot find the library work. Is there any way for emacs flycheck to find the work.multPckg not to give that warnings.
I hope i'm clear about the issue.

Related

How to examine the structures in Windbg?

I'm trying to use dt command to see the values of the structure fields. But it doesn't work for some reason:
dt ntkrnlmp!_SECURITY_SUBJECT_CONTEXT rdx
Cannot find specified field members.
Nevertheless, if I check if windbg knows the structure, it works just fine:
dt ntkrnlmp!_SECURITY_SUBJECT_CONTEXT
+0x000 ClientToken : Ptr64 Void
+0x008 ImpersonationLevel : _SECURITY_IMPERSONATION_LEVEL
+0x010 PrimaryToken : Ptr64 Void
+0x018 ProcessAuditId : Ptr64 Void
add # before register name
dt foo!blah #bar or use
? #rdx and provide the physical value
dt foo!blah 0x13371337

I2C returning Busy or Error on memory reading

I started the following code to handle a Bosch BME280 sensor with a Nucleo-F446ZE and a Nucleo-F411RE boards.
with STM32.Device; use STM32.Device;
with STM32.GPIO; use STM32.GPIO;
with STM32; use STM32;
with STM32.I2C;
with HAL.I2C; use HAL.I2C;
use HAL;
procedure Simple_I2C_Demo is
-- I2C Bus selected
Selected_I2C_Port : constant access STM32.I2C.I2C_Port := I2C_1'Access;
Selected_I2C_Port_AF : constant GPIO_Alternate_Function := GPIO_AF_I2C1_4;
Selected_I2C_Clock_Pin : GPIO_Point renames PB8;
Selected_I2C_Data_Pin : GPIO_Point renames PB9;
Port : constant HAL.I2C.Any_I2C_Port := Selected_I2C_Port;
-- Shift one because of 7-bit addressing
I2C_Address : constant HAL.I2C.I2C_Address := 16#76# * 2;
procedure SetupHardware is
GPIO_Conf_AF : GPIO_Port_Configuration (Mode_AF);
Selected_Clock_Speed : constant := 10_000;
begin
Enable_Clock (Selected_I2C_Clock_Pin);
Enable_Clock (Selected_I2C_Data_Pin);
Enable_Clock (Selected_I2C_Port.all);
STM32.Device.Reset (Selected_I2C_Port.all);
Configure_Alternate_Function (Selected_I2C_Clock_Pin, Selected_I2C_Port_AF);
Configure_Alternate_Function (Selected_I2C_Data_Pin, Selected_I2C_Port_AF);
GPIO_Conf_AF.AF_Speed := Speed_100MHz;
GPIO_Conf_AF.AF_Output_Type := Open_Drain;
GPIO_Conf_AF.Resistors := Pull_Up;
Configure_IO (Selected_I2C_Clock_Pin, GPIO_Conf_AF);
Configure_IO (Selected_I2C_Data_Pin, GPIO_Conf_AF);
STM32.I2C.Configure
(Selected_I2C_Port.all,
(Clock_Speed => Selected_Clock_Speed,
Addressing_Mode => STM32.I2C.Addressing_Mode_7bit,
Own_Address => 16#00#, others => <>));
STM32.I2C.Set_State (Selected_I2C_Port.all, Enabled => True);
end SetupHardware;
ID : HAL.I2C.I2C_Data (1 .. 1);
Status : HAL.I2C.I2C_Status;
begin
SetupHardware;
HAL.I2C.Mem_Read (This => Port.all,
Addr => I2C_Address,
Mem_Addr => 16#D0#,
Mem_Addr_Size => HAL.I2C.Memory_Size_8b,
Data => ID,
Status => Status,
Timeout => 15000);
if Status /= Ok then
raise Program_Error with "I2C read error:" & Status'Img;
end if;
end Simple_I2C_Demo;
In this simple example, I always get an error status at the end of reading. In the context of a more complete code, I always get a Busy status after waiting 15secs.
I really don't see what is going on as my code is largely inspired from the code I found on Github for a I2C sensor.
Maybe I forgot a specific code for I2C init but as I'm not an expert, I prefer to ask to experts :)
Finally found what was wrong. After testing with C using STM HAL and investigating the Ada configuration code, I found that a line was missing:
GPIO_Conf_AF.AF_Speed := Speed_100MHz;
GPIO_Conf_AF.AF_Output_Type := Open_Drain;
GPIO_Conf_AF.Resistors := Pull_Up;
-- Missing configuration part of the record
GPIO_Conf_AF.AF := Selected_I2C_Port_AF;
-- That should be present even though there was a call to configure
-- each pin few lines above
Configure_IO (Selected_I2C_Clock_Pin, GPIO_Conf_AF);
Configure_IO (Selected_I2C_Data_Pin, GPIO_Conf_AF);
Using Configure_IO after Configure_Alternate_Function crushes the configuration and, as there was a part of the record which was left uninitialized, the GPIO were incorrectly configured.
To be more precise, after looking at the code inside the GPIO handling, Configure_IO calls Configure_Alternate_Function using the AF part of the GPIO_Port_Configuration record. In my case, it was resetting it.
With the missing line, the code now runs correctly with Mem_Read and Master_Transmit/Master_Receive.
A big thanks to ralf htp for advising me to dive into the generated C code.
No, between HAL_I2C_Mem_Read and the HAL_I2C_Master_Transmit, wait, HAL_I2C_Master_Receive procedure is only a nuance cf How do I use the STM32CUBEF4 HAL library to read out the sensor data with i2c? . If you know what size of data you want to receive you can use the HAL_I2C_Master_Transmit, wait, HAL_I2C_Master_Receive procedure.
A C++ HAL I2C example is in https://letanphuc.net/2017/05/stm32f0-i2c-tutorial-7/
//Trigger Temperature measurement
buffer[0]=0x00;
HAL_I2C_Master_Transmit(&hi2c1,0x40<<1,buffer,1,100);
HAL_Delay(20);
HAL_I2C_Master_Receive(&hi2c1,0x40<<1,buffer,2,100);
//buffer[0] : MSB data
//buffer[1] : LSB data
rawT = buffer[0]<<8 | buffer[1]; //combine 2 8-bit into 1 16bit
Temperature = ((float)rawT/65536)*165.0 -40.0;
//Trigger Humidity measurement buffer[0]=0x01;
HAL_I2C_Master_Transmit(&hi2c1,0x40<<1,buffer,1,100);
HAL_Delay(20);
HAL_I2C_Master_Receive(&hi2c1,0x40<<1,buffer,2,100);
//buffer[0] : MSB data
//buffer[1] : LSB data
rawH = buffer[0]<<8 | buffer[1]; //combine 2 8-bit into 1 16bit
Humidity = ((float)rawH/65536)*100.0; HAL_Delay(100); }
Note that it uses HAL_I2C_Master_Transmit, waits 20 ms until the slave puts the data on the bus and then receives it with HAL_I2C_Master_Receive. This code is working, i tested it myself.
Possibly the problem is that the BME280 supports single byte reads and multi-byte reads (until it sends a NOACK and stop). HAL_I2C_Mem_Read waits for the ACK or stop but for some reasons it does not get it what causes the Busy and then Timeout behavior, cf page 33 of the datasheet http://www.embeddedadventures.com/datasheets/BME280.pdf for the multibyte read. You specified timeout to 15 sec and you get the timeout after 15 secs. So it appears that the BME280 simply does not stop sending or it sends nothing including not a NOACK and Stop condition ...
HAL_I2C_Mem_Read sometimes causes problems, this depends on the slave https://community.arm.com/developer/ip-products/system/f/embedded-forum/7989/trouble-getting-values-with-i2c-using-hal_library
By the way with the
HAL.I2C.Mem_Read (This => Port.all,
Addr => I2C_Address,
Mem_Addr => 16#D0#,
Mem_Addr_Size => HAL.I2C.Memory_Size_8b,
Data => ID,
Status => Status,
Timeout => 15000);
you try to read 1 byte the chip identification number from register D0 cf http://www.embeddedadventures.com/datasheets/BME280.pdf page 26

Delphi 10 : showing a DLL's form when compiling with runtime packages

Sorry if this question has been asked in the past, but i'm confused!
I have an app and a DLL, both in Delphi. The Dll has a form that i want to show(no modal) inside a Groupbox.
In the main app i have enabled runtime packages.
In the DLL if i disable them, then works ok with the code bellow.
in DLL :
procedure showInfo(app : Thandle; GB : TGroupBox); stdcall;
begin
// application.Handle := app; // are the same
FormSysInfo := TFormSysInfo.CreateParented(GB.handle);
FormSysInfo.show;
end;
procedure destroyInfo; stdcall;
begin
FormSysInfo.destroy;
end;
exports showInfo index 1,
destroyInfo index 2;
in main app :
procedure loadSysInfo;
var showInfo : procedure(app : Thandle; GB : TGroupBox); stdcall;
begin
sysInfo := LoadLibrary('SysInfo.dll');
if sysInfo <> 0 then begin
#showInfo := GetProcAddress(sysInfo, 'showInfo');
#destroyInfo := GetProcAddress(sysInfo, 'destroyInfo');
if #showInfo <> NIL then showInfo(application.handle,mainForm.GroupBox8);
end;
end;
but didn't show if i enable runtime packages for the DLL (I want to reduce the size).
How can i manage this, please ?
thanks in advance

Undefined output of Ring Counter Test waveform

I have modeled 4 bit Ring Counter using D Flip Flop.
The D flip flop is in separate file, included in my workspace. The D flip flop works correctly (gives correct output waveform).
This is the code of ring counter:
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
entity ring4counter is
port (
clk: std_logic;
output: out std_logic_vector(3 downto 0));
end ring4counter;
architecture ring4counter_arch of ring4counter is
component dff
port (
clk: std_logic;
d: in std_logic;
q: out std_logic;
qbar: out std_logic);
end component;
signal temp:std_logic_vector(3 downto 0):=(others=>'0');
begin
r1: dff port map(clk, temp(3), temp(0));
r2: dff port map(clk, temp(0), temp(1));
r3: dff port map(clk, temp(1), temp(2));
r4: dff port map(clk, temp(2), temp(3));
output <= temp;
end ring4counter_arch;
Here is the testbench code for Ring counter:
library ieee;
use ieee.std_logic_1164.all;
entity ring4_tb is end ring4_tb ;
architecture arch of ring4_tb is
component tbc is
port (
clk: std_logic;
output: out std_logic_vector(3 downto 0));
end component ;
component dff
port (
clk: std_logic;
d: in std_logic;
q: out std_logic;
qbar: out std_logic);
end component;
constant period : time := 50 ns ;
signal clk : std_logic := '0' ;
signal done : boolean := false ;
signal output : std_logic_vector(3 downto 0) ;
shared variable cycle : natural := 0 ;
signal temp:std_logic_vector(3 downto 0):=(others=>'0');
begin
-- this is the unit under test
u1: tbc
port map(
clk => clk,
output => output) ;
clkprocess: process(done, clk)
begin
if (not done) then
if (clk = '1') then
cycle := cycle + 1 ;
end if ;
clk <= not clk after period / 2 ;
end if ;
end process ;
r1: dff port map(clk, temp(3), temp(0));
r2: dff port map(clk, temp(0), temp(1));
r3: dff port map(clk, temp(1), temp(2));
r4: dff port map(clk, temp(2), temp(3));
output <= temp;
testbench: process
begin
wait until (clk = '0') ;
temp <= "1000";
wait for period*4 ;
done <= true ; -- force the clock process to shutdown
wait ; -- this waits forever
end process ;
end arch ;
But the waveform for 'output' is 'U' for all bits.
Where am I going wrong?
In the testbench process when you are trying to initialize temp to "1000", the flip flops are still driving the temp signal as well, so you effectively have a bus fight going on.
Use the initialisation of temp in your ring counter to set up the signal.
Note that this may not synthesize correctly depending on your architecture and synthesis tool.
The most general purpose way of doing it is to add a reset signal to all the DFFs except on, and put a preset signal on that one. Then you assert the reset at the start, which will set up the DFFs to a good value.
Here's a simpler version of your code which does that and avoid the need to use explicit DFFs. You can also change the width of temp and the code will do all the rest for you:
process (clk)
begin
if reset = '1' then
temp <= (0=>'1', others => '0'); -- set one bit high, the others low.
elsif rising_edge(clk) then
-- take the high bit and move it to the low bit.
-- Move the other bits left 1 place
temp <= temp(temp'high-1 downto 0) & temp(temp'high);
end if;
end process;
(Note: code just typed into the message, there may be syntactic typos in there!)
BTW, shared variables are a bad idea unless they are of protected types. They can have race conditions.
One thing to do is add a enable signal to D flipflops. when you want to reset the circuit make the enable signal go low and then change the temp to "1000".
r1: dff port map(clk, temp(3), temp(0), enable);
process(clk,reset)
begin
if(rising_edge(clk)) then
if( reset='1') then
enable='0';
temp <= "1000";
else
enable <= '1';
end if;
end if;
end process;

Sockets in Pascal

How do you use network sockets in Pascal?
­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­
Here's an example taken from http://www.bastisoft.de/programmierung/pascal/pasinet.html
program daytime;
{ Simple client program }
uses
sockets, inetaux, myerror;
const
RemotePort : Word = 13;
var
Sock : LongInt;
sAddr : TInetSockAddr;
sin, sout : Text;
Line : String;
begin
if ParamCount = 0 then GenError('Supply IP address as parameter.');
with sAddr do
begin
Family := af_inet;
Port := htons(RemotePort);
Addr := StrToAddr(ParamStr(1));
if Addr = 0 then GenError('Not a valid IP address.');
end;
Sock := Socket(af_inet, sock_stream, 0);
if Sock = -1 then SockError('Socket: ');
if not Connect(Sock, sAddr, sizeof(sAddr)) then SockError('Connect: ');
Sock2Text(Sock, sin, sout);
Reset(sin);
Rewrite(sout);
while not eof(sin) do
begin
Readln(sin, Line);
Writeln(Line);
end;
Close(sin);
Close(sout);
Shutdown(Sock, 2);
end.
If you're using FPC or Lazarus(which is basically a rad IDE for FPC and a clone of delphi) you could use the Synapse socket library. It's amazing.
If you are using Delphi, I highly recommend Indy sockets, a set of classes for easy manipulation of sockets and many other internet protocols (HTTP, FTP, NTP, POP3 etc.)
You cannot use OpenSSL with Indy version 10.5 that shippes with Delphi 2007. You have to download version 10,6 from http://www.indyproject.org/ and install it into the IDE.
Note that other packages might use Indy, like RemObjects, and therefore they have to be re-compiled too and this can be tricky due to cross-references.