Xilinx Error: Place 1018 message - xilinx

I am using a Basys2 board to program a simple string detector to read patterns like "0101". I am using the Xilinix Design Suite 13.2 for this project. The .ucf file gives the following message.
ERROR:Place:1018 - A clock IOB / clock component pair have been found that are not
placed at an optimal clock IOB clock site pair.
The clock component <reset_IBUF_BUFG> is placed at site <BUFGMUX_X1Y1>.
The IO component <reset> is placed at site <IPAD73>.
Here's what my user constrains file looks like:
NET "x" LOC = "P11";# input switch
NET "reset" LOC = "K3"; # reset switch
NET "ck" LOC = "B8"; # clock
NET "b1" LOC = "A7"; # button 1
NET "b2" LOC = "M4"; # button 2
NET "z" LOC = "M5"; # output
One of the solutions I found online was to use this in the ucf:
CLOCK_DEDICATED_ROUTE = FALSE;
But unfortunately this didn't work for me. I'd appreciate any help with this problem.

The message appears to imply that your reset is being detected as a clock signal. That should be worrying - do you have processes which are sensitive to the edge of the reset signal?
You should (until you really know what you're doing) only use a couple of forms of process.
Asynchronous reset
process (clk, reset)
begin
if reset = '1' then
-- async reset stuff
elsif rising_edge(clk) then
-- sync stuff
end if;
end process;
Synchronous reset
process (clk)
begin
if reset = '1' then
--sync reset stuff
else
-- other sync stuff
end if;
end process;
Also, be careful - you still need to release the reset signal to these processes synchronously.
Here's a good read on various reset strategies:
http://www.xilinx.com/support/documentation/white_papers/wp272.pdf
Finally, using CLOCK_DEDICATED_ROUTE = FALSE; is another no-no for almost every situation.

In my case, I got that inscrutable error message because I mistyped:
always #(clk) begin
if (rst) begin
...
instead of
always #(posedge clk) begin
if (rst) begin
...
Apparently since it wasn't using the edge of clk, rst was now being treated like a clock and messing up routing.
I know this is an old question but I just hit this problem using ISE and Spartan 6; hopefully this answer will help someone (most likely me 6 months from now).

Related

SystemVerilog: String to Circuit Net

Assuming that I set one environment variable before launching a logic simulation of my circuit wrapped in a testbench written in SystemVerilog, I want to check whether it is possible to read the variable and try to map it to a net of the circuit.
For instance:
#### from the bash script that invokes the logic simulator ####
export NET_A=tb_top.module_a.submodule_b.n1
//// inside the tb_top in system verilog ////
import "DPI-C" function string getenv(input string env_name);
always_ff #(posedge clk, nenedge rst_n) begin
if (getenv("NET_A") == 1'b1) begin
$display("Hello! %s has the value 1", getenv("NET_A"));
end
end
In the example above I simply want to check whether the current net i.e., NET_Ais assigned at a certain point in the simulation the logic value of 1.
Thanks in advance
SystemVerilog has a C-based API (Verilog Procedural Interface VPI) that gives you access to a simulator's database. There are routines like vpi_get_handle_by_name which gives you a handle to an signal looked up by a string name. And then you can use vpi_get_value the gives you the current value of that signal.
Use of the VPI needs quite a bit of additional knowledge and many simulators give you built-in routines to handle this common application without having to break into C code. In Modelsim/Questa, it is called Signal_Spy.
But regardless of whether you use the VPI or tool specific routines, looking up a signal by string name has severe performance implications because it prevents many optimizations. Unless a signal represents a storage element, it usually does not keep its value around for queries.
It would be much better to use the signal path name directly
vlog ... +define+NET_A=tb_top.module_a.submodule_b.n1
Then in your code
if (`NET_A == 1'b1) begin

Redis - monitoring maximum memory before inserts fail?

While this Q/A does not address the actual issue of: How to detect with client (eg redis-py) that redis is running out of memory constraint not by machine but by the maxmem configuration? Before inserts fail which command to use in the programm to detect about to be full?
My first guess is: info and check if used_memory_peak < maxmem setting. Is this correct?
(Besides, for out of machine memory, since defrag, use which setting, none of the returned INFO fields help here)
Well should i just try an insert and see if fail (but that would be after the fact then.)
Trail and error, good enough tested by running
while true; do redis-cli lpush mm longstringhere; done; results on maxmem - used_memory < 0.1MB with insert failures:
(error) OOM command not allowed when used memory > 'maxmemory'.
So i have set i poll it via redis-py client and once the diff goes <1mb threshold throw up, sry raise Error of course. Make sure the user_memory memory addon of your longest command is < threshold too of course otherwise you run into it on insert.
I try to figure how to calc the ~percentage of used mem so i get notification way earlier eg 90% of maxmem, therefore this solution is fine.
Info dump:
# Memory
used_memory:3126272
used_memory_human:2.98M
used_memory_rss:5292032
used_memory_rss_human:5.05M
used_memory_peak:4914296
used_memory_peak_human:4.69M
used_memory_peak_perc:63.62%
used_memory_overhead:696654...
Furthermore maxmem is not a hardcap, when running it further by eg adding members to existing set.
used_memory:3162584
used_memory_human:3.02M
code to get percent 0-100
rmem_info = pipe.info(section='memory')
{'redis_mem_percent': math.ceil(rmem_info['used_memory'] / rmem_info['maxmemory'] *100)}

Don't starve Lua: Can't figure out how to spawn additional bamboo with each bamboo tree, or other machete resources

I'm building, or trying to build, a mod called More Drops (DS). I ported it to Don't Starve from "Don't Starve Together", so my lua knowledge is very limited, but I've been working on this thing for days and can't figure it out, so I need to ask for help.
I figured out how to expand on the original mod authors work by adding new trees and resources, but when it comes to "hackable" resources, I'm stumped.
So this is what I was trying, and tons of variations on this. This doesn't work and I don't understand why, and I'll show you what does work in the next two.
--bamboo
if inst.name == "Bamboo Patch" and utils.LootRandom(bambooChance) then
utils.DoTimes(GetModConfigData("bambooAmount", KnownModIndex:GetModActualName("(JEM) More Drops DS")), inst.components.lootdropper.SpawnLootPrefab, inst.components.lootdropper, "bamboo")
end
This does work
--Spawn extra logs for tall trees
if inst.components.growable.stage == 3 and utils.LootRandom(logChance) then
utils.DoTimes(GetModConfigData("extralogstall", KnownModIndex:GetModActualName("(JEM) More Drops DS")), inst.components.lootdropper.SpawnLootPrefab, inst.components.lootdropper, "log")
end
And this works as well
if inst.name == "Evergreen" and inst.components.growable.stage ~= 1 then
if utils.DropLootRandom(inst, "pinecone", seed_chance) then print("Dropped seed") end
end
Now I'm not sure how much of the files I should paste here, but here's the start of the trees.lua just to add a bit more context
local utils = require("utils")
local logChance = GetModConfigData("logChance", KnownModIndex:GetModActualName("(JEM) More Drops DS"))
local function ImproveTree(inst)
--Do these when the tree is fully chopped
local seed_chance = GetModConfigData("treeseedchance", KnownModIndex:GetModActualName("(JEM) More Drops DS"))
local egg_chance = GetModConfigData("eggChance", KnownModIndex:GetModActualName("(JEM) More Drops DS"))
local coconut_seed_chance = GetModConfigData("coconutChance", KnownModIndex:GetModActualName("(JEM) More Drops DS"))
local bambooChance = GetModConfigData("bambooChance", KnownModIndex:GetModActualName("(JEM) More Drops DS"))
local oldonfinish = inst.components.workable.onfinish
inst.components.workable:SetOnFinishCallback(function(inst, chopper)
All of the info is called in modmain.lua correctly as far as I can tell, I made sure to add things in the same way as the working code.
I expected this to drop some extra bamboo! I've tried so many different ways, even made my own choppable.lua file and added it the same way the original author added pickable.lua, but I figured it's gotta be a bit more like trees than regular resources, since you use a tool and it drops the item on the ground rather than adding to invetory.
If you want to see the whole mod, I've uploaded it here: https://www.dropbox.com/s/ahss2d0s861j2an/%28JEM%29%20More%20Drops%20DS.7z?dl=0

mql4: Get data from site

How I can get "Maintenance" value from site
using a MQL4 script ?
As I understand, I must set an internet connection, get data from site, parse it and get data.
Is there a way how I can do it?
I'll be grateful for any example.
Fact #1: MQL4 syntax restricts calling external sub-process:
This means ( if not using a DLL-workaround ) the whole task would require to re-invent a wheel and build the HTML-parser inside MQL4. Doable but a waste of anyone's resources.
Fact #2: There are better ways to choose from:
Once going to use a DLL-imported functionalities, one may either just bypass the MQL4 code-execution restrictions and call Windows-API services to fork sub-process and make things move forwards, however Windows-API, in my opinion, is rather a feature rich interfacing framework, but for a pretty low-level access to elementary services, so you finally can find yourself re-inventing wheel again, well, now "outside" from the MQL4 sandbox restrictions.
If you do not restrict our imagination, your project may benefit from rapid-prototyping in Python and setup a peer-to-peer distributed messaging/control in a heterogeneous Python / MQL4 environment.
Besides other benefits, Python strengths in smart and powerful ( not only ) web-content processing is fabulous, so this distributed approach will open your MQL4 projects into strategically new, unseen dimensions.
Python smart-scraping ( not a dumb-force one ):
def askAtPublisherWebURL( aControlDICT,
aURL = "https://globalde?.?.?.?y?.com/en/products/.../...-DLON?Class_type=class_symbol=???&Class_exchange=???&ps=999&md=03-2014",
anOPT = "ESX",
aMaturityDATE = "03-2014",
anEmailRECIPIENT = "Me.Robot-GWY-2013-PoC#gmail.com",
aFileNAME = "ESX_2014-03_anObservedStateTIMESTAMP[]"
):
import time, urllib, re, winsound, urllib2 # late, dirty import
try:
aReturnFLAG = True
anOutputSTRING = "|TRYING: " + aURL # a crash-proof proxy-value for a case IOError <EXC> would appear
# --------------------------------------------------------# urllib2 MODE
anInputHANDLER = urllib2.urlopen( aURL, None, 120 ) # urllib2 MODE with a 120 [sec] timeout before urllib2.URLError ... still gets stuck during peak-hours ( on aMaturityDATE )
aListOfLINEs = anInputHANDLER.readlines()
anInputHANDLER.close()
# --------------------------------------------------------# urllib2 MODE
except urllib2.URLError as anExcREASON:
aReturnFLAG = False
# no RET here // JMP .FINALLY: to log IOError....
except exceptions.IOError as ( ErrNO, ErrSTR ): # an IOError <EXC> hase appeared, handle with care before JMP .FINALLY:
aReturnFLAG = False
else: # no IOError or any other <EXC>, process the <content> .. JMP .FINALLY:
# ------------------------------------------------------# HTML-processor
# smart html-processing goes here
# ...
# ------------------------------------------------------# HTML-processor
finally: # in any case do all this TIDY-UP-BEFORE-EXIT
# fileIO + pre-exit ops
# sendMsg4MQL() --> SIG MT4
return aReturnFLAG # MISRA-motivated single point of RET
For hawkish Pythoneers, the post intentionally uses non-PEP-8 source code formatting as it is authors experience that during a learning phase, code read-ability improves the focus on task solution and helps getting used to the underlying concepts rather than to spend efforts on formally adhering typography. Hope the principle of providing help is respected and the non-PEP-8 styling format is forgiven in the name of the ease of reading.

Reading from serial port iis erratic without user input

Using Delphi 7 I am reading from a serial port.
The read is always preceded by a write which triggers the h/w to measure from a sensor and write something for me to read (and there is always something to read).
I have two possibilities: manually enter a command and click a button to write that to the serial port (read model or f/w version, etc) or click a button to loop reading measurements until a stop button is pressed. These both use the same internal functions, so the code looks something like this:
WriteSerial('?model');
SerialData := ReadSerial(); // returns string
WriteSerial('?fw');
SerialData := ReadSerial();
and
while stopButtonNotPressed do
begin
WriteSerial('?data');
SerialData := ReadSerial();
Memo1.Lines.Add(SerialData );
end;
The first variant (manually entering a command & pressing a button) is always successful, no matter how quickly or slowly I enter commands (hold down button for repeat), where are the second goes
pass
fail
pass
pass
fail
pass
pass
fail
... add infinitum
adding calls to sleep produces nothing, but trying to debug, I found that if I add a modal dialog box MsgDialog, 'Please close this dialog...', mtInfo, [mrOK]); to the loop, then it no longer fails.
Now, it doesn't look like timing (else surely adding Sleep(2000); to the loop would make it pass & does not, so why does pressing a button on the main form or the modal dialog cause it to succeed?
Btw, the h/w user guide says nothing of CTS / RTS, and the sole code example provide also does not.
Note: if I manually enter ?data repeatedly it never fails ...
Any ideas?
Your serial devices need time to react, so obviously you need a break for the device to catch up. When you use the keyboard to push the button you're providing the brake it needs because the keyboard repeat isn't all that fast.
As you say Sleep(2000) should provide plenty of "break", but there are two other potential problems you'll need to take care of:
Serial communication isn't necessary buffered: Sleep(2000) might be too long!
The serial library you're using might be using windows messages to process incoming bytes. Sleep() inhibits the message pump, so no more messages flow towords your application
Try "sleeping" using something like this:
procedure BusyWait(ms: Cardinal);
var StopAt: TDateTime;
begin
StopAt := Now + EncodeTime(0, 0, ms div 1000, ms mod 1000);
while StopAt > Now do
begin
Application.ProcessMessages;
Sleep(50); // per MichaƂ Niklas's suggestion, to keep the CPU from reaching 100%
end;
end;
This routine will wait, but it'll keep the message pump going, allowing your serial library to receive messages. If that's the problem...
Maybe adding Application.ProcessMessages() before Sleep() will help.

Resources