Making a small VHDL script that outputs a 1(5v) for 2 seconds when a 1 is inputted, but then goes back to a zero - vhdl

I'm trying to make a program to power a dc motor for 2 seconds when a 1 is inputted. I already have a circuit designed with an LED and a capacitor for the motors protection, but i can't figure out a way to make this VHDL script.
if i try to use a "wait" statement or something, it conflicts with my "if" statements. This is for a cyclone IV FPGA

The "wait" statement is not synthesizable.
This means, you will not be able to run it on any board. It is more like a "helping" tool for modelling - e.g. when you need to model the real time delays of flipflops or make a testbench.
The easiest way to create a time delay on your board is to create a counter, that counts up to a given value and changes signal/output when value reached.

Related

Can I 'poison' a value in VHDL

I'd like to be able to poison a signal in VHDL so that any subsequent consumers of it get a poisoned value too so I can find unintended links. Its fine if poisoning works in simulation only.
Background: I've made a CPU in VHDL and want to pipeline it. Before I do that I want to make sure that no part of the pipeline is sampling outputs from other parts when it shouldn't. So all the parts in the pipeline create and hold their valid output for exactly one clock cycle and set the various outputs to zero at other times. And for those times where the output is zero the next stage in the pipeline shouldn't even be looking at those values. But I want to confirm it under simlation.
So I tried setting the outputs to 'U' or 'X' during the times they dont represent data and these show up in the simulator as orange or red, but if I force them to be erroneously sampled the bad values dont propagate. So it seems like neither U nor X are what I want. Without changing the consumers of these (e.g. calling is_x(..) in hundreds of places) is there any easy way to poison those values when running under the simulator.
If it matters, this is on a Spartan7 based Arty board with the free version of Vivado.

I need to know how to make a proper 4 bit binary counter

I tried making a 4 bit binary counter from the following picture:
As the result of making that circuit in a game with no flip-flops or anything with are intended with blocks I was confused on the following:
where is the output?
does the clock speed matter?
why doesn't it work?
is this even right?

Does time delay in a sequential logic circuit block have a influence on synthesize or place or route's result?

I use Xilinx ISE as a IDE.
If I add a 100 ps delay at every assignment in a always(Verilog)/process(VHDL) with sensitive list only have clock and reset.
Like this.
always#(posedge clk)
if(rst)
a <= #100 'd0;
else
a <= #100 b;
end
I think the delay function is only effect the simulation process.Because every book and user guide tell us delay is not synthesizable.
But I still wondering if the delay function can really effect the place or route's result?Like static timing or clock report?
Like can make a circuit max frequency higher or slower?
No the #delay in your code is not going to affect the timing of the design when it is loaded on to the FPGA.
It also does not affect the place and route results or the static timing analysis. Both of these steps use timing information that is provided by the manufacturer in the form of device models.
You are correct that there's nothing intrinsic about delay statements that makes them unsynthesizable, however it's wildly impractical to attempt to do so. The reason for this is that once on the FPGA you are dealing with a physical circuit whose performance varies with PVT (process, voltage, temperature) and can do so by a lot! The only hedge against this would be an analog circuit that attempts to sense all of the above and adjust itself accordingly. Such a beast will still be limited in what it can do, and would be physically large and power hungry depending on the rage of delay and the variance in all of the above you want to support.
So with than in mind and considering that there is very little (read: no) demand for this outside of special purpose IO FPGA vendors don't provide any such components making the construct unsythesizable.
Delay statements (#100) are usually ignored during synthesis in Verilog. So in synthesis it is the same as:
always#(posedge clk)
if(rst)
a <= 0;
else
a <= b;
end
Xlinx Synthesis and Simuation Design Guide states:
Delays in Synthesis Code
Do not use Wait for XX ns (VHDL) or the #XX (Verilog) statements in
your code. (...) This statement does not synthesize to a component.
In designs that include this construct, the functionality of the
simulated design does not always match the functionality of the
synthesized design.
(...)
Wait for XX ns Statement Verilog Coding Example
#XX;
Do not use the After XX ns statement in your VHDL code or the Delay
assignment in your Verilog code
(...)
Delay Assignment Verilog Coding Example
assign #XX Q=0;
XX specifies the number of nanoseconds that must pass before a
condition is executed. This statement is usually ignored by the
synthesis tool. In this case, the functionality of the simulated
design does not match the functionality of the synthesized design.
"Usually" there is no impact on synthesis and P&R results.
Xilinx: This statement is usually ignored by the synthesis tool.
When does it have impact then?
Although the delay statement is ignored by the synthesis tool, the HDL code is a little bit different. That may change the seed of randomization in any stage (parsing, elaboration, synthesis etc.), so there is a possibility for different results. These results may be better or worse.
If a delay statement exists in the code, the following warning is expected from Xilinx ISE:
WARNING:Xst:916 - design.v line x: Delay is ignored for synthesis.

VHDL signal's Delay - Quartus

I faced a problem when using Quartus II from Altera.
In the VHDL course, I have a problem about the behavior of VHDL variables VS signals.
The theory says that the VHDL variables get its new value immediately. On the other hand , the signal's new value requires a delay. So the result is different between the two cases.
But this is not what happens when I use Quartus tool. I unexpectedly get the same result for both. I don't Know why this happens, please advise??
If your assignments all go without an explicit delay clause like y <= x after 10 ns; then the difference is a single delta cycle. A delta cycle is no physical time and is not visible in the waveform. You will see a difference though when you use either the updated variable or signal to assign to another output signal later in the same process. Assigning from the variable copies its newly computed value, assigning from the signal copies the value it started with into the current delta cycle.
You should get the same result. There shouldn't be any delay. In programs which use VHDL, the programs operate so fast that you can't measure a delay. If you want a delay you can use the "wait for x ns" command.

variable assignment and synthesizable code

Simply having a code like this :
if(rising_edge(clk)) then
temp(0):="001";
temp(1):="011";
temp(2):="101";
temp(3):="000";
temp(0):=temp(3)xor temp(5);
end if
For the example above all this variable assignment would be done in 1 clock cycle which is pretty unpractical. In the behavioral simulation it works fine but in post synthesis it's messed up. Can I add like a delay or a sth like a wait(wait statement is un-synthesizable) to make it wait util the variable gets its value before jumping to the next line?
Doing all of those things in one clock cycle is simple. Hardware is extremely fast, and FPGA clock rates aren't that high relative to processors.
Since you are using variables, the intermediate results are used immediately. If you want a more explicit delay, you could use a signal. The above code with signals would use temp(3) from the previous rising edge.
for synthesis you can not make delays like wait. well defined, controllable delays in synthesis can only be made with pipelining (clock cycles as delay units).

Resources