VHDL code is finally converted into hardware equivalent when it is synthesized. What happens to data operator type "variable" when it is synthesized?
121810
I know two ways in which a VHDL variable is synthesized by synthesis tool:   Variable synthesized as Combinational logic Variable synthesized as a Latch unintentionally (when an uninitialized variable is assigned to a signal or another variable)   What are the other ways in which a VHDL variable can be synthesized ? (Example: can it be interpreted as a FF ? )
83183
This question was inspired by the following reference:    We use the usual notation.  $N = 2^n$ ,  the number of all possible n-bit strings . The oracle  $U_\omega$ can be put in the form    $U_\omega=I - 2  (\vert\omega\rangle\langle\omega \vert )$  $U_\omega$ is a reflection of any vector on the hyperplane orthogonal to $\vert\omega\rangle$  The vector $\vert s \rangle $ and operator $U_s$ are introduced.   $\vert s \rangle = H^{\otimes n} \vert 0 \rangle^{\otimes n}$ , where $H^{\otimes n}$  is the n-qubit Hadamard transform.   Operator $U_s$ reflects any vector with respect to $\vert s \rangle$  $U_s = 2\vert s \rangle \langle s \vert - I$      The Grover iteration is $U_{Grover} = U_s U_\omega$  $U_{Grover}$ rotates (at every iteration) the initial vector $\vert s \rangle$ towards the desired vector $\vert\omega\rangle$ by the angle $2\theta$, where $sin\theta =  \frac{1}{\sqrt{N}}$  We note that a reflection is expressed by a unitary matrix. That means that the operator defined below is represented by a unitary matrix, therefore a quantum circuit can be designed in order to implement this operator (Edit. This statement was proven false by the answer to this question).    We define the operator:  $U(\vert x \rangle , \vert y \rangle  ) = ( \vert x \rangle , U_x \vert y \rangle) $  , where  $U_x \vert y \rangle$ represents the reflection of $\vert y \rangle$  with respect to $\vert x \rangle$  In the following relations the vectors  $\vert \xi_i \rangle$ are implicitly defined based on the action of the operator U.  We consider the following sequence of transformations (based on the definition of the operator  U):  $U(\vert s \rangle ,  U_\omega\vert  s \rangle  ) = (\vert s \rangle ,  U_sU_\omega \vert s \rangle) = (\vert s \rangle , \vert \xi_1 \rangle )$  $U(\vert \xi_1 \rangle ,  U_\omega\vert  s \rangle  ) = (\vert \xi_1 \rangle ,  U_{\xi_1}U_\omega \vert s \rangle) = (\vert \xi_1 \rangle , \vert \xi_2 \rangle )$  $U(\vert \xi_2 \rangle ,  U_\omega\vert  s \rangle  ) = (\vert \xi_2 \rangle ,  U_{\xi_2}U_\omega \vert s \rangle) = (\vert \xi_2 \rangle , \vert \xi_3 \rangle )$  .......................and so on..........................  $U(\vert \xi_{n-1} \rangle ,  U_\omega\vert  s \rangle  ) = (\vert \xi_{n-1} \rangle ,  U_{\xi_{n-1}}U_\omega \vert s \rangle) = (\vert \xi_{n-1} \rangle , \vert \xi_n \rangle )$  In other words, the vector to be reflected is fixed but the reflection axis is variable (in the original Grover algorithm it's the other way around ).  At every step  K of the algorithm above  the initial vector $\vert s \rangle$ is rotated towards the desired vector $\vert\omega\rangle$ by an angle which is at about $2^K\theta$ (as order of magnitude ), where $sin\theta =  \frac{1}{\sqrt{N}}$.  That means that this algorithm will only need about  $log_2 N$ (as order of magnitude ) steps  to reach the target.  Question 1. Can a quantum circuit be designed, that implements this algorithm, in principle ?  Question 2. Does this algorithm present an exponential speedup,  when compared to Grover's algorithm?  Edit. Unfortunately nothing from what  I tried seems to work. You need a quantum circuit that takes as input the vector to be reflected and the vector that represents the reflection axis. The output of the quantum circuit must contain the reflected vector. That does not seem possible,  as far as I understand. This reflection implementation problem,  if ever solved,   would lead to an exponential speedup of Grover's algorithm.
113326
If I write a #define that performs an operation using other preprocessor constants, is the final value computed each time the macro appears at runtime? Does this depend on optimizations in the compiler, or is it covered under a standard?  Example:  #define EXTERNAL_CLOCK_FREQUENCY    32768 #define TIMER_1_S                   EXTERNAL_CLOCK_FREQUENCY #define TIMER_100_MS                TIMERB_1_S / 10   Will the operation 32768 / 10 occur at runtime every time I use the TIMER_100_MS macro?  I would like to avoid the following:  #define EXTERNAL_CLOCK_FREQUENCY    32768 #define TIMER_1_S                   EXTERNAL_CLOCK_FREQUENCY #define TIMER_100_MS                3276     Summary  A compiler is required to be able to evaluate constant integral expressions because they are necessary for calculating things like array sizes at compile time. However, the standard only says they "can" -- not "must" -- do so. Therefore, only a brain-dead compiler would not evaluate a constant integral expressions at compile time, but a simple check of the assembly output for an unconventional compiler would verify each case.
6378
I have a parameterised module in verilog, where the parameters are a clock rate and refresh rate, which is used to calculate how many cycles of inactivity are inserted between instances of a repeating operation.  However, it is very easy to set parameters that cannot be attained (because the operation takes a non-trivial length of time, so the repeat would have to occur before it had completed), and at the moment the design does not give any feedback on this.  I was wondering if there was some way I could trigger an error during synthesis (or compilation prior to simulation) if the conditions cannot be met (i.e. if one localparam is less than another)?  Some equivalent of the popular C/C++ compile-time-assert hack, perhaps.
38840
I have gone through various sources... But I am not quite sure what it is.I want an and gate and the logical equivalent is two inputs feeding to one gate and for Y=AB' the logical equivalent is feeding to one not gate and one and gate. But it is the same LUT for both AND and Y=AB'. I think we store the values as desired in the LUT. Someone elaborate on this
27874
In C++, is there any difference between:  struct Foo { ... };   and:  typedef struct { ... } Foo;
95746
I read somewhere once that the modulus operator is inefficient on small embedded devices like 8 bit micro-controllers that do not have integer division instruction. Perhaps someone can confirm this but I thought the difference is 5-10 time slower than with an integer division operation.  Is there another way to do this other than keeping a counter variable and manually overflowing to 0 at the mod point?  const int FIZZ = 6; for(int x = 0; x &lt; MAXCOUNT; x++) {     if(!(x % FIZZ)) print("Fizz\n"); // slow on some systems }   vs:  The way I am currently doing it:  const int FIZZ = 6; int fizzcount = 1; for(int x = 1; x &lt; MAXCOUNT; x++) {     if(fizzcount &gt;= FIZZ)      {         print("Fizz\n");         fizzcount = 0;     } }
82601
I'm trying to convert an incoming sting of 1s and 0s from stdin into their respective binary values (where a string such as "11110111" would be converted to 0xF7). This seems pretty trivial but I don't want to reinvent the wheel so I'm wondering if there's anything in the C/C++ standard libs that can already perform such an operation?
80591
Although I'm doubtful, I'm curious as to whether it's possible to extract primitive-type template parameters from an existing type, perhaps using RTTI.  For example:  typedef std::bitset&lt;16&gt; WordSet;   Would it be possible to extract the number 16 in the above code without hard-coding it elsewhere? Compiler specific implementations are welcome, though I'm particularly interested in g++.
1679
What does the , operator do in C?
103238
I want to work with unsigned 8-bit variables in C++.  Either unsigned char or uint8_t do the trick as far as the arithmetic is concerned (which is expected, since AFAIK uint8_t is just an alias for unsigned char, or so the debugger presents it.  The problem is that if I print out the variables using ostream in C++ it treats it as char.  If I have:  unsigned char a = 0; unsigned char b = 0xff; cout &lt;&lt; "a is " &lt;&lt; hex &lt;&lt; a &lt;&lt;"; b is " &lt;&lt; hex &lt;&lt; b &lt;&lt; endl;   then the output is:  a is ^@; b is 377   instead of   a is 0; b is ff   I tried using uint8_t, but as I mentioned before, that's typedef'ed to unsigned char, so it does the same.  How can I print my variables correctly?  Edit: I do this in many places throughout my code.  Is there any way I can do this without casting to int each time I want to print?
86999
Admittedly I don't get it. Say you have a memory with a memory word of length of 1 byte. Why can't you access a 4 byte long variable in a single memory access on an unaligned address(i.e. not divisible by 4), as it's the case with aligned addresses?
89053
Looking at some code I'm maintaining in System Verilog I see some signals that are defined like this:  node [range_hi:range_lo]x;   and others that are defined like this:  node y[range_hi:range_lo];   I understand that x is defined as packed, while y is defined as unpacked.  However, I have no idea what that means.  What is the difference between packed and unpacked vectors in System Verilog?  Edit: Responding to @Empi's answer, why should a hardware designer who's writing in SV care about the internal representation of the array?  Are there any times when I shouldn't or can't use packed signals?
21013
Most properties of a single binary operation can be easily read of from the operation's table. For example, given $$\begin{array}{c|ccccc} \cdot &amp; a &amp; b &amp; c &amp; d &amp; e\\\hline a     &amp; e &amp; d &amp; b &amp; a &amp; c\\ b     &amp; d &amp; c &amp; e &amp; b &amp; a\\ c     &amp; b &amp; e &amp; a &amp; c &amp; d\\ d     &amp; a &amp; b &amp; c &amp; d &amp; e\\ e     &amp; c &amp; a &amp; d &amp; e &amp; b \end{array}$$ it is easy to check that it is closed (no elements occur in the table which don't occur as row or column index), commutative (the table is symmetric), has a neutral element (the row and column of $d$ are copies of the index row/column), and has an inverse element for each element (there's a $d$ in each row and column). In other words, almost all important properties can immediately be seen. The only part missing is associativity.  Therefore my question: Is there a simple way to see directly from the operation's table (i.e. without doing explicitly all the calculations) if an operation is associative?
29613
What does a JIT compiler specifically do as opposed to a non-JIT compiler? Can someone give a succinct and easy to understand description?
19865
Can someone explain what this means?  int (*data[2])[2];
62334
I have an array of values that is passed to my function from a different part of the program that I need to store for later processing.  Since I don't know how many times my function will be called before it is time to process the data, I need a dynamic storage structure, so I chose a std::vector.  I don't want to have to do the standard loop to push_back all the values individually, it would be nice if I could just copy it all using something similar to memcpy.