There is 3 files in my program, compile error is "parse error before ':' token"
jtag.h
Code: Select all
/*
* jtag.h
*
* Created on: 2017年2月25日
* Author: Kevin
*/
#ifndef JTAG_H_
#define JTAG_H_
typedef unsigned char uint8;
typedef unsigned int uint32;
interface jf_jtag_tms{
void set(uint32 v);
};
interface jf_jtag_tdo{
void set(uint32 v);
};
interface jf_jtag_tdi{
void init();
uint32 get(void);
};
void jtag_tms (server interface jf_jtag_tms if_tms);
void jtag_tdo (server interface jf_jtag_tdo if_tdo) ;
void jtag_tdi (server interface jf_jtag_tdi if_tdi) ;
void jtag_clk (int interval, int cnt_pulse) ;
#endif /* JTAG_H_ */
Code: Select all
/*
* jtag.xc
*
* Created on: 2017年2月25日
* Author: Kevin
*/
# include <xs1.h>
#include "jtag.h"
out port port_tms = XS1_PORT_1H ; // J13
out port port_tck = XS1_PORT_1G ; // J8
out port port_tdo = XS1_PORT_1L ; // J10
in port port_tdi = XS1_PORT_1K ; // J12
void jtag_tms (server interface jf_jtag_tms if_tms) {
uint32 tms;
while(1){
select{
case if_tms.set(uint32 v):
tms =v;
port_tms <: tms;
break;
case port_tdi when pinsneq(1):
tms >>=1;
break;
}
}
}
void jtag_tdo (server interface jf_jtag_tdo if_tdo) {
uint32 tdo;
while(1){
select{
case if_tdo.set(uint32 v):
tdo =v;
port_tdo <: tdo;
break;
case port_tdi when pinsneq(1):
tdo >>=1;
break;
}
}
}
void jtag_tdi (server interface jf_jtag_tdi if_tdi) {
int di;
int bit_di;
while(1){
select{
case if_tdi.init():
di =0;
break;
case if_tdi.get() -> uint32 res:
res = di;
break;
case port_tdi when pinsneq(0):
tdi :> bit_di;
di <<=1;
di += bit_di;
break;
}
}
}
void jtag_clk (int interval, int cnt_pulse) {
int count ;
port_tck <: 0 @ count ; // timestamped output
while (cnt_pulse--){
count += interval;
port_tck @ count <: 1; // timed output
count += interval;
port_tck @ count <: 0; // timed output
} ;
}
Code: Select all
# include <xs1.h>
#include "jtag.h"
void test_clk(client interface jf_jtag_tms if_tms,
client interface jf_jtag_tdo if_tdo,
client interface jf_jtag_tdi if_tdi )
{
while(1){
if_tdi.init();
if_tms.set(0x55);
if_tdo.set(0xaa);
jtag_clk(5,10);
if_tdi.get();
};
}
int main(void){
interface jf_jtag_tms if_tms;
interface jf_jtag_tdo if_tdo;
interface jf_jtag_tdi if_tdi;
par{
jtag_tms(if_tms);
jtag_tdo(if_tdo);
jtag_tdi(if_tdi);
test_clk(if_tms, if_tdo, if_tdi);
}
return 0;
}
Code: Select all
15:18:23 **** Incremental Build of configuration Default for project T2 ****
xmake CONFIG=Default all
Checking build modules
No build modules used.
Analyzing jtag.xc
../src/jtag.xc:26:38: error: parse error before ':' token
case port_tdi when pinsneq(1):
^
../src/jtag.xc:41:38: error: parse error before ':' token
case port_tdi when pinsneq(1):
^
../src/jtag.xc:59:38: error: parse error before ':' token
case port_tdi when pinsneq(0):
^
../src/jtag.xc:50:9: warning: unused variable `bit_di'
int bit_di;
^~~~~~
xmake[1]: *** [.build/src/jtag.xc.pca.xml.decouple] Error 1
xmake: *** [analyze] Error 2
15:18:24 Build Finished (took 499ms)
Thank you very much!