[Home] [Dice] [BCD to 7 Segm] [Mux Display] [Bcd Counter] [Toggle Button] [StopWatch] [Conversions] [RPN Calculator] [The Gnome II] [74x382 ALU (8-bit)]
The Gnome II
Up ] Solution 2 ]

Download this bit-file to your xxxYS-kit - Press <Btn3>, <Btn2>, <Btn1> and <Btn0> and observe how each digit at the display acts as independent counters. 

Please note! The bit file demonstrates four different implementations of possible solutions. Only <Btn3> will work correct (the best solution)

The Gnome (I) can be found here

 

Instructions of the Gnome

                                                                                                d     =  number from 0 to 15  
                                                                                                Rd  = one of register R0 to R15
                                                                                                Adr = 7-bit Address (0 to 127)
   LOAD    Rd   ACC <= Rd
 
Load ACC with the content of register d
   LOAD    #d ACC <= d Load ACC with the number d
   STORE  Rd Rd   <= ACC Store ACC in register d
      
   ADD      Rd ACC <= ACC + Rd + C
C     <= Carry out
 
   ADD      #d ACC <= ACC + d + C
C      <= Carry out
 
   XOR      Rd ACC <= ACC xor Rd  
   TEST     Rd Z      <= ACC and Rd  
     
   CLEAR_C C <= 0  
   SET_C C <= 1  
     
   SKIP_C PC <= PC + 1 + C  
   SKIP_Z PC <= PC + 1 + Z  
   JUMP  Adr PC <= Adr  


New instructions of the Gnome II

    SKIP_0D PC <= PC + 1 + 1 if ....
           Rising_edge(Button 0)
 
    SKIP_0H PC <= PC + 1 + 1 if ....
           High level at Button 0
 
    SKIP_0L PC <= PC + 1 + 1 if .....
           Low level at Button 0
 
      SKIP_xD                 Consider making the same three instructions for Button 1,2 and 3 as well
      ...................
     

 

  ;Program example with the Gnome I - This program will wait for a press at button 0.

Btn0_is_0:
                  LOAD       #1                      ; Put the test bit pattern = 0001 in the Accumulator
                  TEST        R0                     ; Test if R0, bit 0 = 1 (Note its considered that R0 = Btn3,Btn2,Btn1,Btn0)
                  SKIP_Z                              ; Conditional branch on the Zero-flag
                 JUMP       Btn0_Pressed     ; Zero-flag=0 means that R0,bit0=1
                 JUMP       Btn0_is_0           ; Zero-flag=1 means that R0,bit0=0
Btn0_Pressed:

;Do something like adding one to R12

                  LOAD      #1
Btn0_is_1:
                  TEST       R0
                  SKIP_Z
                  JUMP     Btn0_is_1            ;Zero-flag=0 means that R0,bit0=1
                  JUMP     Btn0_Released   ;Zero-flag=1 means that R0,bit0=0
 Btn0_Released:
 

;Do something more

                  JUMP     Btn0_is_0  

             
                

  ; Same program with Gnome II

Wait_for_btn0_press:
                       SKIP_0D
                       JUMP        Wait_for_btn0_press
Btn0_pressed:

;Do something like adding one to R12

                JUMP     Wait_for_btn0_press: 

 

 
The real advantage of the new SKIP_xD instructions can be seen if you want to use all four buttons in the same program with Press detection - this would be a quite hard task to implement with the Gnome I

Make the updates for the Gnome in order to implement the new instructions:

In order to make the task easier can most of the files be found below - including a Memory with the test program.

In order to implement a SKIP_xD instruction must you consider using an extra process (one for each button) - hence can a F/F (or may be a Latch) be implemented. The <Btnx> press will set the Detectx signal and later will the same signal be cleared due to the execution of the SKIP_xD instruction.