I'm a novice at Verilog. I'm writing some glue logic to shift out data
over SPI. My problem code is this:
always @(negedge SPISS)
begin
ADCSPIShifter <= ADCTemp;
end
always @(posedge SPICLK)
begin
SPIMISO = ADCSPIShifter[63];
ADCSPIShifter = ADCSPIShifter << 1;
end
I have a register, ADCTemp, that I created in a different clock
domain. I want to shift this data out over an SPI bus. When the chip
select line (SPISS) goes low, I load the shift register from the
ADCTemp register. On each rising edge of the SPICLK, I want to shift
out a bit of the register.
I know that I'm driving ADCSPIShifter from two sources. I just can't
figure out how to solve it. The chip select line and the SPI clock
line should never transition at the same time, but I don't know how to
tell the synthesizer about that guarantee.
I'm certain there's an easy prepackaged solution to this problem that
everyone who knows anything about Verilog knows. I'm just not one of
those people who learned Verilog the right way. If anyone can suggest
a solution, I'd sure appreciate it.
|
|
0
|
|
|
|
Reply
|
WindowsGeek
|
11/17/2010 8:21:46 PM |
|
You dont specify the frequency of the clocks. You may need to use an async
fifo.
Jon
---------------------------------------
Posted through http://www.FPGARelated.com
|
|
0
|
|
|
|
Reply
|
maxascent
|
11/17/2010 8:43:12 PM
|
|
WindowsGeek <windowsgeek@gmail.com> wrote:
> I'm a novice at Verilog. I'm writing some glue logic to shift out data
> over SPI. My problem code is this:
> always @(negedge SPISS)
> begin
> ADCSPIShifter <= ADCTemp;
> end
> always @(posedge SPICLK)
> begin
> SPIMISO = ADCSPIShifter[63];
> ADCSPIShifter = ADCSPIShifter << 1;
> end
> I have a register, ADCTemp, that I created in a different clock
> domain. I want to shift this data out over an SPI bus. When the chip
> select line (SPISS) goes low, I load the shift register from the
> ADCTemp register. On each rising edge of the SPICLK, I want to shift
> out a bit of the register.
It helps if you think of gates and wires, instead of variables,
like you would in C.
If you wired this up with TTL, the outputs of your shift register
would be wired to the outputs of the ADC, which would cause
overheating in the output transistors. The simulator doesn't
overheat, but it also doesn't know what to do.
What you want is a loadable shift register. What you got was
two registers with their outputs connected together.
> I know that I'm driving ADCSPIShifter from two sources. I just can't
> figure out how to solve it. The chip select line and the SPI clock
> line should never transition at the same time, but I don't know how to
> tell the synthesizer about that guarantee.
From what you have given, I don't believe I can answer it.
The shift register normally has one clock, and a load enable such
that it loads when the load enable is active, and shifts when it isn't.
-- glen
|
|
0
|
|
|
|
Reply
|
glen
|
11/17/2010 8:47:50 PM
|
|
On Nov 17, 12:21=A0pm, WindowsGeek <windowsg...@gmail.com> wrote:
> I'm a novice at Verilog. I'm writing some glue logic to shift out data
> over SPI. My problem code is this:
>
> always @(negedge SPISS)
> begin
> =A0 =A0 =A0 =A0 ADCSPIShifter <=3D ADCTemp;
> end
>
> always @(posedge SPICLK)
> begin
> =A0 =A0 =A0 =A0 SPIMISO =3D ADCSPIShifter[63];
> =A0 =A0 =A0 =A0 ADCSPIShifter =3D ADCSPIShifter << 1;
> end
>
> I have a register, ADCTemp, that I created in a different clock
> domain. I want to shift this data out over an SPI bus. When the chip
> select line (SPISS) goes low, I load the shift register from the
> ADCTemp register. On each rising edge of the SPICLK, I want to shift
> out a bit of the register.
>
> I know that I'm driving ADCSPIShifter from two sources. I just can't
> figure out how to solve it. The chip select line and the SPI clock
> line should never transition at the same time, but I don't know how to
> tell the synthesizer about that guarantee.
>
> I'm certain there's an easy prepackaged solution to this problem that
> everyone who knows anything about Verilog knows. I'm just not one of
> those people who learned Verilog the right way. If anyone can suggest
> a solution, I'd sure appreciate it.
You need to code it like this.
always @(posedge SPICLK)
begin
if (SPISS =3D 1'b0)
ADCSPIShifter =3D ADCTemp;
else
ADCSPIShifter =3D ADCSPIShifter << 1;
end
assign SPIMISO =3D ADCSPIShifter[63];
You load the register once with your load signal and then shift it out
as needed.
Ed McGettigan
--
Xilinx Inc.
|
|
0
|
|
|
|
Reply
|
Ed
|
11/17/2010 8:56:28 PM
|
|
On 11/17/2010 12:21 PM, WindowsGeek wrote:
> I'm a novice at Verilog. I'm writing some glue logic to shift out data
> over SPI. My problem code is this:
>
> always @(negedge SPISS)
> begin
> ADCSPIShifter<= ADCTemp;
> end
>
> always @(posedge SPICLK)
> begin
> SPIMISO = ADCSPIShifter[63];
> ADCSPIShifter = ADCSPIShifter<< 1;
> end
>
> I have a register, ADCTemp, that I created in a different clock
> domain. I want to shift this data out over an SPI bus. When the chip
> select line (SPISS) goes low, I load the shift register from the
> ADCTemp register. On each rising edge of the SPICLK, I want to shift
> out a bit of the register.
>
> I know that I'm driving ADCSPIShifter from two sources. I just can't
> figure out how to solve it. The chip select line and the SPI clock
> line should never transition at the same time, but I don't know how to
> tell the synthesizer about that guarantee.
>
> I'm certain there's an easy prepackaged solution to this problem that
> everyone who knows anything about Verilog knows. I'm just not one of
> those people who learned Verilog the right way. If anyone can suggest
> a solution, I'd sure appreciate it.
My knee-jerk response to this would be to look for a clock domain that's
fast enough (at least four times SPICLK, more = better), then do the
whole thing in that clock domain, with an appropriate state machine.
--
Tim Wescott
Wescott Design Services
http://www.wescottdesign.com
Do you need to implement control loops in software?
"Applied Control Theory for Embedded Systems" was written for you.
See details at http://www.wescottdesign.com/actfes/actfes.html
|
|
0
|
|
|
|
Reply
|
Tim
|
11/17/2010 9:55:50 PM
|
|
On Nov 17, 3:56=A0pm, Ed McGettigan <ed.mcgetti...@xilinx.com> wrote:
> On Nov 17, 12:21=A0pm, WindowsGeek <windowsg...@gmail.com> wrote:
>
>
>
> > I'm a novice at Verilog. I'm writing some glue logic to shift out data
> > over SPI. My problem code is this:
>
> > always @(negedge SPISS)
> > begin
> > =A0 =A0 =A0 =A0 ADCSPIShifter <=3D ADCTemp;
> > end
>
> > always @(posedge SPICLK)
> > begin
> > =A0 =A0 =A0 =A0 SPIMISO =3D ADCSPIShifter[63];
> > =A0 =A0 =A0 =A0 ADCSPIShifter =3D ADCSPIShifter << 1;
> > end
>
> > I have a register, ADCTemp, that I created in a different clock
> > domain. I want to shift this data out over an SPI bus. When the chip
> > select line (SPISS) goes low, I load the shift register from the
> > ADCTemp register. On each rising edge of the SPICLK, I want to shift
> > out a bit of the register.
>
> > I know that I'm driving ADCSPIShifter from two sources. I just can't
> > figure out how to solve it. The chip select line and the SPI clock
> > line should never transition at the same time, but I don't know how to
> > tell the synthesizer about that guarantee.
>
> > I'm certain there's an easy prepackaged solution to this problem that
> > everyone who knows anything about Verilog knows. I'm just not one of
> > those people who learned Verilog the right way. If anyone can suggest
> > a solution, I'd sure appreciate it.
>
> You need to code it like this.
>
> always @(posedge SPICLK)
> begin
> =A0 =A0 =A0 if (SPISS =3D 1'b0)
> =A0 =A0 =A0 =A0 ADCSPIShifter =3D ADCTemp;
> =A0 =A0 =A0 else
> =A0 =A0 =A0 =A0 ADCSPIShifter =3D ADCSPIShifter << 1;
> end
>
> assign SPIMISO =3D ADCSPIShifter[63];
>
> You load the register once with your load signal and then shift it out
> as needed.
>
> Ed McGettigan
> --
> Xilinx Inc.
Well, that might work. But there are many SPI systems where the clock
does
not run constantly, so the load needs to be asynchronous. Most
designs work
around the asynchronous load requirement by using a (much faster)
internal
system clock to load the register as well as to sample the SPI clock
and data.
The OP did not say whether he has such a free-running clock in his
system.
If not he could code something like:
always @(posedge SPICLK or negedge SPISS)
begin
if (SPISS =3D 1'b0)
ADCSPIShifter =3D ADCTemp;
else
ADCSPIShifter =3D ADCSPIShifter << 1;
end
Then you get to find out whether asynchronous load shift-registers
synthesize
in the architecture of choice.
regards,
gabor
|
|
0
|
|
|
|
Reply
|
Gabor
|
11/17/2010 10:03:01 PM
|
|
|
5 Replies
1199 Views
(page loaded in 0.452 seconds)
Similiar Articles: Signal is connected to multiple drivers - comp.arch.fpga ...I'm a novice at Verilog. I'm writing some glue logic to shift out data over SPI. My problem code is this: always @(negedge SPISS) begin ADCSPIS... ored bus -- Fatal: (SIGSEGV) Bad handle or reference. - comp.lang ...Signal is connected to multiple drivers - comp.arch.fpga ... ored bus -- Fatal: (SIGSEGV) Bad handle or reference. - comp.lang ... The databus is an 8 lines bit bus which ... SPI using NI USB-8451 - comp.soft-sys.matlabSignal is connected to multiple drivers - comp.arch.fpga ... SPI using NI USB-8451 - comp.soft-sys.matlab The three wires/signals are serial clock, receive data ... the NI ... like a kid with a new toy (PPS jitter) - comp.protocols.time.ntp ...I'm not really sure how'd I'd signal an event to the ATOM driver (perhaps through ... Signal is connected to multiple drivers - comp.arch.fpga ... like a kid with a new ... Simulink Asynchronous Machine - comp.soft-sys.matlabSignal is connected to multiple drivers - comp.arch.fpga ..... that clock domain, with an appropriate state machine. ... not run constantly, so the load needs to be ... async clock design - comp.dspSignal is connected to multiple drivers - comp.arch.fpga ... But there are many SPI systems where the clock does not run constantly, so the load needs to be asynchronous. Quick sync between two computers not connected to the internet ...Signal is connected to multiple drivers - comp.arch.fpga ..... which is connected to the internet). dumbclock driver ... two computers not connected to the internet ... Signal frequency is out of range - Please change timing signal ...If I resinstall the drivers then I am back where I started. Any ideas? I ... spreads out to ... sampling frequency and time to contain a precise multiple of the signal ... How to connect to a remote MySQL database using Java - comp.lang ...Hi, I am trying to connect to a remote MySQL database using Java. I used the driver org.gjt.mm.mysql.Driver but ... Wake on LAN, or WOL, is the ability to send a signal ... How to configure backup route with BGP - comp.dcom.sys.cisco ...Hello, My Cisco 7200 is connected with two different ... if ISP supports customer's communities) to signal lower ... There are multiple ways to accomplish this, but the ... Synthesis Error : Signal is connected to multiple driversThe above code can be successfully compiled without any errors or warnings.But when you try to synthesis it you will get the following errors: this signal is connected to multiple drivers - Forum for ElectronicsI always get this message when I use a signal in to places in the process() , or in and out the process, or in the left or right of <= How can I 7/22/2012 5:26:28 PM
|