Minecraft / Projects

Fast compact 8 Bit Magnitude comparator [1.12.2]

infoWhat is PMCView3D? Read the Schemagic feature announcement for more info.

  • 18
  • 5
  • comment4
  • playlist_add
  • share
  • more_horiz
avatar _Phrozenbit_
Level 25 : Expert Electrician
92
๏ปฟHello again, I'm back with another Redstone device :D

This time it's a computer component that requires that you know how to use binary to represent numbers. Anyway, this is my take on a 8 bit binary magnitude comparator. Basically what this device does is compare two 8 bit binary numbers to see if input A (green concrete) is greater than input B (green terracotta), if input A is less than B or if input A is equal to input B.

Click to see inputs, also click image for larger version




The outputs - A greater than B

Here's the image for the outputs.



The lamp that's on the yellow concrete represents the A > B output. This will light up whenever the number that has been selected on the A inputs is greater than the number that's selected on the B inputs. Here is an image with an example input.



As you can see, the binary numbers should be entered from top to bottom, meaning that the least significant bit is on top. On the A inputs I have set the binary number 0000 0100, which is the number 4 in (unsigned) binary, and on the B inputs I have selected 0000 0011, which is the number 3 in (unsigned) binary. The input of A should be greater than the input of B ( 4 > 3 ) so the lamp on the yellow concrete block should be on, which it is.



The outputs - A is equal to B

Whenever both input A and input B are exactly the same, the lamp on the blue lapis lazuli block should turn on. Interesting fact about the logic that does A == B is that it's a hack. Normally one would put input A and B of every bit through a XNOR gate and then run all the outputs to a AND gate to see if both inputs match. I've used a different approach. If there is no output on both A < B and A > B then output has to be A == B (IF ! A > B AND ! A < B THEN A == B) because what else could it be.

Here's an example for A == B. Input A is now 0000 0100 (4 using unsigned binary) and input B is the same.



Now the lamp on the lapis lazuli block should light up, as it does.



The outputs - A lesser than B

Last but not least, or in fact lesser than B so actually also least heh, A < B. The lamp on the red concrete should light up when A is lesser than B. Here's an example. I've set input A to 000 0100 (4 using unsigned binary) and B to 000 0101 (5 using unsigned binary) A is lesser then B.



So now the lamp on the red concrete block should turn on, as it does.



Design

Admittedly this design isn't completely my own. I've used a existing comparator logic that's been designed by zaubara, click here to go to their build. I've commented on this build with my old account about six years ago. In the gallery of this build is a logic diagram, I've used that as a base to build my own interpretation of the 8 bit comparator. I used the vertical design as it would fit most modern computer building styles, six years ago things were different, we were building mostly horizontal style parts. For easy reference here's the logic diagram.



I've started by building this logic diagram quite literally as you can see in this screenshot.



Then I started arranging logic gates defferently and tried a couple of things to make the design more compact. The design thats on the most right is this design. Here's a progress image.



free to use!

If you are building a CPU and are looking for a magnitude comparator feel free to use this one if it fits into your CPU design. There are many other ways to incorporate magnitude comparators so test this design as a stand alone unit first. Also feel free to check out my design on my Redsignal Redstone server!

If you plan to use this design I'd would love a link back to my submission and would appreciated a diamond. It too me a whole day to build this! Thanks for looking at my submission :D <3
CreditZaubara for his logic diagram design
Progress100% complete
Tags

Comments : 4

star Login or register to post a comment.

Show Comments

1 - 4 of 4

  • GISED_Link
  • Level 11
  • Journeyman Network
  • February 10, 2019, 9:22 pm
Hi,

nice design. The inputs are arranged vertically which is a good idea nowadays. I think your latency is 5 ticks. This is correct but is not optimal for ALU that need to be really fast.

To improve the speed, have a look of my design:
https://www.planetminecraft.com/project/8-bits-binary-comparator---gised_link/

It uses pistons (so this design is worse than yours) but it is faster.

Can you add a feature to compare signed values ?
  • _Phrozenbit_
  • Level 25
  • Expert Electrician
  • February 11, 2019, 12:43 am
Hey, thanks for feedback :3

I know I can make it a bit faster, there's a repeater after every XOR, they are there to prevent signals 'bleeding back'. The signal goes up, so I should use a slab staircase there. Will make it one tick faster.

I don't know yet how to compare signed values with this logic diagram, I'd have to look into it at some point. There is a good chance I'll improve this design anyway since I'm always messing around with it :D
  • GISED_Link
  • Level 11
  • Journeyman Network
  • February 11, 2019, 10:26 pm
To compare signed values, nothing hard : The MSB of the two numbers represents the sign. If this bit is at '1', this means that this number is negative. So if you will compare signed values, you have to invert both MSB input.
  • _Phrozenbit_
  • Level 25
  • Expert Electrician
  • February 13, 2019, 8:18 am
I'll probably look into signed binary as well. Going to work my way up again with unsigned for now, kind of getting back where I left Redstone CPU designs six years ago :3 I'm not afraid to admit that I've missed out on a lot of redstone things past six years or so.. and have to re-learn things again since so much has changed. I feel I'm getting there again though :D Thanks for the feedback!

1 - 4 of 4

Show Comments

Planet Minecraft

Browse

Site

© 2010 - 2019
planetminecraft.com

Welcome