Datapath sign jump

Example of using datapath sign flag to branch (asserted when the ALU output is negative)

Download this project

Program Listing

    // [title] Datapath sign jump
// [brief] Example of using datapath sign flag to branch (asserted when the ALU output is negative)
// [categories] Examples - jump conditions

init:
    // ----------------------------------------
    // Load the next Stage_A value and subtract
    // [SUBTRACTION_VAL_1] in DataRam_A from it
    // ----------------------------------------

    // Initialize
    // [acu]    Ensure we are positioned on [SUBTRACTION_VAL_1] at 0x00
    acu(clear, clear) dmux(sa, sa) alu(hold) mac(hold)
        
    // [dmux].a     Set up to read bus Stage_A to ALU
    // [dmux].b     Set up to read [SUBTRACTION_VAL_1] from DataRam_A to ALU
    // [alu]        Set up to subtract b from a - 2 instruction pipeline delay
    // [addr]       Select Bus in 1 (Stage_A) - 1 instruction pipeline delay
    acu(hold, hold) addr(1) dmux(ba, sra) alu(subb) mac(hold)

    // Pipeline delay
    // [alu]        Data values are loaded off the datapath
    acu(hold, hold) dmux(sa, sa) alu(hold) mac(hold)

    // Conditional jump: Is dpsign asserted?
    //              [true]  Jump to [sign_is_negative]
    //              [false] Fall through to [sign_is_positive]
    // [alu]        ALU output is put on the datapath
    acu(hold, hold) dmux(sa, sa) alu(hold) mac(hold) jmp(dpsign, sign_is_negative)

sign_is_positive:
    // --------------------------------------------------
    // This branch is entered when [alu].a - [alu].b >= 0
    // --------------------------------------------------

    // Unconditional jump: return to [init]
    acu(hold, hold) dmux(sa, sa) alu(hold) mac(hold) jmp(eob, init)

sign_is_negative:
    // --------------------------------------------------
    // This branch is entered when [alu].a - [alu].b < 0
    // --------------------------------------------------

    // Unconditional jump: return to [init]
    acu(hold, hold) dmux(sa, sa) alu(hold) mac(hold) jmp(eob, init)

area data_b
org 0
dw 0x000004    // [SUBTRACTION_VAL_1]

  

State Diagrams

Jump Diagram

Your browser does not support SVG
Call Diagram for this program from the DFB Assembler Mini IDE