How does one describe signal concatenation with logic diagram blocks? - concatenation

I know in HDL one can concatenate with c<={a,b};
but how is it represented in logic gates?
signal concatenation keeps the order of the bits, so if i want to represent 2 one bit signals being concatenated into a one 2 bit signal and run that wire to another module, what is the logic block representation of the concatenation process?
I've already googled this question and searched, have not been able to find what I am looking for
c<={a,b};

You asked for a 'logic diagram' which is just two sets of wires combined into a third set of wires:
As dave_59 pointed out the result is a "unidirectional alias in that you can only read from c." I have tried to capture that feature in the diagram by using arrows on the wires.
Note that the concatenation operation does not add any logic and thus it does not cause any extra delay in the signals.

There is no hardware logic that represents concatenation—it simply creates an alias. (i.e. the MSB of c maps to the MSB of a, and so on).
BTW, using an assignment with a concatenation creates a unidirectional alias in that you can only read from c. SystemVerilog has a few other constructs to make bi-directional aliases, like the let and alias construct.

Related

How to compare POSIX ACLs?

Given two acl_t values, how do I compare them? That is, I need a way to find out if one acl_t has more or less entries than the other, or if the given acl_entry_t contains different set of permissions than the other one.
Linux does have non-standard acl_cmp function. What I need is basically a POSIX-compliant variant of this function.
The only idea I've come up with so far is comparing ACL's textual representations:
strcmp(acl_to_text(acl1), acl_to_text(acl2))
Any more performant solutions?
Since acl_t is an opaque type, the client code can't implement acl_cmp. Moreover, using strcmp(acl_to_text(acl1), acl_to_text(acl2)) also can't be relied on, because ACL's may be equivalent, but sorted in different order.
I came to conclusion that this function along with some others should've ended up in the standard, but unfortunate way of events resulted in its abandoned state.

Tcl String function that does "shimmering" ruined my customized tcl type defined in c

