Support

If you have a problem or need to report a bug please email : support@dsprobotics.com

There are 3 sections to this support area:

DOWNLOADS: access to product manuals, support files and drivers

HELP & INFORMATION: tutorials and example files for learning or finding pre-made modules for your projects

USER FORUMS: meet with other users and exchange ideas, you can also get help and assistance here

NEW REGISTRATIONS - please contact us if you wish to register on the forum

Users are reminded of the forum rules they sign up to which prohibits any activity that violates any laws including posting material covered by copyright

Nand Gate

DSP related issues, mathematics, processing and techniques

Nand Gate

Postby BobF » Fri May 01, 2015 4:11 am

Bobs_Nand.fsm
(922 Bytes) Downloaded 1474 times
Hello gang,
Well I think I could use some help. I am trying to make a Nand gate that will mimic a Transistor Transistor Logic (TTL) Nand gate. Thats a hardware Nand gate that will pass Streamin data. I am not sure if the coding is right. Sometimes it SEEMS to work right and other times NOT. It should only work with values of 0 and 1, so I also coded a little module that will convert streamin data say from a Osc to just 0 and 1. Any help, suggestions, examples, etc., will be very greatly appreciated. Many thanks, BobF.....

Nand.png
Nand.png (7.5 KiB) Viewed 33238 times
BobF
 
Posts: 598
Joined: Mon Apr 20, 2015 9:54 pm

Re: Nand Gate

Postby KG_is_back » Fri May 01, 2015 10:18 am

Code: Select all
streamin in1;
streamin in2;
streamout out;


out= 1 & ((in1 & in2) ==0);


KG_is_back
 
Posts: 1196
Joined: Tue Oct 22, 2013 5:43 pm
Location: Slovakia

Re: Nand Gate

Postby BobF » Fri May 01, 2015 7:15 pm

Hey KG,

Thanks a million! Sorry to ask for more, but if you have a moment what would it be for a NOR gate and XOR gate?
I really have trouble figuring out Boolean for some reason.

Thanks again. BobF
BobF
 
Posts: 598
Joined: Mon Apr 20, 2015 9:54 pm

Re: Nand Gate

Postby KG_is_back » Fri May 01, 2015 7:52 pm

Actually there is even better solution to this. Assembler code has opcodes for preforming AND, OR, XOR and NOT(x) AND (also called ANDNOT). XOR is present only in the latest version of FS and ANDNOT has a syntax colouring bug in older versions (although it works normally)
Simple assembler modules will provide such functionality very easily. Also boolean logic will work very same way as for bitmasks if both numbers are the same.

Here are some codes for what you ask (same have two implementations, one for older FS versions,which not include XOR). Simply copy it to assembler component and remove parts you do not need (for better performance). Also "andps xmm0,F1;" code makes it work with input 1 rather than bitmasks.

Code: Select all
streamin A;
streamin B;
streamout outXOR;
streamout outNAND;
streamout outNOR;
float F1=1;
int In1=-1; //=bitwise all true

//XOR
movaps xmm0,A;
xorps xmm0,B;
andps xmm0,F1;
movaps outXOR,xmm0;
//XOR old version
movaps xmm0,A;
movaps xmm1,xmm0;
movaps xmm2,B;
andnps xmm0,xmm2;
andnps xmm2,xmm1;
orps xmm0,xmm2;
andps xmm0,F1;
movaps XOR,xmm0;


//NAND
movaps xmm0,A;
andps xmm0,B;
andnps xmm0,In1;
andps xmm0,F1;
movaps outNAND,xmm0;

//NOR
movaps xmm0,A;
orps xmm0,B;
andnps xmm0,In1;
andps xmm0,F1;
movaps outNAND,xmm0;
Last edited by KG_is_back on Sat May 02, 2015 12:57 pm, edited 1 time in total.
KG_is_back
 
Posts: 1196
Joined: Tue Oct 22, 2013 5:43 pm
Location: Slovakia

Re: Nand Gate

Postby BobF » Fri May 01, 2015 10:42 pm

Hi again KG,

Thanks many times over, you are a life saver. Now I just have to learn ASM and Boolean both (kidding around).
Have a great one! Later, BobF.....
BobF
 
Posts: 598
Joined: Mon Apr 20, 2015 9:54 pm

Re: Nand Gate

Postby martinvicanek » Sat May 02, 2015 3:30 am

I think it shold read
int In1=-1; // bitwise true
not float.
User avatar
martinvicanek
 
Posts: 1328
Joined: Sat Jun 22, 2013 8:28 pm

Re: Nand Gate

Postby KG_is_back » Sat May 02, 2015 12:56 pm

martinvicanek wrote:I think it shold read
int In1=-1; // bitwise true
not float.

Ops.. my bad... fixed in original post...
KG_is_back
 
Posts: 1196
Joined: Tue Oct 22, 2013 5:43 pm
Location: Slovakia

Re: Nand Gate

Postby BobF » Sat May 02, 2015 4:04 pm

Hello All,

What version of Flowstone does "andnps" show up in? Mine does not seem to have it. I am using version 3.02 within Fl Studio. Thanks Bobf.....
BobF
 
Posts: 598
Joined: Mon Apr 20, 2015 9:54 pm

Re: Nand Gate

Postby KG_is_back » Sat May 02, 2015 4:27 pm

andnps is in Flowstone since Synthmaker 2, I think. However, it has a syntax colouring bug - it is not recognized by assembler as valid opcode (code is marked black after it), although it works. Also one minor problem I forgot about: it works with registers only. So replace every "andnps xmm0,In1;" with "movaps xmm2,In2; andnps xmm0,xmm2;" and it should work.
KG_is_back
 
Posts: 1196
Joined: Tue Oct 22, 2013 5:43 pm
Location: Slovakia

Re: Nand Gate

Postby martinvicanek » Sat May 02, 2015 4:28 pm

3.0.8 fixes the syntax coloring bug. Otherwise KG is right that it has been there all along.
User avatar
martinvicanek
 
Posts: 1328
Joined: Sat Jun 22, 2013 8:28 pm

Next

Return to DSP

Who is online

Users browsing this forum: No registered users and 63 guests