2011年9月19日 星期一

Handle-C

Handle-C 一種高階的HardWare語法, 有點像是把Hardware的Driver寫成API 的語法,讓使用者能透過這些API,直接控制硬體的行為模式.不過缺點就是Platform被綁死,而系統的最佳化取決於架構的型式.
-hardware keyword(token)
type()   : unsigned, signed,
length() : int <3>, [3:0]
size()   : [10]

unsigned 4 RAM[4][4]; 4*4 4 bits RAM

 
-logic/arithmetic
&,/,^,+,-...


-interface definition


-module keyword  
RAM,ROM,BUS,...


-method/processor
pra : parallel
seq : sequence

par 
{
    { 
        a = b; 
        c = d;
        link ! x;
    }

    link ? y;
}

/*
cycle  Branch_1    Branch_2
1      a=b;        delay
2      c=d;        delay
3      channel_out channel_in
*/

-special keywords
<- Take LSBs
\\ Drop LSBs
@  Concatenation

x = 0xC7; 
y = x <- 4; // y = 0X7
z = x \\ 4; // z = 0xC
x = y @ z;  // x = 0x7C


-standard library
static extern
volatile

extern "C" int printf(const char *format, ...);


-try except(reset)
try ... reset

try {
 a = 1;
}
reset(_condition)


- RAM Bank/Bolck Check
x = y>z ? RamA[1] : RamA[2]; // fail
x = RamA[y>z ? 1 : 2];  // pass


-Functions and macros:
functions : not recursive
macros    : recursive

macro expr multiply(x,y) = select(width(x) == 0, 0
    multiply(x\\1,y<<1) +
    (x[0] == 1 ? y : 0));

a = multiply(b,c);

a = ((b\\3)[0] == 1 ? c<<3 : 0) +
    ((b\\2)[0] == 1 ? c<<2 : 0) +
    ((b\\1)[0] == 1 ? c<<1 : 0) +
    (b[0]      == 1 ? c    : 0);

a = ((b&8) == 8 ? c*8 : 0) +
    ((b&4) == 4 ? c*4 : 0) +
    ((b&2) == 2 ? c*2 : 0) +
    ((b&1) == 1 ? c   : 0);

delay // clock cycle


-Platform type
set family = XilinxVirtex;
macro expr DoThis() =
select (__isfamily(XilinxVirtex)  : DoThing1() :
select (__isfamily(AlteraApex20K) : DoThing2() :
select (__isfamily(MadeUpDevice)  : DoThing3() : DoThing4())
)
);


-Clock timing
ram unsigned 8 ExtRAM[16384] with { 
offchip = 1, westart = 2, welength = 1, 

data = {"P1", "P2"}, 
addr = {"P9", "P10"}, 
we = {"P23"}, 
oe = {"P24"}, 
cs = {"P25"}
};

-diff Clock interface
FIFO/PORT/BUS
Ref:http://babbage.cs.qc.edu/courses/cs345/Manuals/HandelC.pdf

沒有留言:

張貼留言