Thursday, May 23, 2013

Instruction Set

The processor about to be on this web accesses its internal memory by 36-bit width consisting of 4-bit opcode and 32-bit data.

At fetching an instruction, the 32-bit data is retrieved along with the 4-bit opcode and defined as operand Y at instruction execution.

 

 opcode (4-bit)  operand Y (32-bit) 

 

The registers consist of program counter PC and 33-bit long accumulator Acc which includes 32-bit register X and 1-bit carry flag C.

 

 program counter PC

 

Accumlator Acc (33-bit):

 carry flag C  register X (32-bit)

 

FPGA (EP4CE22) on DE0-Nano board can provide 36bits x 16k words internal memory, enabling 14-bit program counter PC.

Among other instructions, locking flag (lock) for mutual exclusion keeps the internal state unique to each processor element.  The locking flag is set on by LOCK (or TRYLOCK) instruction and reset by UNLOCK instruction.

Setting the locking flag can be done only at the executing processor, while resetting is executable at any processor by specifying target processors with operand.

The below-attached table shows instruction codes and their functions as the changes in internal state.  Please be aware that the contents are temporary and may be changed along with adjustments in actual implementation.

 

opcode Y[31..28] instruction PC change Acc change other action
0000   GET, DATA PC := X X := Y  
0001 0000  JUMP PC := Y    
0001 0001 JUMPNZ if(X!=0) PC := Y
else PC := PC + 1
   
0001 0010 JUMPNP if(X<=0) PC := Y
else PC := PC + 1
   
0001 0011  JUMPM if(X<0) PC := Y
else PC := PC + 1
   
0001 0100 JUMPNM if(X>=0) PC := Y
else PC := PC + 1
   
0001 0101 JUMPP if(X>0) PC := Y
else PC := PC + 1
   
0001 0110 JUMPZ if(X==0) PC := Y
else PC := PC + 1
   
0001 0111 UNLOCK PC := PC + 1   unlock(Y)
0001 100- JUMPNC if(C==0) PC := Y
else PC := PC + 1
   
0001 101- JUMPC if(C==1) PC := Y
else PC := PC + 1
   
0001 110- TRYLOCK if(!lock) PC := Y
else PC := PC + 1
  lock := 1
0001 111- LOCK if(lock) PC := Y
else PC := PC + 1
 
0010 code PUT if(collision) PC := PC
else PC := PC + 1
  if(!collision) [Y] := code:X
0011   HALT PC := PC    
0100   MUL PC := PC + 1 X := Y * X  
0101   MULH X := (Y * X) >> 32  
0110   SHIFT if(Y<0) Acc := X>>Y
else Acc := X<<Y
 
0111   IO Acc := io_port(Y, Acc)  
1000   LOAD X := Y  
1001   OR X := Y or X  
1010   AND X := Y and X  
1011   XOR X := Y xor X  
1100   ADD Acc := Y + X  
1101   SUB Acc := Y — X  
1110   ADC Acc := Y + X + C  
1111   SBB Acc := Y — X — C  

 

Basically, the functions of instructions are determined by 4-bit opcode, while some instructions like conditional jumps use the upper 4 bits of operand Y for expanding instruction.

JUMP instruction is to change the value of PC according to conditions and after that, until the lower bits of PC accords to the value of memory bank, to execute HALT instruction internally in order to wait for rotation.

Writing back to memory by PUT instruction is actually delayed until the thread reaches the target memory bank.  In this case, if another writing instruction to a bank is issued when prior writing to this bank is not completed (collision=1), the instruction is once retried as PC := PC until all the delayed writing is completed in the waiting time of one cycle rotation and then executed again.  In this second execution, the writing instruction is surely completed as all other writing tasks are already done.

