cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Highlighted
Visitor
Visitor
5,599 Views
Registered: ‎07-31-2012

Constraint file error when reading from breadboard

Hi everyone,

 

I'm using a Spartan 3 FPGA board XC3S400 and as part of my project, I'm using a breadboard (FX2-BB) where I have connected my temperature sensors. I'm trying to read the signal from the sensors. The signal from the sensors is a 40 bit signal.

I have the correct pin assignments (I'm only using one pin on the breadboard to read the signal from).

 

Now, in my VHDL file, I have my data_in port declared as a std_logic_vector (39 downto 0).  In my constraints file, I'm assigning the pin on the breadboard that I read from to the data_in port. Now, I don't know if I'm doing this right or not, but the constraint file would not compile. The reason I suspect is because I'm only using one pin to read 40 bits of data (which I suppose I could do).

 

For example;

My vhdl file has the following declared: 

data_in : std_logic_vector (30 downto 0);

 

and in my constraint file;

NET "data_in" LOC = "B4";

 

The file compiles if I read one bit at a time such as "data_in<0>". This means I'm going to have data_in<0> through to data_in<39> and have 40 pins assigned? (which is obviously not correct). Is there a way around it?

 

Kind regards

0 Kudos
6 Replies
Highlighted
Advisor
Advisor
5,593 Views
Registered: ‎10-05-2010

If you define data in as a 31 (or 40) bit vector, you'll need to define all 31 (or 40) nets in your UCF.

 

You can't read 40 bits of data using only one pin unless you do so serially. However this will require additional logic to clock incoming bits into a shift register or similar, and this can't be inferred automatically by the tools. Is the sensor using an SPI/I2C interface or something like that?

0 Kudos
Highlighted
Visitor
Visitor
5,591 Views
Registered: ‎07-31-2012

Thanks for your reply joelby. The sensor I'm using is just the most basic digital 2-in-1 temperature sensor (bought it from an electronics store, the sensor is called "Grove temperature and humidity sensor") that I have wired onto the breadboard. I have connected the "SIG" line of the sensor to the IO1 port of the breadboard.

Do you have any suggestions as to how I read the values from the sensor? The sensor provides a 40bit data signal (16 bits of humidity + 16bits of temp + 8bits of checksum).
0 Kudos
Professor
Professor
5,586 Views
Registered: ‎08-14-2007

Did you get a data sheet with the sensor?  If not do you at least know the part number so

you can search the web for one?  That would describe the data format and what you

need to do to read the sensor.

 

-- Gabor

-- Gabor
0 Kudos
Highlighted
Advisor
Advisor
5,578 Views
Registered: ‎10-05-2010

You should be able to find a complete data sheet for the sensor, but the Seeed Studios page has some good details on how it works. If you look at the waveform figure under "Usage", you'll see that you need to send a signal from the FPGA to the sensor, wait, and then read back data from the sensor, one bit at a time over a single wire. There's some C code below that you can use as a guide for a state machine that will do this.

 

It's not a very complicated task for an experienced HDL designer, but if you're new to FPGAs I would recommend working on a few simple designs until you're confident with finite state machines, tri-state I/O, synchronising asynchronous signals, etc.

 

Highlighted
Visitor
Visitor
5,572 Views
Registered: ‎07-31-2012

Gabor and joelby, thanks for your replies. I did have a look at the information, but I was wondering if there was any other way. Now that you've mentioned that I'll need to read 1 bit at a time in a loop, I guess that's the only way.

Thanks once again.

0 Kudos
Highlighted
Historian
Historian
5,562 Views
Registered: ‎02-25-2008


@vipulreddy wrote:

 Now that you've mentioned that I'll need to read 1 bit at a time in a loop, I guess that's the only way.



A loop is a software construct. You don't read "1 bit at a time in a loop."

 

You need to build a shift register which shifts in the appropriate number of bits. When all bits are shifted in, you have your data word.

----------------------------Yes, I do this for a living.
0 Kudos