URL
https://opencores.org/ocsvn/hasm/hasm/trunk
Subversion Repositories hasm
[/] [hasm/] [web_uploads/] [example.hsm] - Rev 6
Compare with Previous | Blame | View Log
----------------------------------------------------- HASM Example File---------------------------------------------------.equ fpgabase 0xa0000000;.equ membase 0x80000000;.equ memfaultcount 0xa0000010;.isr isr_handler;start:call mem_test;stophere:jmp stophere;----------------------------------------------------- mem_test shows how to implement a simple memory-- test in hasm.---------------------------------------------------mem_test:ld rega,membase; -- Base address of memoryld regc,0x0; -- Loop countmem_write:ld regb,0x5a5a5a5a; -- Test pattern Awr rega,regb; -- Write rega to address pointed to by regbadd rega,0x04; -- Bump mem pointerld regb,0xa5a5a5a5; -- Test pattern Bwr rega,regb; -- Write rega to address pointed to by regbadd rega,0x04; -- Bump mem pointeradd regc,0x01; -- Bump loop countcmp_e regc,0x100; -- Done writing?jmp mem_write; -- No, keep goingld rega,membase; -- Finished writing so reinit for a readld regc,0x0; -- Reinit the loop pointermem_verify:rd regb,rega; -- Read back first locationcmp_e regb,0x5a5a5a5a; -- First value ok?call mem_fault; -- Values didn't match so call fault handleradd rega,0x4; -- Bump the address pointerrd regb,rega; -- Get the next valuecmp_e regb,0xa5a5a5a5; -- Check against second pattercall mem_fault; -- Didn't match, call the handleradd regc,0x1; -- Bump the iteration countcmp_e regc,0x100; -- Done yet?jmp mem_verify; -- No, keep goingret; -- Yep return----------------------------------------------------- mem_fault is responsible for incrementing the-- fault count stored in the FPGA.---------------------------------------------------mem_fault:push rega; -- Save regard rega,memfaultcount; -- Get the fault countadd rega,0x1; -- Increment the fault countwr rega,memfaultcount; -- Write the fault count backpop rega; -- Restore regaret; -- Return to caller----------------------------------------------------- isr_handler gets called when then the-- machine_interrupt input to the cycle_simulator-- file is brought high.---------------------------------------------------isr_handler:push regd;pop regd;ret;
