08-17-2012 06:51 PM
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).
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?
08-18-2012 12:52 AM
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?
08-18-2012 02:27 AM
08-18-2012 08:09 AM
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.
08-18-2012 06:18 PM
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.
08-19-2012 03:56 AM
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.
08-20-2012 09:43 AM
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.