I have defined a customized tcl type using tcl library in c/c++. I basically make the Tcl_Obj.internalRep.otherValuePtr point to my own data structure. The problem happens by calling [string length myVar] or other similar string functions that does so called shimmering behaviour which replace my internalRep with it's own string structure. So that after the string series tcl function, myVar cannot convert back! because it's a complicate data structure cannot be converted back from the Tcl_Obj.bytes representation plus the type is no longer my customized type. How can I avoid that.
The string length command converts the internal representation of the values it is given to the special string type, which records information to allow many string operations to be performed rapidly. Apart from most of the string command's various subcommands, the regexp and regsub commands are the main ones that do this (for their string-to-match-the-RE-against argument). If you have a precious internal representation of your own and do not wish to lose it, you should avoid those commands; there are some operations that avoid the trouble. (Tcl mostly assumes that internal representations are not fragility, and therefore that they can be regenerated on demand. Beware when using fragility!)
The key operations that are mostly safe (as in they generate the bytes/length rep through calling the updateStringProc if needed, but don't clear the internal rep) are:
substitution into a string; the substituted value won't have the internal rep, but it will still be in the original object.
comparison with the eq and ne expression operators. This is particularly relevant for checks to see if the value is the empty string.
Be aware that there are many other operations that spoil the internal representation in other ways, but most don't catch people out so much.
[EDIT — far too long for a comment]: There are a number of relatively well-known extensions that work this way (e.g., TCOM and Tcl/Java both do this). The only thing you can really do is “be careful” as the values really are fragile. For example, put them in an array and then pass the indexes into the array around instead, as those need not be fragile. Or keep things as elements in a list (probably in a global variable) and pass around the list indices; those are just plain old numbers.
The traditional, robust approach is to put a map (e.g., a Tcl_HashTable or std::map) in your C or C++ code and have the indices into that be short strings with not too much meaning (I like to use the name of the type of value followed by either a sequence number or a serialisation of the pointer, such as you might get with the %p conversion in sprintf(); the printed pointer reveals more of the implementation details, is a little more helpful if you're debugging, and generally doesn't actually make that much difference in practice). You then have the removal of things from the map be an explicit deletion operation, and it is also easy to provide operations like listing all the known current values. This is safe, but prone to “leaking” (though it's not formally a memory leak if you provide the listing operation). It can be accelerated by caching the lookup in a Tcl_Obj*'s internal representation (a cheap way to handle deletion is to use a sequence number that you increment when you delete something, and only bypass the map lookup if the sequence number that you cache in the intrep is equal to the main sequence number) but it's not usually a big deal; only go to that sort of thing if you've measured a bottleneck in the lookups.
But I'd probably just live with fragility in my own code, and would just take care to ensure that I never bust the assumptions. The problem is really that you're being incautious about how you use the values; the Tcl code should just pass them around and nothing else really. Also, I've experimented a fair bit with wrapping such things up inside a TclOO object; it's far too heavyweight (by the design of TclOO) for values that you're making a lot of, but if you've only got a few of them and you're wanting to treat them as objects with methods, this can work very well indeed (and gives many more options for automatic cleanup).

constructing a non deterministic turing machine

Draw the diagram of a two tape Non deterministic Turing Machine M that decides the language
L={w∈Σ* | w=uuu ∈Σ* }
if i could get help explaining the steps how to construct the NDTM (linguistically), I believe I could draw the diagram but I couldnt come out with an answer..
thank you
By u*u*u (viewed in the edit history), I presume what you intend is the language of all words of the form u^3 (u repeated three times) where u is any string over the alphabet.
Our NDTM needs to accept strings in the language in at least one way, and it must never accept anything not in the language. In particular, the key is that an NDTM can reject strings in the language, as long as some path through the NDTM does accept every string in the language.
Given that, our first step can be do guess about the length of u. The NDTM can mark three tape symbols (say, by writing versions of the symbols that are underlined) by nondeterministically transitioning from state q0 to q1 then q2 at arbitrary points while scanning right. Then, we can reset the tape head and use a deterministic TM to answer the question: did the split we guessed in the first step result in a string of the form u^3?
This is deterministic since we know the delineation of parts. We can check the first two parts (say, by bouncing back ad forth and marking symbols we've already processed), and then the second two parts (using the same technique, but applied to the 2nd and 3rd parts).
We have reduced the problem to that of checking whether a string is of the form w|w where we know the split. This deterministic TM is easier to come up with. When we put it after the NDTM that guesses about how to split up the initial input, we get a NDTM that can (and for exactly one guess, does) accept any string of the form u^3, but cannot possibly accept anything else. This is what we were after and we are done.

Defining Scalar Sequence of Dynamic Length in MIB

I'm trying to figure out a way to define a dynamic length sequence of scalars (in this case IpAddress) in a MIB file. I'm fairly certain that just using SYNTAX SEQUENCE OF IpAddress will not work, and I'm unsure of how/if to define a custom entry without explicitly labelling all of its fields (and thus, having to know the size in advance). Is there any way to do this and have it work with the net-snmp API? If this question is confusing, I can try to elaborate more. Thanks in advance!
The right thing to do in the SMI structure is to use a table where the index is composed of two different (at least) variables: one of InetAddressType and one of InetAddress. These two Textual Conventions, and the definitions for what the types contain, can be found in the INET-ADDRESS-MIB. You'll find that the first variable will identify the type of IP address and the second will define the value (and is flexible in length so it accommodates IPv4 and IPv6 both, eg).

How to represent functions in flowchart?

I define some function in my Ansi C Program (simple program). I don't known how to represent a function in flowchart. Anybody can help me?
In my opinion, a flowchart is more of a functional description of your algorithm and not where you would "define" a function in the sense of your program. Yes, a functional aspect represented in your flowchart may directly map to a single function in your C program, but it may be that multiple functions or multiple threads are used to accomplish it as well. The flowchart isn't where you would describe these.
In short, the flowchart is not where you should be "defining" functions for your C program. It should be a high-level representation of functional aspects of your program, not the implementation of it.
On a flowchart, a function can be anything: a state, an action that occurs while transitioning betwwen states, etc. It all depends on how you have your flowchart organized. I would recommend building your flowchart normally, then go back and add a function name to the description of anything that is implemented by a function.
There is no direct symbol.. you can create your function with the basic input /output/process symbols
Here is a tutorial on writing C functions using DRAKON charts (DRAKON charts are very similar to flowcharts):
http://drakon-editor.sourceforge.net/cpp/c.html
I had a similar question, Flowcharting a Get-ter, which was answered with:
NOTE: Please don't upvote this answer but instead the original within the above link.
Flowcharts represent flow of control, not flow of information.
Flowcharting formally captures steps and the linkages between them
that describe the transfer of the flow of control that are often based
on decisions: in particular, conditional branches and loops.
Flow of control is about what is done or happens next, and (sadly) not
about the required data to perform that step.
According to Wikipedia, there are some extensions for the flow of
data; however, they are basically limited to documents and files.
Generally speaking, state is poorly represented in flowcharting; there
is virtually no notion of data, variables, scopes, lifetimes, or
types. So, data (and metadata about that data, such as allowed or
expected types) is mostly documented informally with human language
description in the text within individual steps of the flowchart.
Input & Output in flowcharting is meant to indicate communication with
another independent and top-level process (even if it is just a later
running copy of one's self). As such this communication is about
reading/writing to disc or to a network.
A getter does not qualify as input or output, which is to say
communication with another independent process, so I think that is
out. I don't think they even had getter's when flowcharting was first
applied to software design (circa 1950).
You might look in to UML. – Erik Eidt Dec 12 '16 at 16:51

Resources