I have a monitor unit with the following fields/events:
uart_env.e:
unit uart_monitor_u like uvm_monitor{
smp : uart_signal_map_u; //ptr to smp
keep smp == get_enclosing_unit(uart_env_u).smp;
kind : uart_monitor_u_kind_t;
};
uart_monitor.e:
extend uart_monitor_u{
!port_data_b : inout simple_port of bit; -- pointer to the data-bit port
event clk_e is rise (smp.port_uart_clk$) #sim;
event data_deassert is fall (port_data_b$) #uart_clk_e;
.......
.......
};
uart_rx_monitor.e:
extend RX uart_monitor_u{
keep soft port_data_b == smp.port_rxdi;
.....
.....
};
uart_types.e:
type uart_monitor_u_kind_t: [ RX, TX ];
uart_signal_map.e:
extend uart_signal_map_u {
p_def port_uart_clk bit;
p_def port_uart_clk_period real;
p_def port_resetn bit;
p_def port_br_clk_period real;
p_def port_uart_int bit;
p_def port_txdo bit;
p_def port_rxdi bit;
......
......
};
The order of the compilation of the relevant file:
import uart_types;
import uart_env;
import uart_monitor;
import uart_rx_monitor;
For some reason I got the following error when I try to compile:
*** Error: Cannot access null port expression.
at line 22 in #uart_monitor
event data_deassert is fall (port_data_b$) #uart_clk_e;
the port_data_b pointer is marked as do-not-generate. so it remains NULL.
try removing the "!" from it
Related
I am trying to make a simple parser for an https website push, so trying to follow from the example from http://rosettacode.org/wiki/HTTP#Ada, just changing the address from a website.
So I tried
with Ada.Text_IO; use Ada.Text_IO;
with AWS.Client;
with AWS.Response;
procedure Main_Other is
begin
Put_Line (AWS.Response.Message_Body
(AWS.Client.Get
(URL => "https://google.com")));
end Main_Other;
But I got an exception
raised PROGRAM_ERROR : aws-client.adb:398 finalize/adjust raised exception
[2020-04-02 10:41:20] process exited with status 1, elapsed time: 00.80s
So, any thoughts on how to fix that?
I'd like to parse the current status of some tables in a website, similar of making something like that in Python
import pandas as pd
def retrieve_json(json_url):
return pd.read_json(json_url)
I'd like to code this solution the simplest way possible, even better not relying on AWS.
Please, and thanks.
It seems that you're using a build of AWS with SSL support disabled (SSL support is optional). Replacing https with http should do the trick. If an unsecured connection is not an option, either recompile AWS with SSL support enabled (see here and here) or, if you're in a hurry and happen to develop on Linux, fall back on GNAT.Expect and wget (tested with GNAT CE 2019):
main.adb
with Ada.Text_IO; use Ada.Text_IO;
with GNAT.Expect; use GNAT.Expect;
with GNATCOLL.JSON; use GNATCOLL.JSON;
procedure Main is
-------------------
-- Download_JSON --
-------------------
function Download_JSON (URL : String) return JSON_Value is
Cmd : constant String := "wget";
Arg_1 : aliased String := "-q"; -- Turn off Wget's own messages.
Arg_2 : aliased String := "-O"; -- Output response to ...
Arg_3 : aliased String := "-"; -- ... standard output.
Arg_4 : aliased String := URL;
Status : aliased Integer;
Response : String :=
Get_Command_Output
(Command => Cmd,
Arguments => (1 => Arg_1'Unchecked_Access,
2 => Arg_2'Unchecked_Access,
3 => Arg_3'Unchecked_Access,
4 => Arg_4'Unchecked_Access),
Input => "",
Status => Status'Unchecked_Access);
begin
-- Omitting check of 'Status' for brevity.
return Read (Response);
end;
Root : JSON_Value;
begin
Root := Download_JSON
("https://raw.githubusercontent.com/AdaCore/gnatcoll-core/" &
"master/testsuite/tests/json/validation/basic_object.json");
Put_Line (Write (Root));
end Main;
default.gpr
with "gnatcoll.gpr";
project Default is
for Source_Dirs use ("src");
for Object_Dir use "obj";
for Main use ("main.adb");
end Default;
output
$ ./main
{"a":1,"b":"a tringg","c":[1,2,3],"d":{"a":"a"},"e":null}
I'm trying to install pycuda on Linux Mint with a GeForce 960M and Cuda 8.0 installed. When I run the test_driver.py script it outputs the following error:
============================= test session starts ==============================
platform linux2 -- Python 2.7.12, pytest-3.0.3, py-1.4.31, pluggy-0.4.0
rootdir: /home/milton/Downloads/pycuda-2016.1.2, inifile:
collected 28 items
test_driver.py ...................x.....F..
=================================== FAILURES ===================================
________________________ TestDriver.test_multi_context _________________________
args = (,), kwargs = {}
pycuda = <module 'pycuda' from '/home/milton/miniconda2/lib/python2.7/site-packages/pycuda-2016.1.2-py2.7-linux-x86_64.egg/pycuda/init.pyc'>
ctx = <pycuda._driver.Context object at 0x7f540e39d758>
clear_context_caches = <function clear_context_caches at 0x7f540ee26758>
collect =<built-in function collect>
def f(*args, **kwargs):
import pycuda.driver
# appears to be idempotent, i.e. no harm in calling it more than once
pycuda.driver.init()
ctx = make_default_context()
try:
assert isinstance(ctx.get_device().name(), str)
assert isinstance(ctx.get_device().compute_capability(), tuple)
assert isinstance(ctx.get_device().get_attributes(), dict)
inner_f(*args, **kwargs)
../../../miniconda2/lib/python2.7/site-packages/pycuda-2016.1.2-py2.7-linux-x86_64.egg/pycuda/tools.py:460:
self = <test_driver.TestDriver instance at 0x7f540c21fc20>
#mark_cuda_test
def test_multi_context(self):
if drv.get_version() < (2,0,0):
return
if drv.get_version() >= (2,2,0):
if drv.Context.get_device().compute_mode == drv.compute_mode.EXCLUSIVE:
E AttributeError: type object 'compute_mode' has no attribute 'EXCLUSIVE'
test_driver.py:638: AttributeError
================ 1 failed, 26 passed, 1 xfailed in 6.92 seconds ================
python driver compute mode only supports following modes:
DEFAULT,
PROHIBITED,
EXCLUSIVE_PROCESS
so please change this:
if drv.Context.get_device().compute_mode == drv.compute_mode.EXCLUSIVE:
to
if drv.Context.get_device().compute_mode == drv.compute_mode.EXCLUSIVE_PROCESS:
in your test_driver.py file
while i am trying to assign port and host to delphi client socket, an exception is raised "Can't change value while socket is active". But i haven't changed the socket.active := true. Can anybody suggest possible cause of this error.
procedure CreateSocket(add : pchar);
var
port : integer;
address : string;
host : string;
socket1 : TClientSocket;
begin
setstring(address,add,50);
//showmessage(address) ;
host := split(address,':');
address := del(address,':');
//showmessage(address);
port := strtoint(address);
socket1.port := port; //exception comes here
socket1.host := host;
showmessage('address assigned');
connectionAttempt(Socket1);
CheckDataArrival(socket1);
end;
If this is your actual copy/pasted code, then you have declared a TClientSocket variable but are not instantiating a TClientSocket object, so you are setting the host and port on invalid memory.
I'm trying to get a little script to recognize the SNMP data from a query to store it in a database. But I'm stuck when processing the data with the Net::IP CPAN module. If I define the network string there is no problem, but I have IP and mask in separate strings, and no matter how I join them, the module always set the netmask to /32.
I tried it like this:
my $net = "${$query_snmp->{$tablekey}}{'ipRouteMask'}/${$query_snmp->{$tablekey}}{'ipRouteDest'}";
my $IP = new Net::IP ($net) or die (Net::IP::Error());
But all the IP objects are always created with /32 no matter what I set the netmask to. If i define a string like 192.168.0.0/20 or anything on the same string I find no problem.
What am I missing?
Network -> 192.168.65.64/255.255.255.248
IP : 192.168.65.64
LASTIP : 192.168.65.64
Sho : 192.168.65.64
Bin : 11000000101010000100000101000000
Int : 3232252224
*** Mask: 255.255.255.255 *** wtf ??
Last: 192.168.65.64
Len : 32
Size: 1
Type: PRIVATE
Rev: 64.65.168.192.in-addr.arpa.
From the manual: A Net::IP object can be created from a single IP address, or from a Classless Prefix, ...
I think you've chosen to specify a classless network, provided that you insert a valid network specifier, it works for me.
#!/usr/bin/perl -w
use Net::IP;
my $ip = new Net::IP('112.198.64.0/18') or die (Net::IP::Error());
print ("IP : ".$ip->ip()."\n");
print ("Sho : ".$ip->short()."\n");
print ("Bin : ".$ip->binip()."\n");
print ("Int : ".$ip->intip()."\n");
print ("Mask: ".$ip->mask()."\n");
print ("Last: ".$ip->last_ip()."\n");
print ("Len : ".$ip->prefixlen()."\n");
print ("Size: ".$ip->size()."\n");
print ("Type: ".$ip->iptype()."\n");
print ("Rev: ".$ip->reverse_ip()."\n");
will output:
IP : 112.198.64.0
Sho : 112.198.64
Bin : 01110000110001100100000000000000
Int : 1892040704
Mask: 255.255.192.0
Last: 112.198.127.255
Len : 18
Size: 16384
Type: PUBLIC
Rev: 64.198.112.in-addr.arpa.
However, if you've entered "192.168.65.64/255.255.255.248", this is not a format accepted by Net::IP, you've to use instead "192.68.65.64/29", see this table. In this case it will work correctly:
IP : 192.168.65.64
Sho : 192.168.65.64
Bin : 11000000101010000100000101000000
Int : 3232252224
Mask: 255.255.255.248
Last: 192.168.65.71
Len : 29
Size: 8
Type: PRIVATE
Rev: 64.65.168.192.in-addr.arpa.
When you use the format with the full netmask, since it's not recognized, it gets just the IP and will give you the netmask of 255.255.255.255
thank you ! I finally used a simillar module, that doest requier to transform the ip mask to dec notation.
Net::Netmask -> https://metacpan.org/pod/Net::Netmask
CONSTRUCTING
Net::Netmask objects are created with an IP address and optionally a mask. There are many forms that are recognized:
'216.240.32.0/24' The preferred form.
'216.240.32.0:255.255.255.0'
'216.240.32.0-255.255.255.0'
'216.240.32.0', '255.255.255.0'
'216.240.32.0', '0xffffff00'
'216.240.32.0 - 216.240.32.255'
'216.240.32.4'
A /32 block.
'216.240.32'
Always a /24 block.
'216.240'
Always a /16 block.
'140'
Always a /8 block.
'216.240.32/24'
'216.240/16'
'default' or 'any'
0.0.0.0/0 (the default route)
'216.240.32.0#0.0.31.255'
Thank you.
Similar to this post
http://feedproxy.google.com/~r/cadence/community/blogs/fv/~3/IvdCIla8_Es/extending-multiple-when-subtypes-simultaneously.aspx
I want to make a macro that does loop unrolling to get around some of the when-subtyping and inheritance issues Specman has.
I've started with:
-- macros.e
<'
define <FOREACH_UNROLL'action> "FOREACH_UNROLL (<UNROLLEES>\[<unrollee'name>,...\]) (<STATEMENTS>{<statement>;...})" as computed {
print <UNROLLEES>;
print str_split(<UNROLLEES>,"/ *, */");
for each in str_split(<UNROLLEES>,"/ *, */") {
out(it.as_a(string));
var statements := str_replace( <STATEMENTS>,"\"REPLACE_ME\"",it);
result =appendf("%s %s;",result,statements);
};
};
'>
-- main.e
<'
import macros.e
extend sys {
run() is also {
FOREACH_UNROLL [baz,foo,bar] {
out("REPLACE_ME");
out("part2","REPLACE_ME");
};
};
};
'>
When I run this, I get:
specman -c 'load $HOME/main; test'
Welcome to Specman Elite(64) (08.20.007-s) - Linked on Tue Dec 15 17:07:26
2009
Protected by U.S. Patents 6,141,630 ;6,182,258; 6,219,809; 6,347,388;
6,487,704; 6,499,132; 6,502,232; 6,519,727; 6,530,054; 6,675,138; 6,684,359;
6,687,662; 6,907,599; 6,918,076; 6,920,583; Other Patents Pending.
0 notifications were modified by command 'set notify -severity=WARNING
DEPR_START_TCM_ARG_BY_REF'
Checking license ... OK
Loading macros.e (imported by main.e) ...
read...parse...update...patch...h code...code...clean...
Loading /nfs/pdx/home/rbroger1/main.e ...
read...parse... <UNROLLEES> = "[35]"
str_split(<UNROLLEES>,"/ *, */") =
0. "[35]"
[35]
update...patch...h code...code...clean...
Doing setup ...
Generating the test using seed 1...
Starting the test ...
Running the test ...
REPLACE_ME
part2REPLACE_ME
No actual running requested.
Checking the test ...
Checking is complete - 0 DUT errors, 0 DUT warnings.
If you look at the printout of <UNROLLEES>:
<UNROLLEES> = "[35]"
Why does <UNROLLEES> give me [35] instead of the body inside the curly braces? 35 is the ascii value for #, so I'm at a loss why I would get a 35...
P.S. I realize macros are from the devil, but I think code copying is worse. I have to do this because Specman isn't really polymorphic.
It turns out I needed to use the function str_expand_dots in my version of Specman (8.2).
Here is the modified macros.e:
define <FOREACH_UNROLL'action> "FOREACH_UNROLL (<UNROLLEES>\[<unrollee'name>,...\]) (<STATEMENTS>{<statement>;...})" as computed {
-- print str_expand_dots(<UNROLLEES>);
--print str_expand_dots(<STATEMENTS>);
-- print str_split(str_expand_dots(<UNROLLEES>),"/ *, */");
for each in str_split(str_expand_dots(<UNROLLEES>),"/ *, */") {
var unrollee := str_replace(it, "[","");
unrollee = str_replace(unrollee, "]","");
--out(unrollee);
var statements := str_replace( str_expand_dots(<STATEMENTS>),"\"REPLACE_ME\"",unrollee);
result =appendf("%s %s;",result,statements);
};
};
Modified main.e:
import macros;
extend sys {
run() is also {
FOREACH_UNROLL ["baz","foo","bar"] {
out("REPLACE_ME");
out("part2","REPLACE_ME");
if "REPLACE_ME" == "baz" {
out("found baz");
};
};
};
};
And the output:
Welcome to Specman Elite(64) (08.20.007-s) - Linked on Tue Dec 15 17:07:26
2009
Protected by U.S. Patents 6,141,630 ;6,182,258; 6,219,809; 6,347,388;
6,487,704; 6,499,132; 6,502,232; 6,519,727; 6,530,054; 6,675,138; 6,684,359;
6,687,662; 6,907,599; 6,918,076; 6,920,583; Other Patents Pending.
0 notifications were modified by command 'set notify -severity=WARNING
DEPR_START_TCM_ARG_BY_REF'
Checking license ... OK
Loading /nfs/pdx/home/rbroger1/macros.e (imported by main.e) ...
read...parse...update...patch...h code...code...clean...
Loading /nfs/pdx/home/rbroger1/main.e ...
read...parse...update...patch...h code...code...clean...
Doing setup ...
Generating the test using seed 1...
Starting the test ...
Running the test ...
baz
part2baz
found baz
foo
part2foo
bar
part2bar
No actual running requested.
Checking the test ...
Checking is complete - 0 DUT errors, 0 DUT warnings.