real constants in XST

Aug 21, 2005 2 Replies

I'm trying to use some real constants in synthesis. I expect them to be truncated to binary values, but it appears XST doesn't like them and it also doesn't like the $realtobits() system function in verilog.



Here is a short example of what I'm trying to do:



`define CLKSPD 50 //MHz `define WTIME 43.03*`CLKSPD //Wait Time is 43.03us (approximately)



module wait(clk,rst,finished); input clk; input rst; output finished;



reg finished;



reg [11:0] accum;



always @ (posedge clk or posedge rst) begin if(rst) begin accum = `WTIME) finished


I dont think real num format is supported. how do you suppose the WTIME of 43.03us will be represented as ? and what unit will it make of your "accum

I expected it to truncate the 43.03 * 50 = 2151.5 to 2151. I expected for there to be a way to convert it to an integer constant so that it could be synthesized. I don't want floating point. I simply want to use the real constants so that when the clock speed is changed, the module can be simply updated to be the most accurate representation of that amount of `WTIME.

I don't understand you question about accum = `WTIME (a real constant I would like to be converted to an integer) and it will latch finished high and it will stop (until reset is triggered).

I tried to use the $realtobits() system function to convert the constant to constant bits, but synthesizers don't recognize it.

I should also add that by adding a wire and assigning the constant to it I got quartus do do proper synthesis: wire [11:0] wtime = `WTIME;

then changing if(accum >= `WTIME) to if(accum >= wtime)

The problem is, I need to do this with XST not Quartus and the technique I used in Quartus does not work in XST. Is this an XST bug?

Thanks, Arlen

Join the Discussion

Have something to add? Share your thoughts — no account required.

Didn't find your answer?

Ask the community — no account required