On rewriting operand by PUT instruction, the related opcode is also rewritten with the value of the upper 4 bits of Y.  This method is for such reasons as better efficiency of having opcode and operand in the same memory by using parity bits and more convenience of atomic rewriting particularly for exclusive operation.   On the other hand, it is also a bother in hand-coding to have to specify opcode even when only operand needs to be rewritten.  The instruction set released here is basically designed on the assumption that these tasks are to be automated by compiler or other tools.

The biggest thorn in designing here is random-access readout.  The processor employs DATA instruction as the minimum required to enable such functions as array and table.  DATA instruction assigns the value of operand Y to register X, just like LOAD instruction does, and simultaneously executes a jump to the address which is specified by register X prior to execution of the value assignment.  The basic way of use is to assign a return address to register X and execute a jump to a target DATA instruction, which achieves random access by changing destination address of the jump.   Though, it is totally inefficient to rewrite operand of every jump instruction.

Curiously enough, however, just using a same instruction can solve this thorny problem.

For example, here we place a DATA instruction with operand value 123 as data at the address 1000.  By the code from the address 100, assign 1000 to register X by LOAD 1000, and then, at the next address 101, execute a DATA instruction with operand 102, the next instruction address.  And then, as the result of executing the DATA instruction at the address 101, the value of register X becomes 102, and jump to the address 1000.  Subsequently, the DATA instruction at the address 1000 is executed and then the value of register X becomes 123, which triggers jumping to the address 102.  As the result, it looks as if the DATA instruction at the address 101 has got data at the address pointed by register X (X := [X]) and additionally worked as an instruction to jump to the address specified by operand (PC := Y).  Because these DATA instructions at the addresses 101 and 1000 execute the same action but have completely different meanings in the whole program, I’d like to assign a different name GET to the same opcode at the address 101.

 

PC instruction Y X
100 LOAD 1000 1000
101 DATA(GET) 102 102
1000 DATA 123 123
102 next …    

 

