Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

how to make instruction set?

Status
Not open for further replies.

Parth86

Member
I have searched about Instruction set but I am confused I don't know what is concept how they make . I want to understand with example it's just for learning purpose
I have 2 bit ALU I have 5 instruction Add, Sub, AND , OR NOT . I choose 4 bit instruction word bit I think I need 3 control word bit I think operand will be 2bit because ALU is 2 bit and operand will be 2 bit
instruction word bit 4 bit= operand 2 bit+opcode 2 bit

I am not sure I am going to correct way please help

how to make instruction set ?
 
Hi,

If you have five different instructions then you need at least a word that is able to have a different bit pattern for each instruction, which at least takes 3 bits. If you are using immediate instruction arguments then you need two more bits for the value. That's 5 bits.
Alternately you could move to two clock cycles which would mean you can provide the instruction first and argument second. That would mean 3 bits for the instruction and that would be followed by 2 bits for the argument on the next clock cycle.

It's not entirely clear what you are doing however. Do you have registers too or just immediate values.
 
I've seen instruction sets described by the BNF form and you could really understand what was going on, See https://en.wikipedia.org/wiki/Backus–Naur_Form but I think what's there is not well written.

Long ago for a college project I did design a 16 bit instruction set, but it was really "microcode".
I think 4 bits were used for a branch. There were 16 words x 16 bits.
Microcode could be 128 or 256 bits wide and many lines of microcode might be required for one instruction.
 
Last edited:
I've seen instruction sets described by the BNF form and you could really understand what was going on, See https://en.wikipedia.org/wiki/Backus–Naur_Form but I think what's there is not well written.

Long ago for a college project I did design a 16 bit instruction set, but it was really "microcode".
I think 4 bits were used for a branch. There were 16 words x 16 bits.
Microcode could be 128 or 256 bits wide and many lines of microcode might be required for one instruction.
Hi, Its very good example but its not about micro controller instruction set
 
Not sure I understand. Our 3 member team breadboarded a "processor" of sorts using 7400 logic chips. It could sort 16 BCD numbers in ascending or decending order depending on the microcode. We knew the sort algorithm and designed an instruction set around it. 1 bit could mean place the value in temp reg A. Another bit might put the value in temp reg B. Another might be branch if A>B or branch if A<B; Another bit might be exchange A & B. You get the idea. I'd have to look at my notes.

Look here: https://www.google.com/url?sa=t&rct...k2IK4e8r2lfTezw&bvm=bv.62922401,d.dmQ&cad=rja

On PDF page 169 they describe the processor in ISP notation. The book will be a good read.
 
Not sure I understand. Our 3 member team breadboarded a "processor" of sorts using 7400 logic chips. It could sort 16 BCD numbers in ascending or decending order depending on the microcode. We knew the sort algorithm and designed an instruction set around it. 1 bit could mean place the value in temp reg A. Another bit might put the value in temp reg B. Another might be branch if A>B or branch if A<B; Another bit might be exchange A & B. You get the idea. I'd have to look at my notes.

.
Instruction word bit divide into OPCODE which specify Instruction type and operand which specify the operation of instruction
please anyone explain with example
 
Lets say you had a 16 bit word.

lets say the 1st 8 bits is an OP code.

so lets define a few instructions:
Code:
Halt:      0000 0000      the 0000 is the OP code and the second 0000 is not used, but is the operand
NOP      0001 0000       No operation
TSTC                           test carry
TSTZ                           test zero - these don't have operands

Now let's say we had an instruction that if the zero flag is set branch; The second 0000 could be a +-relative branch, That's an operand.

Yep, stuff gets messy when you add relative and direct addressing of multiple registers.
 
Lets say you had a 16 bit word.

lets say the 1st 8 bits is an OP code.

so lets define a few instructions:
Code:
Halt:      0000 0000      the 0000 is the OP code and the second 0000 is not used, but is the operand
NOP      0001 0000       No operation
TSTC                           test carry
TSTZ                           test zero - these don't have operands

Now let's say we had an instruction that if the zero flag is set branch; The second 0000 could be a +-relative branch, That's an operand.

Yep, stuff gets messy when you add relative and direct addressing of multiple registers.
Code:
ORG 000H
MOV A, #5H
MOV R1, #3H
ADD A,R1
ok tell me what is operand and op code in above program
 
Hello again,

It's not that hard to understand if you just use a simple approach. Since you have 5 instructions you need 3 bits for that, in the most basic setup. So we have the table below for instructions:
NOT 001
Add 010
Subt 011
AND 100
OR 101

Now if you have an accumulator and two registers we can number the registers 01 and 10 (in binary) and 00 for the accumulator and 11 for immediate data.

So to subtract the accumulator from itself we would use code:
01100

which is in the form:
iiirr

where 'i' is an instruction bit and 'r' is a register bit.

To add register 01 to the accumulator we would use:
01001

and to add immediate data to the accumulator we would use:
01011
followed by the actual data value to be added.

That is the most basic way to do it.

If you want to add jumps and stuff then you need a status register and some other comparison instructions.
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top