Electronic – Verilog data input

analoginputxilinx

Hello I am relatively new to verilog and need help on part of a project am working on. I need someone to guide me as to how you read data from an analog device. I bought an analog temperature sensor from sparkfun and am trying to read data from it. I can not seem to find any examples of getting input. I am using a Nexys3. Any help would be appreciated. This is all I can come up with. I have assigned my ioport to a pin in the constraints file.

Thank you

module TempSensor(
    input wire clk,
    input wire reset,
    inout ioport
   );

reg tempV[7:0], tempC[7:0];


always @(posedge clk)
    begin
        tempV <= ioport;        
    end
endmodule

Best Answer

You can also use op amps and a couple of resistors to build a digital to analog converter based on a R-2R ladder as in the attached picture (from Google images as illustration), and compare that ouput with your signal using another opamp. enter image description here

(The 74H would be your microprocessor instead, and the comparator DAC-signal is not shown here)

Start with 0 on the DAC, if the comparison gives you DAC < signal then increase it to Vcc (11111111 for a 8bits DAC); then if the comparison gives you DAC > signal decrease it to Vcc/2 (01111111), then if the comparison is DAC < signal to Vcc*0.75 etc. etc. This is called converging via dichotomy, but there are other algorithms based on the same hardware (increasing the DAC until the comparison changes sign for example).

By the way, there is a variant of Verilog which is for analog systems (Verilog A) but it won't do what you expect - the equivalent of analogRead() from an arduino. Verilog is made initially to synthesize gates, so your behavioural model can only easily interact with analog signals through ADCs with digital interfaces regardless of their actual working principle (counting, DAC dichotomy, Delta Sigma...).

You can easily find integrated chips that will spare you the trouble of designing your own ADC, for example the very basic TLC0820ACN. Parallel output and not differential, single channel, 8bits, big package... Can't be much simpler than that.