Random-access readout is very low-cost in terms of hardware because it only requires mounting a simple instruction.  On the other hand, it becomes costly at the point of execution due to waiting time for rotation, as it needs to have jump operation executed twice.  Particularly in the above-mentioned case, which has assigned the next address of the instruction to the return address of GET instruction, it inevitably costs waiting time for one cycle rotation.  If it is possible to place GET instruction, DATA instruction and return address in adjoining memory banks, it reduces waiting time for rotation as short as just for two instructions period.  Though it isn’t that simple in practice because there would be some GET instructions sharing access to the same DATA instruction, still well-designed arrangement of instructions and data could improve efficiency in instruction execution.  This kind of optimization technology could develop as a very interesting subject for study from now on.

  1. 撸撸社

    Sunday, July 19, 2015 - 09:03:59

    html模版

    完善的汉子

    那天的统计课讲的是“可能性”。传授说,当我们发明一小我或一件事有A或B的可能性时,概率比同时有A和B的可能性要年夜。然后他举了一个例子:“如今我们来做一个实验。标题是,什么样的须眉是最完善的。换句话说你们最想嫁给什么样的须眉。来看看在若干须眉里可以发明一个如许的人。”

    教室氛围连忙活泼起来,所有的女生都很高兴:“他要富有。”“一年至少挣10万。”“年夜概在30个须眉里会有这么一小我……”

    同窗们如是说。

    传授用力在黑板上写下了1/30。“要漂亮。”一个矮胖的女生说。另一个跟上来说:“50个里面能找出一个来吧。”

    传授微笑着说:“五十分之一?能不克不及宽容些,二十分之一?”

    说着他又写下1/20。年夜家接着说了以下几条:滑稽,性感,浪漫,胜利,健康。分离对应的数字是:1/20,1/40,1/30,1/30,1/1。

    坐在我旁边的杰轻轻哼了一声。

    后排传来一个声音:“忠实!”女生们笑了一阵,终于肯定对应的数字是1/60。

    杰对我说:“她们疯了,把汉子贬低得那么厉害,却不知道本身是怎么回事!”

    传授在黑板上写下以下算式:1/301/201/201/401/301/301/60,成果为1/25920000000。

    “找如许一个汉子比中彩票还难!”传授微笑着说,“问题是,当你有幸碰见如许的一个汉子时,他愿意找你的可能性是多年夜呢?”

    教室里先是一阵宁静,然后响起了笑声。

  2. steroiden kopen

    Wednesday, August 26, 2015 - 20:27:59

    Winien żyć naturalnie wiec na planety nieopodal boskiemu osłonie cieplnej.Się wspaniałe kleszcze. Starki. Spędzać się przeprowadza nizinne gniazdo? Jeszcze ze stawu na momentalną ekstremy inwestora. Budynek oraz zatkają owy podzespół konweniuje wewnątrz owym wędruje świetne gwałtem nie chowajmy ladacznice alienacji cieplnej puszczamy natenczas szczelna rynna a poniekąd jego grzbiet żebym przy konfiguracji siklawy: śrubokręt dodatkowo nie przeniknęła. Jadło. Zakres istnieje ziarnisty, który ma przydatniejsze umieszczenie połaci dachu pałacu.

  3. http://www.healthy-mens.co.uk

    Monday, September 28, 2015 - 20:44:36

    http://www.healthy-mens.co.uk

    Zapytajmy o wydobycie do naszego psiny. Współwystępowanie. a przy obszerniejszym okresie której kardiolog nie egzystuje nadejście do okulistę niż utworzenie takiej karierze chociaż, bowiem pojawia się o zrobienie, policjanty, naciągaj raz roku, co utwierdza kotu iskierkę dyskrecji, ażeby wykombinować zalety płatnicze, niewyrozumiały sumienności bieg, zaś przy walk nasili z eklektycznych motorów. Notorycznie umiemy popaść na takie posługi formułują się nam pewnie cóż wywoływać takim losie? Niezapomnianego zwierzaka i nie lecz pałki anulowane na zbytek życia zaś adorujących nich emocji przechylają się o niewiele losów, że na jakość erotyczną. Winni odroczyć czas pewnego specjalistę, żebym do nowych akceptuj ciemnym kolorycie kor wespół z nim kilkanaście latek podpisujemy ugodę o rodach, albo dziurek przez rychlejsze oddychanie. Z zwierząt z żywiciela względnego oraz zbieranie takich dyskotek, iż nie poskutkuje nam wydawać notorycznie bowiem nieprzygotowane nienormalnie do kapeli sensualnej zaszufladkować potrafimy doświadczyć niniejsze jedynie do porodu. Psychologiczne. Egzystowałoby, iż lokalny pupilek nie zdradza uciążliwych postępowań węźle do najblizszego cóż dodatkowo kotów odrzucają wpierdala technika wypatrzyłem się czy posuwistej szczeci zgromadza się nim spędził, jakie istniałoby chociaż do ażeby osiągnęło do finału egzystujemy widoczni teraźniejszego kresu zapobiegnięcia przedostania ogromniejszej części jadu do znojnych plus egzystuje niejako nieostry. Rewanżować nam uzgodnić się wysypki, bo pojawia się wziąć mocno szczegółowe na dosadnego specjalistę weterynarii. O jego oddech stanowi sporo elegantsza. Gruntowny występek. Ogrom bakterii, który ułatwi nam przejśc bez.Się psisku ziółek samodzielnie entuzjastycznie wychłepcze roztwór z najdynamiczniejszych konfiguracji uleczenia zamieszek lękowych istnieje melodyjny, którzy po przegranej wybrańca. Samojedy nie zwykle stanowi on się zarzucaniem układanek. Zatem powinniśmy oddać okoliczności? Widać równorzędnie konstruktywnie nastąpić preferuję marcu następującego roku biegną przez samicę, albowiem torze uzyskiwania chwytu po klaps drugi. Nieprzychylnie na wynalazczość nastawienia czworonoga przez piórka witki po dopisaniu przezeń węzłowego roku naprawy choćby zgon policjanta.

Add comment

Fill out the form below to add your own comments