Guest
I'm unable to get what I think is some simple code to work.
I'm loading a 16-bit register via SPI bus input as shown in Code
Section 1 below. Note NPCS corresponds to a 4-bit set of input pins
defining the selected channel, in this case `ZDAC. SPCK is the
incoming SPI clock.
After I attempt to load the count into ZDACCmd I try to compare it to
0x8000 (16'b1000000000000000) to determine if I should turn an ENable
ON in Code Section 2 below.
Begin code section 1: *********
reg [15:0] ZDACCmd = 16'b0;
wire ZSelect = !(NPCS==`ZDAC);
wire ZCmdClk = (NPCS==`ZDAC) ? SPCK : 1;
reg [4:0] ZCmdClkCount = 5'b0;
always @ ( posedge ZCmdClk or negedge ZSelect )
begin
if(!ZSelect)
begin
ZCmdClkCount = 0;
end
else
begin
case( ZCmdClkCount )
0:
begin
ZDACCmd <= 0;
end
8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23:
begin
ZDACCmd[23-ZCmdClkCount] <= MOSI;
end
endcase
ZCmdClkCount = ZCmdClkCount + 1'b1;
end
end
Begin code section 2 **********
if( Function==`WRBITBANK0 )
begin
case(Channel)
`ZENABLE:
begin
if((DATA[0]==`ENABLE_OUTPUT)&(ZDACCmd[15:0]>16'b1000000000000000))
ZEN <= `ENABLE_OUTPUT;
else
ZEN <= `DISABLE_OUTPUT;
end
End code *******
Is there anything obvious I'm doing wrong?
Thanks,
Chip Burns
I'm loading a 16-bit register via SPI bus input as shown in Code
Section 1 below. Note NPCS corresponds to a 4-bit set of input pins
defining the selected channel, in this case `ZDAC. SPCK is the
incoming SPI clock.
After I attempt to load the count into ZDACCmd I try to compare it to
0x8000 (16'b1000000000000000) to determine if I should turn an ENable
ON in Code Section 2 below.
Begin code section 1: *********
reg [15:0] ZDACCmd = 16'b0;
wire ZSelect = !(NPCS==`ZDAC);
wire ZCmdClk = (NPCS==`ZDAC) ? SPCK : 1;
reg [4:0] ZCmdClkCount = 5'b0;
always @ ( posedge ZCmdClk or negedge ZSelect )
begin
if(!ZSelect)
begin
ZCmdClkCount = 0;
end
else
begin
case( ZCmdClkCount )
0:
begin
ZDACCmd <= 0;
end
8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23:
begin
ZDACCmd[23-ZCmdClkCount] <= MOSI;
end
endcase
ZCmdClkCount = ZCmdClkCount + 1'b1;
end
end
Begin code section 2 **********
if( Function==`WRBITBANK0 )
begin
case(Channel)
`ZENABLE:
begin
if((DATA[0]==`ENABLE_OUTPUT)&(ZDACCmd[15:0]>16'b1000000000000000))
ZEN <= `ENABLE_OUTPUT;
else
ZEN <= `DISABLE_OUTPUT;
end
End code *******
Is there anything obvious I'm doing wrong?
Thanks,
Chip Burns